If the argument is a full string or a list, the function will assume
this is a tag string or list and will not prompt the user.  If the
argument is nil or the exact strings "-" or "+" then the user will be
prompted.

The function doc is updated accordingly.
---
 emacs/notmuch.el |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0ab8fc2..3b78584 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -646,13 +646,21 @@ added or removed for all threads in the region from BEG 
to END."
           (notmuch-update-tags (notmuch-search-get-tags) tag-changes))
          (forward-line))))))

-(defun notmuch-search-tag (&optional initial-input)
-  "Change tags for the currently selected thread or region."
+(defun notmuch-search-tag (&optional tags)
+  "Change tags for the currently selected thread or region.
+
+If TAGS is a string or list it will be interpreted as tags to
+apply to the selected messages.  If TAGS is nil or either of the
+strings `-' or `+' the user will be prompted to enter tags (with
+tab completion)."
   (interactive)
   (let* ((beg (if (region-active-p) (region-beginning) (point)))
         (end (if (region-active-p) (region-end) (point)))
-        (search-string (notmuch-search-find-thread-id-region-search beg end))
-        (tags (notmuch-read-tag-changes initial-input search-string)))
+        (search-string (notmuch-search-find-thread-id-region-search beg end)))
+    (if (string-or-null-p tags)
+       (if (or (string= tags "-") (string= tags "+") (eq tags nil))
+           (setq tags (notmuch-read-tag-changes tags search-string))
+         (setq tags (list tags))))
     (apply 'notmuch-search-tag-region beg end tags)))

 (defun notmuch-search-add-tag ()
-- 
1.7.9.1

Reply via email to