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