From: Mark Walters Date: Tue, 10 Dec 2013 08:57:26 +0000 (+0000) Subject: [PATCH WIP v4 2/3] emacs: show: add an update seen function to post-command-hook X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2adab37cac26a0e6e96d4a5e8f76c3bfc249ee64;p=notmuch-archives.git [PATCH WIP v4 2/3] emacs: show: add an update seen function to post-command-hook --- diff --git a/a8/94a18864ddf0784a142383c0ba782b2f7b46fe b/a8/94a18864ddf0784a142383c0ba782b2f7b46fe new file mode 100644 index 000000000..2ee748ef9 --- /dev/null +++ b/a8/94a18864ddf0784a142383c0ba782b2f7b46fe @@ -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 4AA90431FBC + for ; Tue, 10 Dec 2013 00:57:46 -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 AgGYjZ240ZS3 for ; + Tue, 10 Dec 2013 00:57:40 -0800 (PST) +Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com + [209.85.212.177]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 890DE431FBD + for ; Tue, 10 Dec 2013 00:57:36 -0800 (PST) +Received: by mail-wi0-f177.google.com with SMTP id cc10so4961723wib.16 + for ; Tue, 10 Dec 2013 00:57:35 -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=smuJTQxWBnv0YGv/R1sLG6pBmD15ssRVN5kV4V60Qo0=; + b=IbyXWGU2ZqZ/mlSz9Cuc2U6pzZJw61KhGPStzt9BqRbZ1+b+3yg4WxXOgrYdoWJG7D + JqsYbbwMcgXaHLI7J8m/NtHuvSJHBETpMSKMU+5eV3OSIUkFgC3aEb5/pVP2D0rviz2C + sDd3CC8ylrrJxfE7iNdlq8qgkRvUmexzIDDmWOD/Jbw41LHwDNTFQ/1Jl9ylM47H8bwv + DCYAN5x2kzAmXxQUmdJWdFe/RBZu1ADU8+QfcLuygteh8vSnG28Z9wEMQ6YpXh+50oaw + UJ3vtMLqjsoBQqkn/t0DXbUyzzLJMNkwENfz/IBrNyuaIi7gdrFszKFXRzU8VA1w7tw+ + ESKw== +X-Received: by 10.194.240.197 with SMTP id wc5mr19282528wjc.23.1386665855472; + Tue, 10 Dec 2013 00:57:35 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id x19sm3200572wia.5.2013.12.10.00.57.34 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Tue, 10 Dec 2013 00:57:34 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH WIP v4 2/3] emacs: show: add an update seen function to + post-command-hook +Date: Tue, 10 Dec 2013 08:57:26 +0000 +Message-Id: <1386665847-6439-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1386665847-6439-1-git-send-email-markwalters1009@gmail.com> +References: <1386665847-6439-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, 10 Dec 2013 08:57:46 -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 files changed, 17 insertions(+), 15 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 30e84b1..51366e9 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1152,6 +1152,8 @@ function is used." + (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) + +@@ -1539,6 +1541,16 @@ 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-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. + +@@ -1674,9 +1686,7 @@ If a prefix argument is given and this is the last message in the + 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))))) +@@ -1687,7 +1697,6 @@ thread, navigate to the next thread in the parent search buffer." + (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) +@@ -1702,9 +1711,7 @@ to show, nil otherwise." + (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)))) +@@ -1717,9 +1724,7 @@ to show, nil otherwise." + (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 () +@@ -1730,8 +1735,7 @@ to show, nil otherwise." + (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 +@@ -1739,8 +1743,7 @@ to show, nil otherwise." + (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 () +@@ -1750,7 +1753,6 @@ to show, nil otherwise." + (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.9.1 +