From: Jani Nikula Date: Sat, 28 Jan 2012 09:09:45 +0000 (+0200) Subject: Re: [PATCH 8/6] emacs: use message ids instead of thread id in `notmuch-show-operate... X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=4ec05d114c33d88f87fba421b882ae034ad5ea59;p=notmuch-archives.git Re: [PATCH 8/6] emacs: use message ids instead of thread id in `notmuch-show-operate-all' --- diff --git a/b6/4cf9846666ff6bc9edf46233897946b1c3f2ba b/b6/4cf9846666ff6bc9edf46233897946b1c3f2ba new file mode 100644 index 000000000..7305bf623 --- /dev/null +++ b/b6/4cf9846666ff6bc9edf46233897946b1c3f2ba @@ -0,0 +1,242 @@ +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 33771431FB6 + for ; Sat, 28 Jan 2012 01:09:49 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.699 +X-Spam-Level: +X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 + tests=[HTML_MESSAGE=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 KnLglAAz3Pps for ; + Sat, 28 Jan 2012 01:09:48 -0800 (PST) +Received: from mail-pw0-f53.google.com (mail-pw0-f53.google.com + [209.85.160.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 371BC431FAE + for ; Sat, 28 Jan 2012 01:09:48 -0800 (PST) +Received: by pbbb4 with SMTP id b4so3083846pbb.26 + for ; Sat, 28 Jan 2012 01:09:47 -0800 (PST) +MIME-Version: 1.0 +Received: by 10.68.189.6 with SMTP id ge6mr21709820pbc.93.1327741785529; Sat, + 28 Jan 2012 01:09:45 -0800 (PST) +Received: by 10.68.236.137 with HTTP; Sat, 28 Jan 2012 01:09:45 -0800 (PST) +Received: by 10.68.236.137 with HTTP; Sat, 28 Jan 2012 01:09:45 -0800 (PST) +In-Reply-To: <1327730348-6466-1-git-send-email-dmitry.kurochkin@gmail.com> +References: <1327725684-5887-1-git-send-email-dmitry.kurochkin@gmail.com> + <1327730348-6466-1-git-send-email-dmitry.kurochkin@gmail.com> +Date: Sat, 28 Jan 2012 11:09:45 +0200 +Message-ID: + +Subject: Re: [PATCH 8/6] emacs: use message ids instead of thread id in + `notmuch-show-operate-all' +From: Jani Nikula +To: Dmitry Kurochkin +Content-Type: multipart/alternative; boundary=e89a8ff1c3e87ade2104b792f9ce +Cc: notmuch@notmuchmail.org +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: Sat, 28 Jan 2012 09:09:49 -0000 + +--e89a8ff1c3e87ade2104b792f9ce +Content-Type: text/plain; charset=UTF-8 + +I guess this now includes the optimization of doing the tagging in a single +call to notmuch tag. (As opposed to calling it once per msg like it used to +be a while back.) There was some discussion about the cmdline length for +large threads potentially growing too big when I sent such an optimization +patch, shall we just ignore that and hope for the best? I guess an idea was +to limit to, say, a few hundred msg ids per command. (Again, sorry I can't +look up the earlier thread now.) + +On Jan 28, 2012 8:00 AM, "Dmitry Kurochkin" +wrote: +> +> Before the change, `notmuch-show-operate-all' used thread id for +> "notmuch tag" search. This could result in tagging unexpected +> messages that were added to the thread after the notmuch-show buffer +> was created. The patch changes `notmuch-show-operate-all' to use ids +> of shown messages to fix this. +> --- +> emacs/notmuch-show.el | 23 ++++++++++++++++++++++- +> 1 files changed, 22 insertions(+), 1 deletions(-) +> +> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +> index 2ca4d92..e606224 100644 +> --- a/emacs/notmuch-show.el +> +++ b/emacs/notmuch-show.el +> @@ -1170,6 +1170,15 @@ All currently available key bindings: +> (notmuch-show-move-to-message-top) +> t)) +> +> +(defun notmuch-show-mapc (function) +> + "Iterate through all messages with +> +`notmuch-show-goto-message-next' and call `function' for side +> +effects." +> + (save-excursion +> + (goto-char (point-min)) +> + (loop do (funcall function) +> + while (notmuch-show-goto-message-next)))) +> + +> ;; Functions relating to the visibility of messages and their +> ;; components. +> +> @@ -1222,6 +1231,18 @@ Some useful entries are: +> "Return the message id of the current message." +> (concat "id:\"" (notmuch-show-get-prop :id) "\"")) +> +> +(defun notmuch-show-get-messages-ids () +> + "Return all message ids of currently shown messages." +> + (let ((message-ids)) +> + (notmuch-show-mapc +> + (lambda () (push (notmuch-show-get-message-id) message-ids))) +> + message-ids)) +> + +> +(defun notmuch-show-get-messages-ids-search () +> + "Return a search string for all message ids of currently shown +> +messages." +> + (mapconcat 'identity (notmuch-show-get-messages-ids) " or ")) +> + +> ;; dme: Would it make sense to use a macro for many of these? +> +> (defun notmuch-show-get-filename () +> @@ -1496,7 +1517,7 @@ i.e. a list of tags to change with '+' and '-' +prefixes." +> `Changed-tags' is a list of tag operations for \"notmuch tag\", +> i.e. a list of tags to change with '+' and '-' prefixes." +> (interactive (notmuch-select-tags-with-completion nil +notmuch-show-thread-id)) +> - (apply 'notmuch-tag notmuch-show-thread-id changed-tags) +> + (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) +changed-tags) +> (save-excursion +> (goto-char (point-min)) +> (loop do (let* ((current-tags (notmuch-show-get-tags)) +> -- +> 1.7.8.3 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch + +--e89a8ff1c3e87ade2104b792f9ce +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +


+I guess this now includes the optimization of doing the tagging in a single= + call to notmuch tag. (As opposed to calling it once per msg like it used t= +o be a while back.) There was some discussion about the cmdline length for = +large threads potentially growing too big when I sent such an optimization = +patch, shall we just ignore that and hope for the best? I guess an idea was= + to limit to, say, a few hundred msg ids per command. (Again, sorry I can&#= +39;t look up the earlier thread now.)

+ +

On Jan 28, 2012 8:00 AM, "Dmitry Kurochkin" <dmitry.kurochkin@gmail.com> wrote: +>
+> Before the change, `notmuch-show-operate-all' used thread id for +> "notmuch tag" search. =C2=A0This could result in tagging une= +xpected
+> messages that were added to the thread after the notmuch-show buffer +> was created. =C2=A0The patch changes `notmuch-show-operate-all' to= + use ids
+> of shown messages to fix this.
+> ---
+> =C2=A0emacs/notmuch-show.el | =C2=A0 23 ++++++++++++++++++++++-
+> =C2=A01 files changed, 22 insertions(+), 1 deletions(-)
+>
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
+> index 2ca4d92..e606224 100644
+> --- a/emacs/notmuch-show.el
+> +++ b/emacs/notmuch-show.el
+> @@ -1170,6 +1170,15 @@ All currently available key bindings:
+> =C2=A0 =C2=A0 (notmuch-show-move-to-message-top)
+> =C2=A0 =C2=A0 t))
+>
+> +(defun notmuch-show-mapc (function)
+> + =C2=A0"Iterate through all messages with
+> +`notmuch-show-goto-message-next' and call `function' for side= +
+> +effects."
+> + =C2=A0(save-excursion
+> + =C2=A0 =C2=A0(goto-char (point-min))
+> + =C2=A0 =C2=A0(loop do (funcall function)
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 while (notmuch-show-goto-message-next)))= +)
+> +
+> =C2=A0;; Functions relating to the visibility of messages and their +> =C2=A0;; components.
+>
+> @@ -1222,6 +1231,18 @@ Some useful entries are:
+> =C2=A0 "Return the message id of the current message."
+> =C2=A0 (concat "id:\"" (notmuch-show-get-prop :id) &quo= +t;\""))
+>
+> +(defun notmuch-show-get-messages-ids ()
+> + =C2=A0"Return all message ids of currently shown messages."= +;
+> + =C2=A0(let ((message-ids))
+> + =C2=A0 =C2=A0(notmuch-show-mapc
+> + =C2=A0 =C2=A0 (lambda () (push (notmuch-show-get-message-id) message= +-ids)))
+> + =C2=A0 =C2=A0message-ids))
+> +
+> +(defun notmuch-show-get-messages-ids-search ()
+> + =C2=A0"Return a search string for all message ids of currently = +shown
+> +messages."
+> + =C2=A0(mapconcat 'identity (notmuch-show-get-messages-ids) "= +; or "))
+> +
+> =C2=A0;; dme: Would it make sense to use a macro for many of these? +>
+> =C2=A0(defun notmuch-show-get-filename ()
+> @@ -1496,7 +1517,7 @@ i.e. a list of tags to change with '+' a= +nd '-' prefixes."
+> =C2=A0`Changed-tags' is a list of tag operations for \"notmuc= +h tag\",
+> =C2=A0i.e. a list of tags to change with '+' and '-' p= +refixes."
+> =C2=A0 (interactive (notmuch-select-tags-with-completion nil notmuch-s= +how-thread-id))
+> - =C2=A0(apply 'notmuch-tag notmuch-show-thread-id changed-tags) +> + =C2=A0(apply 'notmuch-tag (notmuch-show-get-messages-ids-search)= + changed-tags)
+> =C2=A0 (save-excursion
+> =C2=A0 =C2=A0 (goto-char (point-min))
+> =C2=A0 =C2=A0 (loop do (let* ((current-tags (notmuch-show-get-tags)) +> --
+> 1.7.8.3
+>
+> _______________________________________________
+> notmuch mailing list
+> notmuch@notmuchmail.org= +
+> http://not= +muchmail.org/mailman/listinfo/notmuch
+

+ +--e89a8ff1c3e87ade2104b792f9ce--