summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2023-11-18 23:22:26 -0500
committerKyle Meyer <kyle@kyleam.com>2024-01-22 00:02:53 -0500
commit8c71aff19ebf41103b367a367f5fd75bd014957f (patch)
tree8f62ef64772cbd757b5a153e3281e24df16efba5 /lisp
parent11b66c57ff48fbfd7ab1df3423b2289a7673347d (diff)
downloademacs.d-8c71aff19ebf41103b367a367f5fd75bd014957f.tar.gz
denote: Add custom command for inserting denote ID
Diffstat (limited to 'lisp')
-rw-r--r--lisp/km-denote.el13
1 files changed, 13 insertions, 0 deletions
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