[PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only tags open messages
authorPieter Praet <pieter@praet.org>
Thu, 23 Feb 2012 23:09:14 +0000 (00:09 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:52 +0000 (09:44 -0800)
85/5e78ced035d9f63a87f9b83ee9faa0f8550f34 [new file with mode: 0644]

diff --git a/85/5e78ced035d9f63a87f9b83ee9faa0f8550f34 b/85/5e78ced035d9f63a87f9b83ee9faa0f8550f34
new file mode 100644 (file)
index 0000000..7dc47a6
--- /dev/null
@@ -0,0 +1,165 @@
+Return-Path: <pieter@praet.org>\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 AA76A431FC2\r
+       for <notmuch@notmuchmail.org>; Thu, 23 Feb 2012 15:11:48 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[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 jKwdCtQ+UJI0 for <notmuch@notmuchmail.org>;\r
+       Thu, 23 Feb 2012 15:11:47 -0800 (PST)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+       [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 58D3B431FD0\r
+       for <notmuch@notmuchmail.org>; Thu, 23 Feb 2012 15:11:42 -0800 (PST)\r
+Received: by mail-wi0-f181.google.com with SMTP id hi8so1241599wib.26\r
+       for <notmuch@notmuchmail.org>; Thu, 23 Feb 2012 15:11:42 -0800 (PST)\r
+Received-SPF: pass (google.com: domain of pieter@praet.org designates\r
+       10.180.97.130 as permitted sender) client-ip=10.180.97.130; \r
+Authentication-Results: mr.google.com;\r
+       spf=pass (google.com: domain of pieter@praet.org\r
+       designates 10.180.97.130 as permitted sender)\r
+       smtp.mail=pieter@praet.org\r
+Received: from mr.google.com ([10.180.97.130])\r
+       by 10.180.97.130 with SMTP id ea2mr725463wib.20.1330038702050 (num_hops\r
+       = 1); Thu, 23 Feb 2012 15:11:42 -0800 (PST)\r
+MIME-Version: 1.0\r
+Received: by 10.180.97.130 with SMTP id ea2mr588444wib.20.1330038701972;\r
+       Thu, 23 Feb 2012 15:11:41 -0800 (PST)\r
+Received: from localhost ([109.131.181.26])\r
+       by mx.google.com with ESMTPS id cs4sm13259086wib.8.2012.02.23.15.11.41\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Thu, 23 Feb 2012 15:11:41 -0800 (PST)\r
+From: Pieter Praet <pieter@praet.org>\r
+To: David Bremner <david@tethera.net>,\r
+       Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+Subject: [PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only tags\r
+       open messages\r
+Date: Fri, 24 Feb 2012 00:09:14 +0100\r
+Message-Id: <1330038554-10347-6-git-send-email-pieter@praet.org>\r
+X-Mailer: git-send-email 1.7.8.1\r
+In-Reply-To: <878vjtqhcg.fsf@praet.org>\r
+References: <878vjtqhcg.fsf@praet.org>\r
+X-Gm-Message-State:\r
+ ALoCoQnfKAtgFKsq0/uQ2vpW+bYcdLp7D71XKJ/ByMXGv7IoPqtqF2VgBaPxtUUHDBDnF45XKvFa\r
+Cc: Notmuch Mail <notmuch@notmuchmail.org>\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: Thu, 23 Feb 2012 23:11:49 -0000\r
+\r
+* emacs/notmuch-show.el\r
+\r
+  (notmuch-show-get-messages-ids):\r
+    New optional argument ONLY-OPEN.  If non-nil, only return\r
+    Message-Id's for messages which are currently visible.\r
+\r
+  (notmuch-show-tag-all):\r
+    New optional argument IGNORE-VISIBILITY, of which the inverse is\r
+    passed as ONLY-OPEN argument to `notmuch-show-get-messages-ids':\r
+    If called with a prefix arg, affect *all* messages in the current\r
+    buffer.  Otherwise, only change tags of visible messages.\r
+\r
+  (notmuch-show-archive-thread):\r
+    Update wrt changes to `notmuch-show-tag-all'.\r
+\r
+* test/emacs\r
+\r
+  - Subtest "notmuch-show: change tags of open messages in current buffer"\r
+    is no longer broken.\r
+---\r
+ emacs/notmuch-show.el |   28 ++++++++++++++++++++--------\r
+ test/emacs            |    1 -\r
+ 2 files changed, 20 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 4b37c77..4499fcd 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1334,13 +1334,17 @@ (defun notmuch-show-get-message-id ()\r
+   "Return the message id of the current message."\r
+   (concat "id:\"" (notmuch-show-get-prop :id) "\""))\r
+ \r
+-(defun notmuch-show-get-messages-ids (&optional separator)\r
++(defun notmuch-show-get-messages-ids (&optional only-open separator)\r
+   "Return a list of Message-Id's of all messages in the current buffer.\r
+ \r
++If optional argument ONLY-OPEN is non-nil, only return\r
++Message-Id's for messages which are currently visible.\r
++\r
+ If provided with optional argument SEPARATOR, return a string\r
+ instead, consisting of all Message-Id's separated by SEPARATOR."\r
+   (let ((message-ids))\r
+-    (notmuch-show-mapc t\r
++    (notmuch-show-mapc\r
++     `(if only-open (notmuch-show-message-visible-p) t)\r
+      (lambda () (push (notmuch-show-get-message-id) message-ids)))\r
+     (if separator\r
+       (mapconcat 'identity message-ids separator)\r
+@@ -1628,13 +1632,21 @@ (defun notmuch-show-tag (&optional initial-input)\r
+                     initial-input (notmuch-show-get-message-id))))\r
+     (apply 'notmuch-show-tag-message tag-changes)))\r
+ \r
+-(defun notmuch-show-tag-all (&rest tag-changes)\r
+-  "Change tags for all messages in the current thread.\r
++(defun notmuch-show-tag-all (&optional ignore-visibility &rest tag-changes)\r
++  "Change tags of all open messages in the current buffer.\r
++\r
++If optional arg IGNORE-VISIBILITY is non-nil, change tags of\r
++*all* messages in the current buffer, independent of their\r
++visibility.\r
+ \r
+ TAG-CHANGES is a list of tag operations for `notmuch-tag'."\r
+-  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))\r
+-  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)\r
+-  (notmuch-show-mapc t\r
++  (interactive (cons current-prefix-arg\r
++                   (notmuch-read-tag-changes nil notmuch-show-thread-id)))\r
++  (apply 'notmuch-tag\r
++       (notmuch-show-get-messages-ids (not ignore-visibility) " or ")\r
++       tag-changes)\r
++  (notmuch-show-mapc\r
++   `(if ignore-visibility t (notmuch-show-message-visible-p))\r
+    (lambda ()\r
+      (let* ((current-tags (notmuch-show-get-tags))\r
+           (new-tags (notmuch-update-tags current-tags tag-changes)))\r
+@@ -1719,7 +1731,7 @@ (defun notmuch-show-archive-thread (&optional unarchive)\r
+ buffer."\r
+   (interactive "P")\r
+   (let ((op (if unarchive "+" "-")))\r
+-    (notmuch-show-tag-all (concat op "inbox"))))\r
++    (notmuch-show-tag-all t (concat op "inbox"))))\r
+ \r
+ (defun notmuch-show-archive-thread-then-next ()\r
+   "Archive each message in thread, then show next thread from search."\r
+diff --git a/test/emacs b/test/emacs\r
+index 644ef59..c286ff5 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes\r
+ test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == TOTAL\r
+ \r
+ test_begin_subtest "notmuch-show: change tags of open messages in current buffer"\r
+-test_subtest_known_broken\r
+ query="$os_x_darwin_thread"\r
+ filter="from:Jiang"\r
+ add_tag="notmuch-show-tag-all"\r
+-- \r
+1.7.8.1\r
+\r