[PATCH 3/3] emacs: make emacs use message-ids for tagging
Mark Walters
markwalters1009 at gmail.com
Fri Nov 9 10:58:11 PST 2012
This makes emacs use the new --output=with-ids in search mode and use
this for tagging. This fixes the race condition in tagging from
search mode so mark the tests fixed.
---
emacs/notmuch.el | 22 ++++++++++++++++++++--
test/emacs | 2 --
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f9454d8..49a57b2 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -492,6 +492,21 @@ If BARE is set then do not prefix with \"thread:\""
"Return a search string for threads for the current region"
(mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or "))
+(defun notmuch-search-find-msg-ids-region (beg end &optional only-matching)
+ "Return a list of msg-ids for the current region"
+ (let ((msg-ids))
+ (mapc (lambda (msg-id) (setq msg-ids (append msg-id msg-ids)))
+ (append (notmuch-search-properties-in-region :matching_msg_ids beg end)
+ (unless only-matching
+ (notmuch-search-properties-in-region :nonmatching_msg_ids beg end))))
+ msg-ids))
+
+(defun notmuch-search-find-msg-ids-region-search (beg end &optional only-matching)
+ "Return a search string for msg-ids in threads for the current region"
+ (mapconcat (lambda (id) (notmuch-id-to-query id))
+ (notmuch-search-find-msg-ids-region beg end only-matching)
+ " or "))
+
(defun notmuch-search-find-authors ()
"Return the authors for the current thread"
(plist-get (notmuch-search-get-result) :authors))
@@ -566,7 +581,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
(defun notmuch-search-tag-region (beg end &optional tag-changes)
"Change tags for threads in the given region."
- (let ((search-string (notmuch-search-find-thread-id-region-search beg end)))
+ (let ((search-string (notmuch-search-find-msg-ids-region-search beg end)))
(setq tag-changes (funcall 'notmuch-tag search-string tag-changes))
(notmuch-search-foreach-result beg end
(lambda (pos)
@@ -842,7 +857,9 @@ non-authors is found, assume that all of the authors match."
See `notmuch-tag' for information on the format of TAG-CHANGES."
(interactive)
- (apply 'notmuch-tag notmuch-search-query-string tag-changes))
+ (apply 'notmuch-tag (notmuch-search-find-msg-ids-region-search
+ (point-min) (point-max) t)
+ tag-changes))
(defun notmuch-search-buffer-title (query)
"Returns the title for a buffer with notmuch search results."
@@ -939,6 +956,7 @@ Other optional parameters are used as follows:
"notmuch-search" buffer
notmuch-command "search"
"--format=json"
+ "--output=with-ids"
(if oldest-first
"--sort=oldest-first"
"--sort=newest-first")
diff --git a/test/emacs b/test/emacs
index 6246177..4102198 100755
--- a/test/emacs
+++ b/test/emacs
@@ -123,7 +123,6 @@ output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
test_begin_subtest "Tag all matching messages from search view"
-test_subtest_known_broken
notmuch tag +test-tag-race from:cworth
test_emacs "(notmuch-search \"tag:test-tag-race\")
(notmuch-test-wait)"
@@ -135,7 +134,6 @@ notmuch tag -test-tag-race '*'
notmuch tag -test-tag-race-2 '*'
test_begin_subtest "Change tags from search view: another message arriving after thread lookup"
-test_subtest_known_broken
typsos_id="878we4qdqf.fsf at yoom.home.cworth.org"
typsos_thread=$(notmuch search --output=threads id:$typsos_id)
test_emacs "(notmuch-search \"$typsos_thread\")
--
1.7.9.1
More information about the notmuch
mailing list