From fabf7f0888bf171a6d112a46320658476d1d1993 Mon Sep 17 00:00:00 2001 From: Dmitry Kurochkin Date: Fri, 24 Feb 2012 14:47:30 +0400 Subject: [PATCH] Re: [PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only tags open messages --- ab/f09edfe77b302b00980329cc417d8bcdc824c2 | 183 ++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 ab/f09edfe77b302b00980329cc417d8bcdc824c2 diff --git a/ab/f09edfe77b302b00980329cc417d8bcdc824c2 b/ab/f09edfe77b302b00980329cc417d8bcdc824c2 new file mode 100644 index 000000000..01e745ecb --- /dev/null +++ b/ab/f09edfe77b302b00980329cc417d8bcdc824c2 @@ -0,0 +1,183 @@ +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 9EFC4403E3E + for ; Fri, 24 Feb 2012 02:48:57 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, 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 2tfC4MufaMCG for ; + Fri, 24 Feb 2012 02:48:56 -0800 (PST) +Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com + [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id CB9AC40BC64 + for ; Fri, 24 Feb 2012 02:48:55 -0800 (PST) +Received: by bkcit16 with SMTP id it16so2026518bkc.26 + for ; Fri, 24 Feb 2012 02:48:54 -0800 (PST) +Received-SPF: pass (google.com: domain of dmitry.kurochkin@gmail.com + designates 10.205.137.4 as permitted sender) + client-ip=10.205.137.4; +Authentication-Results: mr.google.com; spf=pass (google.com: domain of + dmitry.kurochkin@gmail.com designates 10.205.137.4 as permitted + sender) smtp.mail=dmitry.kurochkin@gmail.com; + dkim=pass header.i=dmitry.kurochkin@gmail.com +Received: from mr.google.com ([10.205.137.4]) + by 10.205.137.4 with SMTP id im4mr798946bkc.136.1330080534423 (num_hops + = 1); Fri, 24 Feb 2012 02:48:54 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; + h=from:to:cc:subject:in-reply-to:references:user-agent:date + :message-id:mime-version:content-type; + bh=Kc4HyIXOqwcMKjafbL9sl4PYrI8qnOfsZfyTHIIEwrM=; + b=wXPC+kshF/QywXsrYSF3YxmflWWQxslMLP/cr6HsDbOdnYgzVCheOV882J0o4/ux8P + jgEPlfsG+n8kt7WZzxQuUlJ9oq2E7tYU/FHiZRfKKHIXhPXkWrh4ECxtyg9R7y9KNXdh + 7Ra5Fzg6VwCb51+1EauxxneQ+4xcuA64mh9Vk= +Received: by 10.205.137.4 with SMTP id im4mr664982bkc.136.1330080534343; + Fri, 24 Feb 2012 02:48:54 -0800 (PST) +Received: from localhost ([91.144.186.21]) + by mx.google.com with ESMTPS id jd17sm7920907bkb.4.2012.02.24.02.48.53 + (version=TLSv1/SSLv3 cipher=OTHER); + Fri, 24 Feb 2012 02:48:53 -0800 (PST) +From: Dmitry Kurochkin +To: Pieter Praet , David Bremner +Subject: Re: [PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only + tags open messages +In-Reply-To: <1330038554-10347-6-git-send-email-pieter@praet.org> +References: <878vjtqhcg.fsf@praet.org> + <1330038554-10347-6-git-send-email-pieter@praet.org> +User-Agent: Notmuch/0.11.1+188~ga5674c2 (http://notmuchmail.org) Emacs/23.3.1 + (x86_64-pc-linux-gnu) +Date: Fri, 24 Feb 2012 14:47:30 +0400 +Message-ID: <87aa48jynx.fsf@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +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: Fri, 24 Feb 2012 10:48:58 -0000 + +On Fri, 24 Feb 2012 00:09:14 +0100, Pieter Praet wrote: +> * 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) + +How about changing ONLY-OPEN to a general optional PREDICATE argument +and pass it as is to `notmuch-show-mapc'? Please make it the last +argument. + +Regards, + Dmitry + +> (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 +> -- 2.26.2