]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: accept empty tag list in `notmuch-tag'
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Sun, 5 Feb 2012 07:13:51 +0000 (11:13 +0400)
committerDavid Bremner <bremner@debian.org>
Wed, 8 Feb 2012 15:21:52 +0000 (11:21 -0400)
Since `notmuch-tag' is a non-interactive function and hence is meant
to be invoked programmatically, it should accept zero tags.  Also, the
tagging operations (bound to "*", "+", "-") would accept empty input
without an error.

emacs/notmuch.el

index b06d8a113d8fce4f178b0e1f54783704761cc487..0ffdf9cb460e4cfed6221b1dcf8bba819cd07747 100644 (file)
@@ -548,15 +548,15 @@ messages instead of running (notmuch-call-notmuch-process \"tag\" ..)
 directly, so that hooks specified in notmuch-before-tag-hook and
 notmuch-after-tag-hook will be run."
   ;; Perform some validation
 directly, so that hooks specified in notmuch-before-tag-hook and
 notmuch-after-tag-hook will be run."
   ;; Perform some validation
-  (when (null tags) (error "No tags given"))
   (mapc (lambda (tag)
          (unless (string-match-p "^[-+]\\S-+$" tag)
            (error "Tag must be of the form `+this_tag' or `-that_tag'")))
        tags)
   (mapc (lambda (tag)
          (unless (string-match-p "^[-+]\\S-+$" tag)
            (error "Tag must be of the form `+this_tag' or `-that_tag'")))
        tags)
-  (run-hooks 'notmuch-before-tag-hook)
-  (apply 'notmuch-call-notmuch-process
-        (append (list "tag") tags (list "--" query)))
-  (run-hooks 'notmuch-after-tag-hook))
+  (unless (null tags)
+    (run-hooks 'notmuch-before-tag-hook)
+    (apply 'notmuch-call-notmuch-process "tag"
+          (append tags (list "--" query)))
+    (run-hooks 'notmuch-after-tag-hook)))
 
 (defcustom notmuch-before-tag-hook nil
   "Hooks that are run before tags of a message are modified.
 
 (defcustom notmuch-before-tag-hook nil
   "Hooks that are run before tags of a message are modified.