1 Return-Path: <markwalters1009@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id A6A80431FC9
\r
6 for <notmuch@notmuchmail.org>; Sat, 6 Sep 2014 09:22:29 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id aS7uEH18ZMXQ for <notmuch@notmuchmail.org>;
\r
18 Sat, 6 Sep 2014 09:22:24 -0700 (PDT)
\r
19 Received: from mail-we0-f179.google.com (mail-we0-f179.google.com
\r
20 [74.125.82.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id 74CE9431FBD
\r
23 for <notmuch@notmuchmail.org>; Sat, 6 Sep 2014 09:22:19 -0700 (PDT)
\r
24 Received: by mail-we0-f179.google.com with SMTP id t60so13004364wes.38
\r
25 for <notmuch@notmuchmail.org>; Sat, 06 Sep 2014 09:22:18 -0700 (PDT)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:in-reply-to:references;
\r
28 bh=KjyWvD6uthdBToASOkGKWvGoe4QzlekxHceLBhw5fUk=;
\r
29 b=dKjq2dpM0nnBlNl1G1Opv4Ki6upsA8OPg6nKLgMQz49kPHUBd5xRtKD4JtgH1XAZTV
\r
30 rVtiFM+EK2c+wFUuaQp7sQp5u4cwVH2ezL3EHf+AXx8skRZVtvkUOAGmoRLU+w7X8pv/
\r
31 wiiEnSAbaCne9xSlIQyqYFSB05SXaQuNkfrRGlZY3UPXLV2uBhnny1oPEGO2+fr1y2Eq
\r
32 x+vExw8ohAnbZs/oSQ34c/K4+gzNkrNKZXYCZtQNGtPFOhJDhk4R/nUo/BpEoldZj6j8
\r
33 dgrj7do18+IuhE0hzB410N7tYdZZ6FvifLc29CUtj0Hg4Nv5zICkjaKv8U5bwXETxO6R
\r
35 X-Received: by 10.194.58.244 with SMTP id u20mr22729067wjq.36.1410020538330;
\r
36 Sat, 06 Sep 2014 09:22:18 -0700 (PDT)
\r
37 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])
\r
38 by mx.google.com with ESMTPSA id h6sm4976836wjb.33.2014.09.06.09.22.17
\r
39 for <multiple recipients>
\r
40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
41 Sat, 06 Sep 2014 09:22:17 -0700 (PDT)
\r
42 From: Mark Walters <markwalters1009@gmail.com>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [Patch v2 2/2] emacs: show: mark messages unread if seen in buffer
\r
45 Date: Sat, 6 Sep 2014 17:22:11 +0100
\r
46 Message-Id: <1410020531-24419-3-git-send-email-markwalters1009@gmail.com>
\r
47 X-Mailer: git-send-email 1.7.10.4
\r
48 In-Reply-To: <1410020531-24419-1-git-send-email-markwalters1009@gmail.com>
\r
49 References: <1410020531-24419-1-git-send-email-markwalters1009@gmail.com>
\r
50 X-BeenThere: notmuch@notmuchmail.org
\r
51 X-Mailman-Version: 2.1.13
\r
53 List-Id: "Use and development of the notmuch mail system."
\r
54 <notmuch.notmuchmail.org>
\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
58 List-Post: <mailto:notmuch@notmuchmail.org>
\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
62 X-List-Received-Date: Sat, 06 Sep 2014 16:22:29 -0000
\r
64 This adds a function that marks messages unread if they are "seen"
\r
65 that is a user configurable amount of them has been visible in the
\r
68 emacs/notmuch-show.el | 74 ++++++++++++++++++++++++++++++++++++++++++++++++-
\r
69 1 file changed, 73 insertions(+), 1 deletion(-)
\r
71 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
72 index 5695d95..7d2c5d2 100644
\r
73 --- a/emacs/notmuch-show.el
\r
74 +++ b/emacs/notmuch-show.el
\r
75 @@ -231,7 +231,27 @@ be the start and end of the visible portion of the buffer and
\r
76 should mark the appropriate messages read by applying
\r
77 `notmuch-show-mark-read'. This function will be called after
\r
78 every user interaction with notmuch."
\r
80 + :type '(radio (const :format "%h" :doc "Mark current message read.
\r
82 +Marks the message containing point read."
\r
83 + notmuch-show-seen-current-message)
\r
84 + (group :format "%v"
\r
85 + (const :inline t :format "" (lambda (start end)))
\r
86 + (list :format "%h %v\n"
\r
87 + :doc "Mark read if enough of the message has been visible.
\r
89 +A message is marked read if both the top of the message and a
\r
90 +point far \"enough\" down in the message have each been visible
\r
91 +in the buffer at some point. The definition of enough is
\r
92 +controlled by the following paramater. Seeing the bottom of message is
\r
93 +always deemed enough. Additionally, it is deemed enough if a
\r
94 +point n lines into the message has been visible in the window
\r
95 +where n is this variable if this variable is an integer and n is
\r
96 +this variable times the height of the window if this variable is
\r
98 + (const :inline t :tag "" :format "" (notmuch-show-do-seen start end))
\r
99 + (number :tag "Proportion needed" 0.75)))
\r
101 :group 'notmuch-show)
\r
103 (defmacro with-current-notmuch-show-message (&rest body)
\r
104 @@ -1576,6 +1596,58 @@ marked as unread, i.e. the tag changes in
\r
105 (apply 'notmuch-show-tag-message
\r
106 (notmuch-tag-change-list notmuch-show-mark-read-tags unread))))
\r
108 +(defun notmuch-show-update-seen (top-or-bottom)
\r
109 + "Update seen status of current message
\r
111 +Mark that we have seen the TOP-OR-BOTTOM of current message."
\r
112 + (let ((current (notmuch-show-get-prop :seen)))
\r
113 + (unless (or (eq current 'both) (eq current top-or-bottom))
\r
114 + (if (not current)
\r
115 + (notmuch-show-set-prop :seen top-or-bottom)
\r
116 + (notmuch-show-set-prop :seen 'both)
\r
117 + (notmuch-show-mark-read)))))
\r
119 +(defun notmuch-show-do-message-seen (needed start end)
\r
120 + "Update seen status for the current message.
\r
122 +A message is seen if both the top and enough of the rest of the
\r
123 +message have been visible in the buffer. Enough means either the
\r
124 +bottom of the message or a point in the message more than
\r
125 +LINES-NEEDED lines into the message. LINES-NEEDED is
\r
126 +NEEDED if NEEDED is an integer and NEEDED
\r
127 +times the current window height if NEEDED is a float."
\r
128 + (let* ((lines-needed (if (integerp needed)
\r
130 + (truncate (* needed (window-body-height)))))
\r
131 + (top (notmuch-show-message-top))
\r
132 + (bottom (notmuch-show-message-bottom)))
\r
133 + (when (notmuch-show-message-visible-p)
\r
134 + (when (>= top start)
\r
135 + (notmuch-show-update-seen 'top))
\r
136 + (when (or (<= bottom end)
\r
137 + (> (count-screen-lines top end) lines-needed))
\r
138 + (notmuch-show-update-seen 'bottom)))))
\r
140 +(defun notmuch-show-do-seen (start end needed)
\r
141 + "Update seen status for all messages between start and end.
\r
143 +We mark the top (bottom) of a message seen if the top (enough of
\r
144 +the rest of the message) respectively have been visible in the
\r
145 +buffer. See `notmuch-show-do-message-seen` for the definition of
\r
146 +enough. When both the top and bottom have been seen we mark the
\r
149 + (goto-char start)
\r
150 + (notmuch-show-do-message-seen needed start end)
\r
151 + (while (and (< (notmuch-show-message-bottom) end)
\r
152 + (notmuch-show-goto-message-next))
\r
153 + (notmuch-show-do-message-seen needed start end))
\r
154 + ;; This is a work around because emacs gives weird answers for
\r
155 + ;; window-end if the buffer ends with invisible text.
\r
156 + (when (and (pos-visible-in-window-p (point-max))
\r
157 + (notmuch-show-message-visible-p))
\r
158 + (notmuch-show-update-seen 'bottom))))
\r
160 (defun notmuch-show-seen-current-message (start end)
\r
161 "Mark the current message read if it is open.
\r