From c792e998edca803d35990e8afc7b39f53f099ddf Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Tue, 25 Mar 2014 20:03:12 +0000 Subject: [PATCH] [Patch v3 2/3] emacs: show: add an update seen function to post-command-hook --- be/422985529385e9d9cb9bea894958ec27b3d7ab | 183 ++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 be/422985529385e9d9cb9bea894958ec27b3d7ab diff --git a/be/422985529385e9d9cb9bea894958ec27b3d7ab b/be/422985529385e9d9cb9bea894958ec27b3d7ab new file mode 100644 index 000000000..7c2d54565 --- /dev/null +++ b/be/422985529385e9d9cb9bea894958ec27b3d7ab @@ -0,0 +1,183 @@ +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 A6779431FC2 + for ; Tue, 25 Mar 2014 13:03:28 -0700 (PDT) +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 cU-0-K6hVBZ9 for ; + Tue, 25 Mar 2014 13:03:24 -0700 (PDT) +Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com + [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 16510431FBF + for ; Tue, 25 Mar 2014 13:03:23 -0700 (PDT) +Received: by mail-wi0-f174.google.com with SMTP id d1so3857556wiv.7 + for ; Tue, 25 Mar 2014 13:03:21 -0700 (PDT) +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=VfC8O5Tu9ay8+KisWsKw5K35igXFtj7AkCqwgM3Qukg=; + b=tRRG7fEXFXJPkpZbLK1PojYd5btonx/h1DpKSCHrHO9MHeUF+3BdQyycvVQvifTYey + weY8j839T6tpQAZBGCjpoRiBXj33ssMP9HQioqcg7FHOxCaFOoI95WD282/3CTxzPjzN + ievrrnaUpIkT53LnxMWl0O9ddV/Uic1dILxtaO3cjK+HBqqRlBhFfDjhcGgY0wR0MPga + xqW0DvEKvass48pqWB260ogNWtyRv/YJR4V2aw9loRjFOiASyqzJjsaay9OmzowMegWb + c24I3mM3TwBw0tP/UDykKot4YbfsurFGiE3AbI7ZaWc/u5CAeDjZvmQx75w/xVlhWpt2 + vHBA== +X-Received: by 10.180.73.1 with SMTP id h1mr26530880wiv.10.1395777801551; + Tue, 25 Mar 2014 13:03:21 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id dd5sm984894wib.12.2014.03.25.13.03.20 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Tue, 25 Mar 2014 13:03:20 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [Patch v3 2/3] emacs: show: add an update seen function to + post-command-hook +Date: Tue, 25 Mar 2014 20:03:12 +0000 +Message-Id: <1395777793-13297-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1395777793-13297-1-git-send-email-markwalters1009@gmail.com> +References: <1395777793-13297-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: Tue, 25 Mar 2014 20:03:28 -0000 + +Add a function stub for updating seen messages to the +post-command-hook. This dummy function gets called with parameters the +start and end of the current window and can decide what to mark seen +based on that. + +Since this is in the post-command-hook it should get called after most +user actions (exceptions include user resizing the window) so it +should be possible to make sure the seen status gets updated whether +the user uses notmuch commands like next-message or normal emacs +commands like scroll-up. + +It also removes all of the old mark read/seen points to give a clean +slate for testing new mark read/seen algorithms. +--- + emacs/notmuch-show.el | 32 +++++++++++++++++--------------- + 1 file changed, 17 insertions(+), 15 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index f6ca827..1a7de85 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1142,6 +1142,8 @@ (defun notmuch-show-build-buffer () + (let ((inhibit-read-only t)) + + (notmuch-show-mode) ++ (add-hook 'post-command-hook #'notmuch-show-command-hook nil t) ++ + ;; Don't track undo information for this buffer + (set 'buffer-undo-list t) + +@@ -1530,6 +1532,16 @@ (defun notmuch-show-mark-read (&optional unread) + (apply 'notmuch-show-tag-message + (notmuch-tag-change-list notmuch-show-mark-read-tags unread)))) + ++(defun notmuch-show-do-seen (start end) ++ "Update seen status for all messages between start and end." ++ ) ++ ++(defun notmuch-show-command-hook () ++ (when (eq major-mode 'notmuch-show-mode) ++ ;; We need to redisplay to get window-start and window-end correct. ++ (redisplay) ++ (notmuch-show-do-seen (window-start) (window-end)))) ++ + ;; Functions for getting attributes of several messages in the current + ;; thread. + +@@ -1665,9 +1677,7 @@ (defun notmuch-show-next-message (&optional pop-at-end) + thread, navigate to the next thread in the parent search buffer." + (interactive "P") + (if (notmuch-show-goto-message-next) +- (progn +- (notmuch-show-mark-read) +- (notmuch-show-message-adjust)) ++ (notmuch-show-message-adjust) + (if pop-at-end + (notmuch-show-next-thread) + (goto-char (point-max))))) +@@ -1678,7 +1688,6 @@ (defun notmuch-show-previous-message () + (if (= (point) (notmuch-show-message-top)) + (notmuch-show-goto-message-previous) + (notmuch-show-move-to-message-top)) +- (notmuch-show-mark-read) + (notmuch-show-message-adjust)) + + (defun notmuch-show-next-open-message (&optional pop-at-end) +@@ -1693,9 +1702,7 @@ (defun notmuch-show-next-open-message (&optional pop-at-end) + (while (and (setq r (notmuch-show-goto-message-next)) + (not (notmuch-show-message-visible-p)))) + (if r +- (progn +- (notmuch-show-mark-read) +- (notmuch-show-message-adjust)) ++ (notmuch-show-message-adjust) + (if pop-at-end + (notmuch-show-next-thread) + (goto-char (point-max)))) +@@ -1708,9 +1715,7 @@ (defun notmuch-show-next-matching-message () + (while (and (setq r (notmuch-show-goto-message-next)) + (not (notmuch-show-get-prop :match)))) + (if r +- (progn +- (notmuch-show-mark-read) +- (notmuch-show-message-adjust)) ++ (notmuch-show-message-adjust) + (goto-char (point-max))))) + + (defun notmuch-show-open-if-matched () +@@ -1721,8 +1726,7 @@ (defun notmuch-show-open-if-matched () + (defun notmuch-show-goto-first-wanted-message () + "Move to the first open message and mark it read" + (goto-char (point-min)) +- (if (notmuch-show-message-visible-p) +- (notmuch-show-mark-read) ++ (unless (notmuch-show-message-visible-p) + (notmuch-show-next-open-message)) + (when (eobp) + ;; There are no matched non-excluded messages so open all matched +@@ -1730,8 +1734,7 @@ (defun notmuch-show-goto-first-wanted-message () + (notmuch-show-mapc 'notmuch-show-open-if-matched) + (force-window-update) + (goto-char (point-min)) +- (if (notmuch-show-message-visible-p) +- (notmuch-show-mark-read) ++ (unless (notmuch-show-message-visible-p) + (notmuch-show-next-open-message)))) + + (defun notmuch-show-previous-open-message () +@@ -1741,7 +1744,6 @@ (defun notmuch-show-previous-open-message () + (notmuch-show-goto-message-previous) + (notmuch-show-move-to-message-top)) + (not (notmuch-show-message-visible-p)))) +- (notmuch-show-mark-read) + (notmuch-show-message-adjust)) + + (defun notmuch-show-view-raw-message () +-- +1.7.10.4 + -- 2.26.2