From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B3A84431FB6 for ; Mon, 15 Oct 2012 20:39:52 -0700 (PDT) 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 c-w+WkD2Kk3M for ; Mon, 15 Oct 2012 20:39:51 -0700 (PDT) Received: from mail-qc0-f181.google.com (mail-qc0-f181.google.com [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D6CCF431FAE for ; Mon, 15 Oct 2012 20:39:51 -0700 (PDT) Received: by mail-qc0-f181.google.com with SMTP id x40so5312744qcp.26 for ; Mon, 15 Oct 2012 20:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=DwGiWcNJuuG9SrYxYn7qI9Ivh9B2CY4G419TURTY8VI=; b=V2omV3klcqiYcvYloPQfmOKy+WalfS3mnWA/utCBGEJrY3bo9oNMmPc2SX6ww+SxrL N5p4di6kB7324/gQZDC7aZPBI5KLL6sMD94qB+EpPjwMQJ+S3FSkLUFcC+IVU9Nh/Ebi khvIKVSkyZYU7He7FPepeKd6pUYdw4sgzKoQHC/y76uxMaOANFxTCrepgPgLXAh2C1EI oTbPl4bzRu+j/ywZn8lJsFuguG9NZrphIVYGoORRDRe9JQ/Yzg88Ilbb20VZD0A0xyrG wQbWJXPoENI6Op1N1fLpXkQTSWROHRuZbebPjbaqE2eEybw4/TJxZeKszwfdJytLSpZ5 qj9g== Received: by 10.224.189.5 with SMTP id dc5mr23621660qab.89.1350358791246; Mon, 15 Oct 2012 20:39:51 -0700 (PDT) Received: from smtp.gmail.com (p70-80.acedsl.com. [66.114.70.80]) by mx.google.com with ESMTPS id cz8sm11608598qab.21.2012.10.15.20.39.49 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 20:39:50 -0700 (PDT) From: Ethan Glasser-Camp To: Pieter Praet , David Bremner , Dmitry Kurochkin Subject: Re: [PATCH v2 6/6] emacs: `notmuch-show-tag-all' with prefix arg only tags open messages In-Reply-To: <1330122640-18895-7-git-send-email-pieter@praet.org> References: <87wr7xqpuf.fsf@rocinante.cs.unb.ca> <1330122640-18895-1-git-send-email-pieter@praet.org> <1330122640-18895-7-git-send-email-pieter@praet.org> User-Agent: Notmuch/0.14+45~g6ea9330 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Mon, 15 Oct 2012 23:39:47 -0400 Message-ID: <87fw5f84qk.fsf@betacantrips.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: Tue, 16 Oct 2012 03:39:53 -0000 Pieter Praet writes: > * emacs/notmuch-show.el > > (notmuch-show-get-messages-ids): > If provided with optional argument PREDICATE, only return > Message-Id's of messages for which PREDICATE returns non-nil. > > (notmuch-show-tag-all): > New argument ONLY-OPEN (set to `current-prefix-arg' if running > interactively): if non-nil, only change tags of *open* messages. > Also correct original docstring: 's/thread/buffer/'. > > (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... This patch is stale, but in case it helps.. > --- > emacs/notmuch-show.el | 33 ++++++++++++++++++++++++--------- > test/emacs | 1 - > 2 files changed, 24 insertions(+), 10 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index 05606fc..4bd1a7c 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -1339,14 +1339,18 @@ (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 separator predicate) > "Return a list of Message-Id's of all messages in the current buffer. > > If provided with optional argument SEPARATOR, return a string > -instead, consisting of all Message-Id's separated by SEPARATOR." > +instead, consisting of all Message-Id's separated by SEPARATOR. > + > +If provided with optional argument PREDICATE, only return > +Message-Id's of messages for which PREDICATE returns non-nil." > (let ((message-ids)) > (notmuch-show-mapc > - (lambda () (push (notmuch-show-get-message-id) message-ids))) > + (lambda () (push (notmuch-show-get-message-id) message-ids)) > + predicate) > (if separator > (mapconcat 'identity message-ids separator) > message-ids))) > @@ -1633,18 +1637,29 @@ (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 (only-open &rest tag-changes) > + "Change tags of all messages in the current buffer. I'm not crazy about notmuch-show-tag-all having an argument to control whether or not it tags all. Introduce another function, or perhaps change this one's name? I also don't really like that the only-open argument comes before the tag changes. This means changing every caller (although I guess there's just one right now). I think tag-changes are more important and should come first. (tag-changes are &optional instead of &rest in master, so you can just put only-open after instead of before.) > + > +If ONLY-OPEN is non-nil, only change tags of *open* messages in > +the current buffer. > > 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) > + (interactive (cons current-prefix-arg > + (notmuch-read-tag-changes nil notmuch-show-thread-id))) > + (apply 'notmuch-tag > + (notmuch-show-get-messages-ids > + " or " > + `(lambda () > + ,(if only-open '(notmuch-show-message-visible-p) t))) > + tag-changes) This is a very awkward use of backquote, to my eyes. Besides, can't you just replace this with (if only-open 'notmuch-show-message-visible-p nil) ? > (notmuch-show-mapc > (lambda () > (let* ((current-tags (notmuch-show-get-tags)) > (new-tags (notmuch-update-tags current-tags tag-changes))) > (unless (equal current-tags new-tags) > - (notmuch-show-set-tags new-tags)))))) > + (notmuch-show-set-tags new-tags)))) > + `(lambda () > + ,(if only-open '(notmuch-show-message-visible-p) t)))) Same. Ethan