Re: [Gaudenz Steinlin] Bug#810784: should match email adress case insensitive when...
[notmuch-archives.git] / cc / 6236bbe74f2355b61384fa6bd87afd3ad61f8b
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 192A3431FBF\r
6         for <notmuch@notmuchmail.org>; Thu,  8 May 2014 17:20:28 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \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 D2Fo8i94+dD7 for <notmuch@notmuchmail.org>;\r
18         Thu,  8 May 2014 17:20:24 -0700 (PDT)\r
19 Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com\r
20         [209.85.212.169]) (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 0A03B431FC0\r
23         for <notmuch@notmuchmail.org>; Thu,  8 May 2014 17:20:23 -0700 (PDT)\r
24 Received: by mail-wi0-f169.google.com with SMTP id hi2so1775839wib.0\r
25         for <notmuch@notmuchmail.org>; Thu, 08 May 2014 17:20:22 -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=vluGkX3vL5l6nusE434lNUa06J/f/OoNW38OHt2K/Us=;\r
29         b=dDrJZlBrsuaxV5cE9vwt6TsYGnhxW9csHXYqfJaPaT/waxqPJgoD3QC4qZqiVAR0Q9\r
30         xpPiqi2LOjhc5/G2RUZvf4OY35nUUNayXwpHT/dlmdiqwXSbwIcTs1BM/0U5z/NEv6Vh\r
31         4k5GoWCL7Rob9baVpDgKeGGIAHtd/jDSo0Gs5MLLfrkWqs8rjGiZ4Th03iey1+kO95VB\r
32         WiqJZcDDQd51hee3BCn90YdcYR+S0bAvpCy9e9YcFzpR1ClBURmhrML9y9ywR/K9h+9i\r
33         hHNkrooqs1qXL7PYpSM+m5mp+pH0s7nC7HNKI0Rrs636ZdKTeONQOP3tOTes3Fq5yTlO\r
34         8aDw==\r
35 X-Received: by 10.194.80.7 with SMTP id n7mr5688320wjx.8.1399594822949;\r
36         Thu, 08 May 2014 17:20:22 -0700 (PDT)\r
37 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
38         by mx.google.com with ESMTPSA id iy13sm2048708wic.1.2014.05.08.17.20.22\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Thu, 08 May 2014 17:20:22 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v4 2/2] emacs: show: add an update seen function to\r
45         post-command-hook\r
46 Date: Fri,  9 May 2014 01:20:08 +0100\r
47 Message-Id: <1399594808-2815-3-git-send-email-markwalters1009@gmail.com>\r
48 X-Mailer: git-send-email 1.7.10.4\r
49 In-Reply-To: <1399594808-2815-1-git-send-email-markwalters1009@gmail.com>\r
50 References: <1399594808-2815-1-git-send-email-markwalters1009@gmail.com>\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Fri, 09 May 2014 00:20:28 -0000\r
64 \r
65 Add a function for updating seen messages to the\r
66 post-command-hook. This function calls a customizable (by eg\r
67 defcustom) function with parameters the start and end of the current\r
68 window and that function can decide what to mark read based on that\r
69 and the current point.\r
70 \r
71 Since this is in the post-command-hook it should get called after most\r
72 user actions (exceptions include user resizing the window) so it\r
73 should be possible to make sure the seen status gets updated whether\r
74 the user uses notmuch commands like next-message or normal emacs\r
75 commands like scroll-up.\r
76 \r
77 It removes all of the old mark read/seen points but introduces a\r
78 simple example function that just marks the current message read if it\r
79 is open. This function has one small subtlety: it makes sure it\r
80 doesn't mark the same message read twice (in the same instance of the\r
81 same buffer); otherwise the post-command-hook makes it impossible for\r
82 a user to manually mark a message unread.\r
83 \r
84 This fixes the current bugs (imo) that closed messages can be marked\r
85 read, and that opening a closed message does not mark it read.\r
86 \r
87 Another advantage of using the post-command-hook any programmatic use\r
88 with point passing through a message will not mark it read.\r
89 ---\r
90  emacs/notmuch-show.el |   43 ++++++++++++++++++++++++++++---------------\r
91  1 file changed, 28 insertions(+), 15 deletions(-)\r
92 \r
93 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
94 index 10fc872..2620f84 100644\r
95 --- a/emacs/notmuch-show.el\r
96 +++ b/emacs/notmuch-show.el\r
97 @@ -222,6 +222,10 @@ (defcustom notmuch-show-mark-read-tags '("-unread")\r
98    :type '(repeat string)\r
99    :group 'notmuch-show)\r
100  \r
101 +(defcustom notmuch-show-mark-read-function #'notmuch-show-seen-current-message\r
102 +  "Function to control which messages are marked read."\r
103 +  :type 'function\r
104 +  :group 'notmuch-show)\r
105  \r
106  (defmacro with-current-notmuch-show-message (&rest body)\r
107    "Evaluate body with current buffer set to the text of current message"\r
108 @@ -1156,6 +1160,8 @@ (defun notmuch-show-build-buffer ()\r
109    (let ((inhibit-read-only t))\r
110  \r
111      (notmuch-show-mode)\r
112 +    (add-hook 'post-command-hook #'notmuch-show-command-hook nil t)\r
113 +\r
114      ;; Don't track undo information for this buffer\r
115      (set 'buffer-undo-list t)\r
116  \r
117 @@ -1544,6 +1550,23 @@ (defun notmuch-show-mark-read (&optional unread)\r
118      (apply 'notmuch-show-tag-message\r
119            (notmuch-tag-change-list notmuch-show-mark-read-tags unread))))\r
120  \r
121 +(defun notmuch-show-seen-current-message (start end)\r
122 +  "Mark the current message read if it is open.\r
123 +\r
124 +We only mark it read once: if it is changed back then that is a\r
125 +user decision and we should not override it."\r
126 +  (when (and (notmuch-show-message-visible-p)\r
127 +            (not (notmuch-show-get-prop :seen)))\r
128 +       (notmuch-show-mark-read)\r
129 +       (notmuch-show-set-prop :seen t)))\r
130 +\r
131 +(defun notmuch-show-command-hook ()\r
132 +  (when (eq major-mode 'notmuch-show-mode)\r
133 +    ;; We need to redisplay to get window-start and window-end correct.\r
134 +    (redisplay)\r
135 +    (save-excursion\r
136 +      (funcall notmuch-show-mark-read-function (window-start) (window-end)))))\r
137 +\r
138  ;; Functions for getting attributes of several messages in the current\r
139  ;; thread.\r
140  \r
141 @@ -1679,9 +1702,7 @@ (defun notmuch-show-next-message (&optional pop-at-end)\r
142  thread, navigate to the next thread in the parent search buffer."\r
143    (interactive "P")\r
144    (if (notmuch-show-goto-message-next)\r
145 -      (progn\r
146 -       (notmuch-show-mark-read)\r
147 -       (notmuch-show-message-adjust))\r
148 +      (notmuch-show-message-adjust)\r
149      (if pop-at-end\r
150         (notmuch-show-next-thread)\r
151        (goto-char (point-max)))))\r
152 @@ -1692,7 +1713,6 @@ (defun notmuch-show-previous-message ()\r
153    (if (= (point) (notmuch-show-message-top))\r
154        (notmuch-show-goto-message-previous)\r
155      (notmuch-show-move-to-message-top))\r
156 -  (notmuch-show-mark-read)\r
157    (notmuch-show-message-adjust))\r
158  \r
159  (defun notmuch-show-next-open-message (&optional pop-at-end)\r
160 @@ -1707,9 +1727,7 @@ (defun notmuch-show-next-open-message (&optional pop-at-end)\r
161      (while (and (setq r (notmuch-show-goto-message-next))\r
162                 (not (notmuch-show-message-visible-p))))\r
163      (if r\r
164 -       (progn\r
165 -         (notmuch-show-mark-read)\r
166 -         (notmuch-show-message-adjust))\r
167 +       (notmuch-show-message-adjust)\r
168        (if pop-at-end\r
169           (notmuch-show-next-thread)\r
170         (goto-char (point-max))))\r
171 @@ -1722,9 +1740,7 @@ (defun notmuch-show-next-matching-message ()\r
172      (while (and (setq r (notmuch-show-goto-message-next))\r
173                 (not (notmuch-show-get-prop :match))))\r
174      (if r\r
175 -       (progn\r
176 -         (notmuch-show-mark-read)\r
177 -         (notmuch-show-message-adjust))\r
178 +       (notmuch-show-message-adjust)\r
179        (goto-char (point-max)))))\r
180  \r
181  (defun notmuch-show-open-if-matched ()\r
182 @@ -1735,8 +1751,7 @@ (defun notmuch-show-open-if-matched ()\r
183  (defun notmuch-show-goto-first-wanted-message ()\r
184    "Move to the first open message and mark it read"\r
185    (goto-char (point-min))\r
186 -  (if (notmuch-show-message-visible-p)\r
187 -      (notmuch-show-mark-read)\r
188 +  (unless (notmuch-show-message-visible-p)\r
189      (notmuch-show-next-open-message))\r
190    (when (eobp)\r
191      ;; There are no matched non-excluded messages so open all matched\r
192 @@ -1744,8 +1759,7 @@ (defun notmuch-show-goto-first-wanted-message ()\r
193      (notmuch-show-mapc 'notmuch-show-open-if-matched)\r
194      (force-window-update)\r
195      (goto-char (point-min))\r
196 -    (if (notmuch-show-message-visible-p)\r
197 -       (notmuch-show-mark-read)\r
198 +    (unless (notmuch-show-message-visible-p)\r
199        (notmuch-show-next-open-message))))\r
200  \r
201  (defun notmuch-show-previous-open-message ()\r
202 @@ -1755,7 +1769,6 @@ (defun notmuch-show-previous-open-message ()\r
203                   (notmuch-show-goto-message-previous)\r
204                 (notmuch-show-move-to-message-top))\r
205               (not (notmuch-show-message-visible-p))))\r
206 -  (notmuch-show-mark-read)\r
207    (notmuch-show-message-adjust))\r
208  \r
209  (defun notmuch-show-view-raw-message ()\r
210 -- \r
211 1.7.10.4\r
212 \r