From bdee9558d93bffb97c80632f522288e059deb7c2 Mon Sep 17 00:00:00 2001 From: Matthieu Lemerre Date: Thu, 25 Feb 2010 00:24:24 +0100 Subject: [PATCH 1/2] Add and use notmuch-show-forall-in-thread macro This macro allows to apply a message-related command to every message in a thread. --- notmuch.el | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diff --git a/notmuch.el b/notmuch.el index 6482170..5d7342a 100644 --- a/notmuch.el +++ b/notmuch.el @@ -321,17 +321,22 @@ pseudoheader summary" (cons (notmuch-show-get-message-id) nil))) (notmuch-show-set-tags (sort (set-difference tags toremove :test 'string=) 'string<)))))) -(defun notmuch-show-archive-thread-maybe-mark-read (markread) - (save-excursion +(defmacro notmuch-show-forall-in-thread (&rest body) + "Executes BODY with point in all messages of the current thread." + `(save-excursion (goto-char (point-min)) (while (not (eobp)) - (if markread - (notmuch-show-remove-tag "unread" "inbox") - (notmuch-show-remove-tag "inbox")) + ,@body (if (not (eobp)) (forward-char)) (if (not (re-search-forward notmuch-show-message-begin-regexp nil t)) - (goto-char (point-max))))) + (goto-char (point-max)))))) + +(defun notmuch-show-archive-thread-maybe-mark-read (markread) + (notmuch-show-forall-in-thread + (if markread + (notmuch-show-remove-tag "unread" "inbox") + (notmuch-show-remove-tag "inbox"))) (let ((parent-buffer notmuch-show-parent-buffer)) (kill-this-buffer) (if parent-buffer -- 1.6.5