Re: [PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc'
authorPieter Praet <pieter@praet.org>
Fri, 24 Feb 2012 22:35:26 +0000 (23:35 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:55 +0000 (09:44 -0800)
cd/dbb3b0daa333cf20088d07d33126b873af17a2 [new file with mode: 0644]

diff --git a/cd/dbb3b0daa333cf20088d07d33126b873af17a2 b/cd/dbb3b0daa333cf20088d07d33126b873af17a2
new file mode 100644 (file)
index 0000000..9620a9c
--- /dev/null
@@ -0,0 +1,164 @@
+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 82C10415E4A\r
+       for <notmuch@notmuchmail.org>; Fri, 24 Feb 2012 14:37:47 -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 B0iQdi6cWHGp for <notmuch@notmuchmail.org>;\r
+       Fri, 24 Feb 2012 14:37:46 -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 B0649415E49\r
+       for <notmuch@notmuchmail.org>; Fri, 24 Feb 2012 14:37:46 -0800 (PST)\r
+Received: by wibhi8 with SMTP id hi8so2010781wib.26\r
+       for <notmuch@notmuchmail.org>; Fri, 24 Feb 2012 14:37:45 -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 ea2mr8787045wib.20.1330123065583\r
+       (num_hops = 1); Fri, 24 Feb 2012 14:37:45 -0800 (PST)\r
+Received: by 10.180.97.130 with SMTP id ea2mr7087381wib.20.1330123065508;\r
+       Fri, 24 Feb 2012 14:37:45 -0800 (PST)\r
+Received: from localhost ([109.131.181.26])\r
+       by mx.google.com with ESMTPS id bg3sm6293527wib.10.2012.02.24.14.37.44\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 24 Feb 2012 14:37:45 -0800 (PST)\r
+From: Pieter Praet <pieter@praet.org>\r
+To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>,\r
+       David Bremner <david@tethera.net>\r
+Subject: Re: [PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc'\r
+In-Reply-To: <87fwe0jz0y.fsf@gmail.com>\r
+References: <878vjtqhcg.fsf@praet.org>\r
+       <1330038554-10347-4-git-send-email-pieter@praet.org>\r
+       <87fwe0jz0y.fsf@gmail.com>\r
+User-Agent: Notmuch/0.11.1+210~g6afc43e (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-unknown-linux-gnu)\r
+Date: Fri, 24 Feb 2012 23:35:26 +0100\r
+Message-ID: <877gzbeu6p.fsf@praet.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Gm-Message-State:\r
+ ALoCoQk4Ikp37f5TAcI+he1a7VaRWUhEkvtpAA9c5pwCnsxKAr+cxbZ30ZbJoOs382dQBtQIU3HS\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: Fri, 24 Feb 2012 22:37:47 -0000\r
+\r
+On Fri, 24 Feb 2012 14:39:41 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:\r
+> On Fri, 24 Feb 2012 00:09:12 +0100, Pieter Praet <pieter@praet.org> wrote:\r
+> > * emacs/notmuch-show.el\r
+> > \r
+> >   (notmuch-show-mapc):\r
+> >     Only call FUNCTION if new argument PREDICATE is satisfied.\r
+> >     Also correct original docstring: 's/thread/buffer/'.\r
+> > \r
+> >   (notmuch-show-get-messages-ids):\r
+> >     Update wrt changes to `notmuch-show-mapc'.\r
+> > \r
+> >   (notmuch-show-tag-all):\r
+> >     Update wrt changes to `notmuch-show-mapc'.\r
+> > ---\r
+> >  emacs/notmuch-show.el |   15 ++++++++-------\r
+> >  1 files changed, 8 insertions(+), 7 deletions(-)\r
+> > \r
+> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> > index aa9ccee..5fc0e43 100644\r
+> > --- a/emacs/notmuch-show.el\r
+> > +++ b/emacs/notmuch-show.el\r
+> > @@ -1272,13 +1272,14 @@ (defun notmuch-show-goto-message-previous ()\r
+> >      (notmuch-show-move-to-message-top)\r
+> >      t))\r
+> >  \r
+> > -(defun notmuch-show-mapc (function)\r
+> > -  "Iterate through all messages in the current thread with\r
+> > -`notmuch-show-goto-message-next' and call FUNCTION for side\r
+> > -effects."\r
+> > +(defun notmuch-show-mapc (predicate function)\r
+> \r
+> Please make PREDICATE optional to avoid giving t when it is not needed.\r
+>\r
+\r
+Done.\r
+\r
+> I would expect PREDICATE to be a function, [...]\r
+\r
+Well, it *can* be a function actually (see later usage in e.g.\r
+`notmuch-show-get-messages-ids' [1]), but should be provided\r
+as a form instead of as a quoted symbol.\r
+\r
+> [...] but perhaps the way you\r
+> implemented it is common in Emacs.\r
+>\r
+\r
+Far from it, apparently.  I did it that way to prevent `funcall' from\r
+choking on t/nil, which -in retrospect- was rather shortsighted...\r
+\r
+I've used a more sensible approach in v2 [2].\r
+\r
+> Regards,\r
+>   Dmitry\r
+> \r
+> > +  "Iterate through all messages in the current buffer with\r
+> > +`notmuch-show-goto-message-next'.  If PREDICATE is satisfied,\r
+> > +call FUNCTION for side effects."\r
+> >    (save-excursion\r
+> >      (goto-char (point-min))\r
+> > -    (loop do (funcall function)\r
+> > +    (loop do (if (eval predicate)\r
+> > +           (funcall function))\r
+> >      while (notmuch-show-goto-message-next))))\r
+> >  \r
+> >  ;; Functions relating to the visibility of messages and their\r
+> > @@ -1336,7 +1337,7 @@ (defun notmuch-show-get-message-id ()\r
+> >  (defun notmuch-show-get-messages-ids ()\r
+> >    "Return all message ids of messages in the current thread."\r
+> >    (let ((message-ids))\r
+> > -    (notmuch-show-mapc\r
+> > +    (notmuch-show-mapc t\r
+> >       (lambda () (push (notmuch-show-get-message-id) message-ids)))\r
+> >      message-ids))\r
+> >  \r
+> > @@ -1633,7 +1634,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)\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-search) tag-changes)\r
+> > -  (notmuch-show-mapc\r
+> > +  (notmuch-show-mapc t\r
+> >     (lambda ()\r
+> >       (let* ((current-tags (notmuch-show-get-tags))\r
+> >        (new-tags (notmuch-update-tags current-tags tag-changes)))\r
+> > -- \r
+> > 1.7.8.1\r
+> > \r
+\r
+\r
+Peace\r
+\r
+-- \r
+Pieter\r
+\r
+[1] id:"1330038554-10347-6-git-send-email-pieter@praet.org"\r
+[2] id:"1330122640-18895-5-git-send-email-pieter@praet.org"\r