aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs/notmuch-tag.el
diff options
context:
space:
mode:
authorGravatar Mark Walters <markwalters1009@gmail.com>2014-05-21 10:58:50 +0100
committerGravatar David Bremner <david@tethera.net>2014-05-27 20:40:04 -0300
commit83f531ad7ee4b9e9aacac4f45148c39101f17ab8 (patch)
treed148044e13ccec467449c067c6c399b92c1379fd /emacs/notmuch-tag.el
parenta33ec9ce40ff6304d620d391593357f22dcebbf0 (diff)
emacs: make sure tagging on an empty query is harmless
Currently notmuch-tag throws a "wrong-type-argument stringp nil" if passed a nil query-string. Catch this and provide a more useful error message. This fixes a case in notmuch-tree (if you try to tag when at the end of the buffer). Secondly, as pointed out by David (dme) `notmuch-search-find-stable-query-region' can return the query string () if there are no messages in the region. This gets passed to notmuch tag, and due to interactions in the optimize_query code in notmuch-tag.c becomes, in the case tag-change is -inbox, "( () ) and (tag:inbox)". This query matches some strange collection of messages which then get archived. This should probably be fixed, but in any case make `notmuch-search-find-stable-query-region' return a nil query-string in this case. This avoids data-loss (random tag removal) in this case.
Diffstat (limited to 'emacs/notmuch-tag.el')
-rw-r--r--emacs/notmuch-tag.el2
1 files changed, 2 insertions, 0 deletions
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 07c260eb..f54aa9d6 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -387,6 +387,8 @@ notmuch-after-tag-hook will be run."
(unless (string-match-p "^[-+]\\S-+$" tag-change)
(error "Tag must be of the form `+this_tag' or `-that_tag'")))
tag-changes)
+ (unless query
+ (error "Nothing to tag!"))
(unless (null tag-changes)
(run-hooks 'notmuch-before-tag-hook)
(if (<= (length query) notmuch-tag-argument-limit)