branch: externals/org-gnosis
commit a3913dd687c1c586d27b2a5f7cbc6ae09e6251e8
Author: Thanos Apollo <pub...@thanosapollo.org>
Commit: Thanos Apollo <pub...@thanosapollo.org>

    Add support for selecting multiple tags
    
    * Add org-gnosis-insert-tags
    * Use completing-read-multiple to select more than one tag to be inserted
---
 org-gnosis.el | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/org-gnosis.el b/org-gnosis.el
index ee52bd0c75..75e4b44940 100644
--- a/org-gnosis.el
+++ b/org-gnosis.el
@@ -352,7 +352,10 @@ TIMESTRING defaults to `org-gnosis-timestring'"
 (defun org-gnosis--create-file (title &optional directory extras)
   "Create a node FILE for TITLE.
 
-Insert initial Org metadata if the buffer is new or empty."
+Insert initial Org metadata if the buffer is new or empty.
+
+DIRECTORY: Directory where the file is created.
+EXTRAS: The template to be inserted at the start."
   (let* ((file (expand-file-name
                (org-gnosis--create-name title)
                (or directory org-gnosis-dir)))
@@ -462,12 +465,12 @@ If JOURNAL-P is non-nil, retrieve/create node as a 
journal entry."
           (message "Created new node: %s" node))
          (t (org-insert-link nil id node)))))
 
-;;;###autoload
-(defun org-gnosis-insert-tag ()
-  "Insert filetag."
+
+(defun org-gnosis-insert-tag (&optional tag)
+  "Insert TAG as filetag."
   (interactive)
   (let* ((filetags (org-gnosis-select 'tag 'tags '1=1 t))
-         (tag (funcall org-gnosis-completing-read-func "Select tag: " 
filetags)))
+         (tag (or tag (funcall org-gnosis-completing-read-func "Select tag: " 
filetags))))
     (save-excursion
       (goto-char (point-min))
       (if (re-search-forward "^#\\+FILETAGS:" nil t)
@@ -478,6 +481,15 @@ If JOURNAL-P is non-nil, retrieve/create node as a journal 
entry."
           (insert "#+FILETAGS: :" tag ":")
           (newline))))))
 
+;;;###autoload
+(defun org-gnosis-insert-tags (tags)
+  "Insert TAGS as filetags."
+  (interactive (list (completing-read-multiple
+                     "Select tags (seperated by ,): "
+                     (org-gnosis-select 'tag 'tags '1=1 t))))
+  (dolist (tag tags)
+    (org-gnosis-insert-tag tag)))
+
 ;;;###autoload
 (defun org-gnosis-journal-find (&optional title)
   "Find journal entry for TITLE."

Reply via email to