[PATCH 3/3] emacs: make emacs use message-ids for tagging
authorMark Walters <markwalters1009@gmail.com>
Fri, 9 Nov 2012 18:58:11 +0000 (18:58 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:28 +0000 (09:50 -0800)
58/aeb6ef5ac5c8ff00b61da6aa0098903e04c17b [new file with mode: 0644]

diff --git a/58/aeb6ef5ac5c8ff00b61da6aa0098903e04c17b b/58/aeb6ef5ac5c8ff00b61da6aa0098903e04c17b
new file mode 100644 (file)
index 0000000..76f7a66
--- /dev/null
@@ -0,0 +1,147 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 617CC431FAE\r
+       for <notmuch@notmuchmail.org>; Fri,  9 Nov 2012 10:58:51 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id wDtvGqpIRnNR for <notmuch@notmuchmail.org>;\r
+       Fri,  9 Nov 2012 10:58:49 -0800 (PST)\r
+Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
+ [74.125.82.45])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 8BEE0431FDB   for <notmuch@notmuchmail.org>; Fri,  9 Nov 2012 10:58:30 -0800\r
+ (PST)\r
+Received: by mail-wg0-f45.google.com with SMTP id dq12so2288423wgb.2\r
+       for <notmuch@notmuchmail.org>; Fri, 09 Nov 2012 10:58:30 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=u5ZMK8YMUY9tgKTvHW4BxuxSCRUop4jbSDlXwc001Jw=;\r
+       b=vlKUq1tMuqheogDZ2k6jkKKMakfaMzi6cjzNWPIkkzYN//vAIN27zwHCD+8dBiC4zy\r
+       e+eETPhBT1RnmywDF4rvC0K9THBle6V6XM8ZJ9xaq4Lf+AA+tssdlieigKUdz0mknvJA\r
+       i6j2ldS72PceOe37L9YsPNazcXNearSGuPO7FMPHeWxeCSpifStce8zuO+i9uQGPbJqn\r
+       z9LDVirFb7gt6AFdwCvquINdezOWEy/mdEq6JgaomWSt9HAavCzue+d1pZQU7vdbecAU\r
+       TGuE+QWVSW1E56911xupGJLKWLhjuvorxI1fM3d4B5SqhNOuTHuC2fX4ycc7fNhJhA1e\r
+       kO5Q==\r
+Received: by 10.180.84.202 with SMTP id b10mr4153807wiz.13.1352487510158;\r
+       Fri, 09 Nov 2012 10:58:30 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPS id bn7sm3764993wib.8.2012.11.09.10.58.28\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 09 Nov 2012 10:58:29 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/3] emacs: make emacs use message-ids for tagging\r
+Date: Fri,  9 Nov 2012 18:58:11 +0000\r
+Message-Id: <1352487491-31512-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1352487491-31512-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1352487491-31512-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 09 Nov 2012 18:58:51 -0000\r
+\r
+This makes emacs use the new --output=with-ids in search mode and use\r
+this for tagging.  This fixes the race condition in tagging from\r
+search mode so mark the tests fixed.\r
+---\r
+ emacs/notmuch.el |   22 ++++++++++++++++++++--\r
+ test/emacs       |    2 --\r
+ 2 files changed, 20 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index f9454d8..49a57b2 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -492,6 +492,21 @@ If BARE is set then do not prefix with \"thread:\""\r
+   "Return a search string for threads for the current region"\r
+   (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or "))\r
+ \r
++(defun notmuch-search-find-msg-ids-region (beg end &optional only-matching)\r
++  "Return a list of msg-ids for the current region"\r
++  (let ((msg-ids))\r
++    (mapc (lambda (msg-id) (setq msg-ids (append msg-id msg-ids)))\r
++          (append (notmuch-search-properties-in-region :matching_msg_ids beg end)\r
++                  (unless only-matching\r
++                    (notmuch-search-properties-in-region :nonmatching_msg_ids beg end))))\r
++    msg-ids))\r
++\r
++(defun notmuch-search-find-msg-ids-region-search (beg end &optional only-matching)\r
++  "Return a search string for msg-ids in threads for the current region"\r
++  (mapconcat (lambda (id) (notmuch-id-to-query id))\r
++           (notmuch-search-find-msg-ids-region beg end only-matching)\r
++           " or "))\r
++\r
+ (defun notmuch-search-find-authors ()\r
+   "Return the authors for the current thread"\r
+   (plist-get (notmuch-search-get-result) :authors))\r
+@@ -566,7 +581,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"."\r
+ \r
+ (defun notmuch-search-tag-region (beg end &optional tag-changes)\r
+   "Change tags for threads in the given region."\r
+-  (let ((search-string (notmuch-search-find-thread-id-region-search beg end)))\r
++  (let ((search-string (notmuch-search-find-msg-ids-region-search beg end)))\r
+     (setq tag-changes (funcall 'notmuch-tag search-string tag-changes))\r
+     (notmuch-search-foreach-result beg end\r
+       (lambda (pos)\r
+@@ -842,7 +857,9 @@ non-authors is found, assume that all of the authors match."\r
+ \r
+ See `notmuch-tag' for information on the format of TAG-CHANGES."\r
+   (interactive)\r
+-  (apply 'notmuch-tag notmuch-search-query-string tag-changes))\r
++  (apply 'notmuch-tag (notmuch-search-find-msg-ids-region-search\r
++                     (point-min) (point-max) t)\r
++       tag-changes))\r
+ \r
+ (defun notmuch-search-buffer-title (query)\r
+   "Returns the title for a buffer with notmuch search results."\r
+@@ -939,6 +956,7 @@ Other optional parameters are used as follows:\r
+                    "notmuch-search" buffer\r
+                    notmuch-command "search"\r
+                    "--format=json"\r
++                   "--output=with-ids"\r
+                    (if oldest-first\r
+                        "--sort=oldest-first"\r
+                      "--sort=newest-first")\r
+diff --git a/test/emacs b/test/emacs\r
+index 6246177..4102198 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -123,7 +123,6 @@ output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)\r
+ 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)"\r
+ \r
+ test_begin_subtest "Tag all matching messages from search view"\r
+-test_subtest_known_broken\r
+ notmuch tag +test-tag-race from:cworth\r
+ test_emacs "(notmuch-search \"tag:test-tag-race\")\r
+           (notmuch-test-wait)"\r
+@@ -135,7 +134,6 @@ notmuch tag -test-tag-race '*'\r
+ notmuch tag -test-tag-race-2 '*'\r
+ \r
+ test_begin_subtest "Change tags from search view: another message arriving after thread lookup"\r
+-test_subtest_known_broken\r
+ typsos_id="878we4qdqf.fsf@yoom.home.cworth.org"\r
+ typsos_thread=$(notmuch search --output=threads id:$typsos_id)\r
+ test_emacs "(notmuch-search \"$typsos_thread\")\r
+-- \r
+1.7.9.1\r
+\r