]> git.notmuchmail.org Git - notmuch/commitdiff
Clean up code duplication in adding or removing tag by region.
authorJesse Rosenthal <jrosenthal@jhu.edu>
Tue, 13 Apr 2010 18:47:19 +0000 (14:47 -0400)
committerCarl Worth <cworth@cworth.org>
Wed, 14 Apr 2010 17:10:55 +0000 (10:10 -0700)
Clean up code duplication, as per Carl's suggestion, by making
notmuch-search-{add/remove}-tag-thread a special case of the -region
commands, where the region in question is between (point) and (point).

emacs/notmuch.el

index 178dea212817a7fe3d3ee93aa804c8d0bcc5f1bc..be09f424a953c0686f552b7dd012ef5747b3d01a 100644 (file)
@@ -507,8 +507,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
       output)))
 
 (defun notmuch-search-add-tag-thread (tag)
-  (notmuch-call-notmuch-process "tag" (concat "+" tag) (notmuch-search-find-thread-id))
-  (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<))))
+  (notmuch-search-add-tag-region tag (point) (point)))
 
 (defun notmuch-search-add-tag-region (tag beg end)
   (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or ")))
@@ -522,8 +521,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
          (forward-line))))))
 
 (defun notmuch-search-remove-tag-thread (tag)
-  (notmuch-call-notmuch-process "tag" (concat "-" tag) (notmuch-search-find-thread-id))
-  (notmuch-search-set-tags (delete tag (notmuch-search-get-tags))))
+  (notmuch-search-remove-tag-region tag (point) (point)))
 
 (defun notmuch-search-remove-tag-region (tag beg end)
   (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or ")))