]> git.notmuchmail.org Git - notmuch/commitdiff
notmuch.el: Implement visual feedback for add/remove tags.
authorCarl Worth <cworth@cworth.org>
Mon, 2 Nov 2009 23:48:21 +0000 (15:48 -0800)
committerCarl Worth <cworth@cworth.org>
Mon, 2 Nov 2009 23:48:21 +0000 (15:48 -0800)
There's no undo still, but at least you can see what you are doing
now.

TODO
notmuch.el

diff --git a/TODO b/TODO
index bfdd8bc4a5fee7d2ab2caa49e209385fcc827565..b94d055bfa7ef7c2527d84c362727fc796c4c88b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
 Add support to format a reply buffer for a particular message.
 
 Add support to format a reply buffer for a particular message.
 
-Add feedback for tag addition/removal to notmuch.el.
-
 Hide thread IDs in notmuch-search mode in notmuch.el.
 
 Selectively hide headers and bodies in notmuch-show mode in
 Hide thread IDs in notmuch-search mode in notmuch.el.
 
 Selectively hide headers and bodies in notmuch-show mode in
index cedbdb330568f2a412106e4e6e4e0c2629d61e55..73f0296349ee0b695a32fcb683bb54a8b15e98e8 100644 (file)
            (error (buffer-substring beg end))
            ))))))
 
            (error (buffer-substring beg end))
            ))))))
 
+(defun notmuch-search-set-tags (tags)
+  (save-excursion
+    (end-of-line)
+    (re-search-backward "(")
+    (forward-char)
+    (let ((beg (point))
+         (inhibit-read-only t))
+      (re-search-forward ")")
+      (backward-char)
+      (let ((end (point)))
+       (delete-region beg end)
+       (insert (mapconcat  'identity tags " "))))))
+
+(defun notmuch-search-get-tags ()
+  (save-excursion
+    (end-of-line)
+    (re-search-backward "(")
+    (let ((beg (+ (point) 1)))
+      (re-search-forward ")")
+      (let ((end (- (point) 1)))
+       (split-string (buffer-substring beg end))))))
+
 (defun notmuch-search-add-tag (tag)
   (interactive "sTag to add: ")
 (defun notmuch-search-add-tag (tag)
   (interactive "sTag to add: ")
-  (notmuch-search-call-notmuch-process "tag" (concat "+" tag) (concat "thread:" (notmuch-search-find-thread-id))))
+  (notmuch-search-call-notmuch-process "tag" (concat "+" tag) (concat "thread:" (notmuch-search-find-thread-id)))
+  (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<))))
 
 (defun notmuch-search-remove-tag (tag)
   (interactive "sTag to remove: ")
 
 (defun notmuch-search-remove-tag (tag)
   (interactive "sTag to remove: ")
-  (notmuch-search-call-notmuch-process "tag" (concat "-" tag) (concat "thread:" (notmuch-search-find-thread-id))))
+  (notmuch-search-call-notmuch-process "tag" (concat "-" tag) (concat "thread:" (notmuch-search-find-thread-id)))
+  (notmuch-search-set-tags (delete tag (notmuch-search-get-tags))))
 
 (defun notmuch-search-archive-thread ()
   (interactive)
 
 (defun notmuch-search-archive-thread ()
   (interactive)