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 463C1431FB6 for ; Fri, 27 Jan 2012 22:00:18 -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 PlDK9Cdm2WKO for ; Fri, 27 Jan 2012 22:00:17 -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 951F4431FAE for ; Fri, 27 Jan 2012 22:00:17 -0800 (PST) Received: by bkbzt19 with SMTP id zt19so2289195bkb.26 for ; Fri, 27 Jan 2012 22:00:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=Xd7jtBqqqLhCHd8k0SN51BQ/VYr8IoXHNAu6YVKxuQw=; b=tR8vVR5GKHbOlrUQ83JzRD7PSgdASn4tqwgkNpxS5pfjVPLv7DHmU5Gja2M2UXWIGz RxKUBXHyi0ViDokKN6HgMT7QDZ9EuEOzD0XEtYctmW4nX7eqGdyxYkcVrTPTtB/JIvge PZ3Siju56aJnQy9DN37atSZ17atu3RRomMDF4= Received: by 10.205.137.4 with SMTP id im4mr4612109bkc.136.1327730416251; Fri, 27 Jan 2012 22:00:16 -0800 (PST) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id x20sm5831668bka.9.2012.01.27.22.00.15 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jan 2012 22:00:15 -0800 (PST) From: Dmitry Kurochkin To: notmuch@notmuchmail.org Subject: [PATCH 8/6] emacs: use message ids instead of thread id in `notmuch-show-operate-all' Date: Sat, 28 Jan 2012 09:59:07 +0400 Message-Id: <1327730348-6466-1-git-send-email-dmitry.kurochkin@gmail.com> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1327725684-5887-1-git-send-email-dmitry.kurochkin@gmail.com> References: <1327725684-5887-1-git-send-email-dmitry.kurochkin@gmail.com> 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 06:00:18 -0000 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