From 3815e003ffd6ba245938c67f5ecebcdf75e90226 Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 25 Mar 2021 03:40:04 +0000 Subject: jao-org-notes: insert tags interactively --- lib/org/jao-org-notes.el | 14 +++++++++++--- org.org | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/org/jao-org-notes.el b/lib/org/jao-org-notes.el index 621ac12..a1b9dbe 100644 --- a/lib/org/jao-org-notes.el +++ b/lib/org/jao-org-notes.el @@ -92,10 +92,12 @@ (org-global-tags-completion-table (directory-files-recursively jao-org-notes-dir ".*\\.org")))) -(defun jao-org-notes--insert-tags () +(defun jao-org-notes--read-tags () (unless jao-org-notes--tags (jao-org-notes--update-tags)) - (let ((ts (completing-read-multiple "Tags: " jao-org-notes--tags))) - (insert "#+filetags: " (mapconcat 'identity ts " ") "\n"))) + (completing-read-multiple "Tags: " jao-org-notes--tags)) + +(defun jao-org-notes--insert-tags () + (insert "#+filetags: " (mapconcat #'identity (jao-org-notes--read-tags) " ") "\n")) (defun jao-org-notes--insert-date () (insert "#+date: ") @@ -132,6 +134,12 @@ (consult-ripgrep jao-org-notes-dir (concat "\\[\\[file:(.*/)?" (regexp-quote (buffer-name))))) +;;;###autoload +(defun jao-org-notes-insert-tags () + "Insert a list of tags at point, with completing read." + (interactive) + (insert (mapconcat 'identity (jao-org-notes--read-tags) " "))) + ;;;###autoload (defun jao-org-notes-insert-link () "Select a note file (with completion) and insert a link to it." diff --git a/org.org b/org.org index 993c6b3..ef26654 100644 --- a/org.org +++ b/org.org @@ -216,6 +216,7 @@ (major-mode-hydra-define+ org-mode () ("Notes" (("i" jao-org-notes-insert-link "insert link") + ("t" jao-org-notes-insert-tags "insert tags") ("o" jao-org-notes-open "find and open note") ("c" jao-org-notes-open-or-create "open or create note") ("v" jao-org-notes-backlinks "show backlinks")))) -- cgit v1.2.3