Re: [PATCH v2 6/6] emacs: `notmuch-show-tag-all' with prefix arg only tags open messages
authorEthan Glasser-Camp <ethan.glasser.camp@gmail.com>
Tue, 16 Oct 2012 03:39:47 +0000 (23:39 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:49 +0000 (09:49 -0800)
90/3e0b2fafaa78fd3e3d80914791f155ae8f3aa2 [new file with mode: 0644]

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