From 2b760cb0202faf7b49268746f801dd30409a0553 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 1 Dec 2013 10:02:26 +0000 Subject: [PATCH] [PATCH WIP v2 5/6] emacs: show: add an update seen function to post-command-hook --- 27/8358f45cf05ee26222044fa1342b4cc70ee273 | 183 ++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 27/8358f45cf05ee26222044fa1342b4cc70ee273 diff --git a/27/8358f45cf05ee26222044fa1342b4cc70ee273 b/27/8358f45cf05ee26222044fa1342b4cc70ee273 new file mode 100644 index 000000000..363a9fea0 --- /dev/null +++ b/27/8358f45cf05ee26222044fa1342b4cc70ee273 @@ -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 29449429E32 + for ; Sun, 1 Dec 2013 02:02:50 -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 FHuxcnuDdAZX for ; + Sun, 1 Dec 2013 02:02:44 -0800 (PST) +Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com + [74.125.82.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + C183A431FD2 for ; Sun, 1 Dec 2013 02:02:41 -0800 + (PST) +Received: by mail-wg0-f46.google.com with SMTP id m15so10578829wgh.13 + for ; Sun, 01 Dec 2013 02:02:40 -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=T2CsFhKMbzND2D2Jxy47eE579SGuRMtdY5UlGtV1iNg=; + b=idbTZzDSeAayKrNkfYgQKmQJPke9C+0yWIzYxgKw2VVzWufY4UFWQISsBOzjaJ50X9 + 9jIUw9apkZi+wB9ghFvo3mgNhJooHhZ7dTl8MU8cxquY3HBW5lq148fs8/GfxJrtXPzy + sS2Jgv2b1/QNCrTqAxuECV1XH4JRtjtIVFGc8HbdQg9BKH1gu6wRNs+URIuf5vA+S70C + LLbyzBKgsCFJbS9pTYlzMdHdYwkoWK3RihKsN2XvcDXpdp0fsMrg4WYIXUsyFX/V/o6q + y2OsyTcdGcWPgXzYbdhVA98GIgvfO+vInlbihS0/8nMQIbgJloCu+XmY1y9wuVPDExQp + JvPQ== +X-Received: by 10.181.11.169 with SMTP id ej9mr13641352wid.13.1385892160769; + Sun, 01 Dec 2013 02:02:40 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id y20sm10196102wib.0.2013.12.01.02.02.39 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 01 Dec 2013 02:02:40 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH WIP v2 5/6] emacs: show: add an update seen function to + post-command-hook +Date: Sun, 1 Dec 2013 10:02:26 +0000 +Message-Id: <1385892147-16994-6-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:02:50 -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 261c2e3..6b6e94a 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1142,6 +1142,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) + +@@ -1585,6 +1587,16 @@ we are not marking them." + (notmuch-show-mark-all-seen-read not-mark) + (notmuch-kill-this-buffer)) + ++(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. + +@@ -1720,9 +1732,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-seen) +- (notmuch-show-message-adjust)) ++ (notmuch-show-message-adjust) + (if pop-at-end + (notmuch-show-next-thread) + (goto-char (point-max))))) +@@ -1733,7 +1743,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-seen) + (notmuch-show-message-adjust)) + + (defun notmuch-show-next-open-message (&optional pop-at-end) +@@ -1748,9 +1757,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-seen) +- (notmuch-show-message-adjust)) ++ (notmuch-show-message-adjust) + (if pop-at-end + (notmuch-show-next-thread) + (goto-char (point-max)))) +@@ -1763,9 +1770,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-seen) +- (notmuch-show-message-adjust)) ++ (notmuch-show-message-adjust) + (goto-char (point-max))))) + + (defun notmuch-show-open-if-matched () +@@ -1776,8 +1781,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-seen) ++ (unless (notmuch-show-message-visible-p) + (notmuch-show-next-open-message)) + (when (eobp) + ;; There are no matched non-excluded messages so open all matched +@@ -1785,8 +1789,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-seen) ++ (unless (notmuch-show-message-visible-p) + (notmuch-show-next-open-message)))) + + (defun notmuch-show-previous-open-message () +@@ -1796,7 +1799,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-seen) + (notmuch-show-message-adjust)) + + (defun notmuch-show-view-raw-message () +-- +1.7.9.1 + -- 2.26.2