cashmere

cashmere

Custom denote capture functions

Description

My custom denote capture functions.

Base function for capturing

(defun my/denote-insert-body (source context)
  "Insert structured body with * Source and * Context sections."
  (goto-char (point-max))
  (insert "\n")
  (when source
    (insert "* Source\n  " source "\n"))
  (when context
    (insert "* Context\n  " context "\n"))
  (save-buffer))

Quick capture

This function is for when I need to capture something in my head quickly.

(defun my/denote-quick-note ()
  (interactive)
  (let* ((title (read-string "Title: "))
         (context (when (y-or-n-p "Add context? ") (read-string "Context: ")))
         (file-name (denote title nil)))
    (with-current-buffer (find-file-noselect file-name)
      (my/denote-insert-body nil context))))

Task capture

A capture for tasks with task state, title, filetags and context if needed

(defun my/denote-todo ()
  (interactive)
  (let* ((type (read-string "Type of TODO: "))
         (task (read-string "Task: "))
         (tag (read-string "Tag: "))
         (context (when (y-or-n-p "Add context? ") (read-string "Context: ")))
         (title (format "%s %s" type task))
         (keywords (delq nil (list "task" type tag)))
         (file-name (denote title keywords)))
    (with-current-buffer (find-file-noselect file-name)
      (my/denote-insert-body nil context))))

To capture links which I may need later.

(defun my/denote-link ()
  (interactive)
  (let* ((title (read-string "Title: "))
         (link (read-string "Link (URL): "))
         (context (when (y-or-n-p "Add context? ") (read-string "Context: ")))
         (file-name (denote title '("link"))))
    (with-current-buffer (find-file-noselect file-name)
      (my/denote-insert-body link context))))