From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/3] emacs: make emacs use message-ids for tagging
Date: Fri, 9 Nov 2012 18:58:11 +0000 [thread overview]
Message-ID: <1352487491-31512-4-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1352487491-31512-1-git-send-email-markwalters1009@gmail.com>
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@yoom.home.cworth.org"
typsos_thread=$(notmuch search --output=threads id:$typsos_id)
test_emacs "(notmuch-search \"$typsos_thread\")
--
1.7.9.1
next prev parent reply other threads:[~2012-11-09 18:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 18:58 [PATCH 0/3] Outline fix for emacs tagging race Mark Walters
2012-11-09 18:58 ` [PATCH 1/3] test: test for race when tagging from emacs search Mark Walters
2012-11-09 18:58 ` [PATCH 2/3] cli: all search mode to include msg-ids with JSON output Mark Walters
2012-11-22 16:15 ` Jameson Graef Rollins
2012-11-22 18:05 ` Michal Nazarewicz
2012-11-22 19:35 ` Mark Walters
2012-11-23 7:23 ` Jameson Graef Rollins
2012-11-23 9:01 ` Tomi Ollila
2012-11-23 20:39 ` Austin Clements
2012-11-09 18:58 ` Mark Walters [this message]
2012-11-09 21:25 ` [PATCH 0/3] Outline fix for emacs tagging race Tomi Ollila
2012-11-09 23:27 ` David Bremner
2012-11-10 5:29 ` Austin Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352487491-31512-4-git-send-email-markwalters1009@gmail.com \
--to=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).