This lets the user specify some tag changes as #tag or =tag which mean the same as +tag and -tag except the reverse changes are not applied when reversing the operation. --- emacs/notmuch-tag.el | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el index 2fdccb6..b18dbf0 100644 --- a/emacs/notmuch-tag.el +++ b/emacs/notmuch-tag.el @@ -50,7 +50,7 @@ (,(kbd "u") notmuch-show-mark-read-tags "Mark read") (,(kbd "f") ("+flagged") "Flag") (,(kbd "s") ("+spam" "-inbox") "Mark as spam") - (,(kbd "d") ("+deleted" "-inbox") "Delete")) + (,(kbd "d") ("+deleted" "=inbox") "Delete")) "A list of keys and corresponding tagging operations For each key (or key sequence) you can specify a sequence of @@ -463,14 +463,27 @@ notmuch-after-tag-hook will be run." Add a \"+\" prefix to any tag in TAGS list that doesn't already begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all -\"+\" prefixes with \"-\" and vice versa in the result." - (mapcar (lambda (str) - (let ((s (if (string-match "^[+-]" str) str (concat "+" str)))) - (if reverse - (concat (if (= (string-to-char s) ?-) "+" "-") - (substring s 1)) - s))) - tags)) +\"+\" prefixes with \"-\" and vice versa in the result. + +Tags may also start with \"#\" or \"=\" which mean the same as + +or - (respectively) when the forward operation is done, but are +dropped when REVERSE is non-nil." + (remove-if 'null + (mapcar (lambda (str) + (let* ((s (if (string-match "^[+#=-]" str) + str + (concat "+" str))) + (change (string-to-char s)) + (tag (substring s 1))) + ;; we have a no-op if reverse and # or = + (unless (and reverse (or (= change ?#) (= change ?=))) + (let ((real-change (if reverse + (if (= change ?-) "+" "-") + (case change + ((?+ ?#) "+") + ((?- ?=) "-"))))) + (concat real-change tag))))) + tags))) (defun notmuch-tag-jump (reverse) (interactive "P") @@ -486,7 +499,7 @@ begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all (second binding))) (tag-change (if reverse (notmuch-tag-change-list forward-tag-change 't) - forward-tag-change)) + (notmuch-tag-change-list forward-tag-change))) (name (or (and (not (string= (third binding) "")) (third binding)) (and (symbolp (second binding)) -- 2.1.4