--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id D8A88431FD4\r
+ for <notmuch@notmuchmail.org>; Sat, 14 Dec 2013 15:53:42 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7] autolearn=unavailable\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id o84KGCwD1A0B for <notmuch@notmuchmail.org>;\r
+ Sat, 14 Dec 2013 15:53:42 -0800 (PST)\r
+Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com\r
+ [74.125.82.42]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 1CC9B431FD6 for <notmuch@notmuchmail.org>; Sat, 14 Dec 2013 15:53:41 -0800\r
+ (PST)\r
+Received: by mail-wg0-f42.google.com with SMTP id a1so690163wgh.5\r
+ for <notmuch@notmuchmail.org>; Sat, 14 Dec 2013 15:53:40 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=smuJTQxWBnv0YGv/R1sLG6pBmD15ssRVN5kV4V60Qo0=;\r
+ b=Y+3kg5wAeGCStTFnc7sAYDwMhDzoKv6Af11aCZHVODWPoxljEC4ve81dNV8sgtDDCH\r
+ Kti0IuIyK2PfaBc8j81mMP/rhc4buoIPo0u9Uw0xW9C0b1m9EV/MeCH5vH0fo//OOe8O\r
+ 2+gOAfgC36olOPs6R9/mLjGzN5WwewzdsJSV33beJFJrFiGCUvJlJ9zpF6JO3GEsYMaQ\r
+ cTTzHr5mHo73Nq9atjUkKYEJZDN/Fsj5lQJvx2IkNhZFaCTc9MUoujYDLs1mFhCTfvkJ\r
+ v80CL69k0OkP9e4nzgHQR7bSlZfXV0TLyZLZXt1KwB4OwD9FQ/i/o0x4rEse2XSQn65m\r
+ XHxA==\r
+X-Received: by 10.194.78.77 with SMTP id z13mr7883800wjw.27.1387065220020;\r
+ Sat, 14 Dec 2013 15:53:40 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id x4sm11197569wif.0.2013.12.14.15.53.38\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 14 Dec 2013 15:53:39 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 4/5] emacs: show: add an update seen function to\r
+ post-command-hook\r
+Date: Sat, 14 Dec 2013 23:53:16 +0000\r
+Message-Id: <1387065197-15776-5-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1387065197-15776-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1387065197-15776-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 14 Dec 2013 23:53:43 -0000\r
+\r
+Add a function stub for updating seen messages to the\r
+post-command-hook. This dummy function gets called with parameters the\r
+start and end of the current window and can decide what to mark seen\r
+based on that.\r
+\r
+Since this is in the post-command-hook it should get called after most\r
+user actions (exceptions include user resizing the window) so it\r
+should be possible to make sure the seen status gets updated whether\r
+the user uses notmuch commands like next-message or normal emacs\r
+commands like scroll-up.\r
+\r
+It also removes all of the old mark read/seen points to give a clean\r
+slate for testing new mark read/seen algorithms.\r
+---\r
+ emacs/notmuch-show.el | 32 +++++++++++++++++---------------\r
+ 1 files changed, 17 insertions(+), 15 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 30e84b1..51366e9 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1152,6 +1152,8 @@ function is used."\r
+ (let ((inhibit-read-only t))\r
+ \r
+ (notmuch-show-mode)\r
++ (add-hook 'post-command-hook #'notmuch-show-command-hook nil t)\r
++\r
+ ;; Don't track undo information for this buffer\r
+ (set 'buffer-undo-list t)\r
+ \r
+@@ -1539,6 +1541,16 @@ marked as unread, i.e. the tag changes in\r
+ (apply 'notmuch-show-tag-message\r
+ (notmuch-tag-change-list notmuch-show-mark-read-tags unread))))\r
+ \r
++(defun notmuch-show-do-seen (start end)\r
++ "Update seen status for all messages between start and end."\r
++ )\r
++\r
++(defun notmuch-show-command-hook ()\r
++ (when (eq major-mode 'notmuch-show-mode)\r
++ ;; We need to redisplay to get window-start and window-end correct.\r
++ (redisplay)\r
++ (notmuch-show-do-seen (window-start) (window-end))))\r
++\r
+ ;; Functions for getting attributes of several messages in the current\r
+ ;; thread.\r
+ \r
+@@ -1674,9 +1686,7 @@ If a prefix argument is given and this is the last message in the\r
+ thread, navigate to the next thread in the parent search buffer."\r
+ (interactive "P")\r
+ (if (notmuch-show-goto-message-next)\r
+- (progn\r
+- (notmuch-show-mark-read)\r
+- (notmuch-show-message-adjust))\r
++ (notmuch-show-message-adjust)\r
+ (if pop-at-end\r
+ (notmuch-show-next-thread)\r
+ (goto-char (point-max)))))\r
+@@ -1687,7 +1697,6 @@ thread, navigate to the next thread in the parent search buffer."\r
+ (if (= (point) (notmuch-show-message-top))\r
+ (notmuch-show-goto-message-previous)\r
+ (notmuch-show-move-to-message-top))\r
+- (notmuch-show-mark-read)\r
+ (notmuch-show-message-adjust))\r
+ \r
+ (defun notmuch-show-next-open-message (&optional pop-at-end)\r
+@@ -1702,9 +1711,7 @@ to show, nil otherwise."\r
+ (while (and (setq r (notmuch-show-goto-message-next))\r
+ (not (notmuch-show-message-visible-p))))\r
+ (if r\r
+- (progn\r
+- (notmuch-show-mark-read)\r
+- (notmuch-show-message-adjust))\r
++ (notmuch-show-message-adjust)\r
+ (if pop-at-end\r
+ (notmuch-show-next-thread)\r
+ (goto-char (point-max))))\r
+@@ -1717,9 +1724,7 @@ to show, nil otherwise."\r
+ (while (and (setq r (notmuch-show-goto-message-next))\r
+ (not (notmuch-show-get-prop :match))))\r
+ (if r\r
+- (progn\r
+- (notmuch-show-mark-read)\r
+- (notmuch-show-message-adjust))\r
++ (notmuch-show-message-adjust)\r
+ (goto-char (point-max)))))\r
+ \r
+ (defun notmuch-show-open-if-matched ()\r
+@@ -1730,8 +1735,7 @@ to show, nil otherwise."\r
+ (defun notmuch-show-goto-first-wanted-message ()\r
+ "Move to the first open message and mark it read"\r
+ (goto-char (point-min))\r
+- (if (notmuch-show-message-visible-p)\r
+- (notmuch-show-mark-read)\r
++ (unless (notmuch-show-message-visible-p)\r
+ (notmuch-show-next-open-message))\r
+ (when (eobp)\r
+ ;; There are no matched non-excluded messages so open all matched\r
+@@ -1739,8 +1743,7 @@ to show, nil otherwise."\r
+ (notmuch-show-mapc 'notmuch-show-open-if-matched)\r
+ (force-window-update)\r
+ (goto-char (point-min))\r
+- (if (notmuch-show-message-visible-p)\r
+- (notmuch-show-mark-read)\r
++ (unless (notmuch-show-message-visible-p)\r
+ (notmuch-show-next-open-message))))\r
+ \r
+ (defun notmuch-show-previous-open-message ()\r
+@@ -1750,7 +1753,6 @@ to show, nil otherwise."\r
+ (notmuch-show-goto-message-previous)\r
+ (notmuch-show-move-to-message-top))\r
+ (not (notmuch-show-message-visible-p))))\r
+- (notmuch-show-mark-read)\r
+ (notmuch-show-message-adjust))\r
+ \r
+ (defun notmuch-show-view-raw-message ()\r
+-- \r
+1.7.9.1\r
+\r