diff options
-rw-r--r-- | init.el | 3 | ||||
-rw-r--r-- | lisp/km-denote.el | 13 |
2 files changed, 15 insertions, 1 deletions
@@ -1720,7 +1720,8 @@ ("C-c d D" . denote-date) ("C-c d t" . denote-type) ("C-c d f" . km/find-file-with-denote-naming) - ("C-c d ." . km/denote-find-file-at-point)) + ("C-c d ." . km/denote-find-file-at-point) + ("C-c d i" . km/denote-insert-id)) :config (setq denote-directory (expand-file-name "~/notes")) (setq denote-dired-directories (list denote-directory)) diff --git a/lisp/km-denote.el b/lisp/km-denote.el index eade820..24e98d2 100644 --- a/lisp/km-denote.el +++ b/lisp/km-denote.el @@ -53,5 +53,18 @@ The file must be tracked in Git." (process-lines "git" "ls-files" "--" (concat "**/" id "--*")) (user-error "No tracked file found for %s" id)))))) +(defun km/denote-insert-id (&optional with-prefix) + "Insert ID of tracked file in `denote-directory'. +When WITH-PREFIX is non-nil, prepend \"denote:\" to the inserted +ID." + (interactive "P") + (let* ((default-directory denote-directory) + (id (or (denote-extract-id-from-string + (completing-read + "Note: " + (process-lines "git" "ls-files" "--" "*--*"))) + (error "Could not determine ID")))) + (insert (concat (and with-prefix "denote:") id)))) + (provide 'km-denote) ;;; km-denote.el ends here |