From 9a29ef77d3e1117e70fc58217b15f027843764fe Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 1 Dec 2013 10:02:23 +0000 Subject: [PATCH] [PATCH WIP v2 2/6] emacs: show: add some seen helpers --- 9c/892a430d6ba93c7a58dfb36480f37c5c01c526 | 128 ++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 9c/892a430d6ba93c7a58dfb36480f37c5c01c526 diff --git a/9c/892a430d6ba93c7a58dfb36480f37c5c01c526 b/9c/892a430d6ba93c7a58dfb36480f37c5c01c526 new file mode 100644 index 000000000..1a9c1f077 --- /dev/null +++ b/9c/892a430d6ba93c7a58dfb36480f37c5c01c526 @@ -0,0 +1,128 @@ +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 7A689431FD0 + for ; Sun, 1 Dec 2013 02:08:32 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=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 3ScLmYa9ZR3w for ; + Sun, 1 Dec 2013 02:08:27 -0800 (PST) +Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com + [74.125.82.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + D09C7431FD2 for ; Sun, 1 Dec 2013 02:08:26 -0800 + (PST) +Received: by mail-wg0-f44.google.com with SMTP id a1so8742474wgh.11 + for ; Sun, 01 Dec 2013 02:08:25 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=K3wprTwWhykGUau4nn5vyDf2jfHbu0RJjdMUWSUxTko=; + b=QNqqmZKpe7kcak/JPOR7MKVW6lvdgBmXHz/ppLp31APlqDcEHq6r4R684aLa405XzS + 4W0sJUIjl8idLk6FtQeg6sdpvVtHJqbYzQB1mu8iq66Pg7dJ4WqFhaRywz1eqf0mf6po + ke6iV7RLdB4cCyVJV+TUdxnuVE/XdLlR7faz8zD5jFSPXL3aDZ6RNQeH7NQBfUx3IdkZ + fJOkOb1buIIRvuETTxAiSeLSIHH2hhqGuMr3IHsKC4HFR9SgcYhIQjZo8NuaxBRFJJky + IqMl0Ze1pmNrs0/ZuWAg85hzWCKYI4MuHYgQed3wn6QxDg7MYj/ETp+qPf/am/nrRWoX + PL8g== +X-Received: by 10.194.78.141 with SMTP id b13mr31650481wjx.32.1385892154498; + Sun, 01 Dec 2013 02:02:34 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id + x19sm110885362wia.5.2013.12.01.02.02.33 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 01 Dec 2013 02:02:33 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH WIP v2 2/6] emacs: show: add some seen helpers +Date: Sun, 1 Dec 2013 10:02:23 +0000 +Message-Id: <1385892147-16994-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1385892147-16994-1-git-send-email-markwalters1009@gmail.com> +References: <1385892147-16994-1-git-send-email-markwalters1009@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: Sun, 01 Dec 2013 10:08:32 -0000 + +We separate out "seeing" a message from marking it read. The intention +is only to mark read at certain times (eg quitting a show buffer). We +use the term seen to mean we have seen the message (for some +definition of seen) in the current buffer, but have not (typically) +marked the message read yet. + +This adds helper functions to test/set the seen property and a +function to tag all seen messages read. The last of these tells the +user how many messages have been marked read. It also takes an +argument that tells the function not to do any marking. This last use +case displays a messages saying "Not marking messages read" and keeps +the logic of what to do when the user does not want to sync seen to +read in one place. +--- + emacs/notmuch-show.el | 34 ++++++++++++++++++++++++++++++++++ + 1 files changed, 34 insertions(+), 0 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index a135e79..c63d295 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1536,6 +1536,40 @@ marked as unread, i.e. the tag changes in + (apply 'notmuch-show-tag-message + (notmuch-tag-change-list notmuch-show-mark-read-tags unread)))) + ++(defun notmuch-show-seen-p () ++ "Return t if current message has been seen." ++ (notmuch-show-get-prop :seen)) ++ ++(defun notmuch-show-mark-seen () ++ "Mark current message seen." ++ (notmuch-show-set-prop :seen t)) ++ ++(defun notmuch-show-mark-all-seen-read (&optional not-mark) ++ "Mark read all messages that have been seen in this buffer. ++ ++If NOT-MARK then do not mark the messages read, and tell the user ++we are not marking them." ++ (if not-mark ++ (message "Not marking messages read") ++ (let ((messages-to-mark-read)) ++ ;; We get a list of all message to tag read. A list means that ++ ;; we can tag all the messages in one tag operation rather than ++ ;; needing one per read message. ++ (notmuch-show-mapc ++ (lambda () ++ (when (and (notmuch-show-seen-p) (notmuch-show-unread-p)) ++ (push (notmuch-show-get-message-id) messages-to-mark-read)))) ++ (when messages-to-mark-read ++ (notmuch-tag (mapconcat #'identity messages-to-mark-read " ") ++ (notmuch-tag-change-list notmuch-show-mark-read-tags))) ++ (let ((count (length messages-to-mark-read))) ++ (cond ((> count 1) ++ (message "Marked %s messages read" count)) ++ ((= count 1) ++ (message "Marked one message read")) ++ ((= count 0) ++ (message "No messages marked read"))))))) ++ + ;; Functions for getting attributes of several messages in the current + ;; thread. + +-- +1.7.9.1 + -- 2.26.2