aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs/notmuch-tag.el
diff options
context:
space:
mode:
authorGravatar Jani Nikula <jani@nikula.org>2012-09-06 18:32:37 +0300
committerGravatar David Bremner <bremner@debian.org>2012-09-19 08:01:59 -0300
commit1dc7e66ee7186679e7669f045a4d787f36d26860 (patch)
treede4224ab6deac509e08e7f14f004a4dc87cc038f /emacs/notmuch-tag.el
parent69843dd6283f17656510f1aae197bc263f9633e1 (diff)
emacs: add helper for tag change list manipulation
Add a helper to create (and optionally reverse) a list of tag changes.
Diffstat (limited to 'emacs/notmuch-tag.el')
-rw-r--r--emacs/notmuch-tag.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 0c0fc875..4fce3a98 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -140,6 +140,21 @@ notmuch-after-tag-hook will be run."
;; in all cases we return tag-changes as a list
tag-changes)
+(defun notmuch-tag-change-list (tags &optional reverse)
+ "Convert TAGS into a list of tag changes.
+
+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))
+
+
;;
(provide 'notmuch-tag)