Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / be / 422985529385e9d9cb9bea894958ec27b3d7ab
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 A6779431FC2\r
6         for <notmuch@notmuchmail.org>; Tue, 25 Mar 2014 13:03: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 cU-0-K6hVBZ9 for <notmuch@notmuchmail.org>;\r
18         Tue, 25 Mar 2014 13:03:24 -0700 (PDT)\r
19 Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com\r
20         [209.85.212.174]) (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 16510431FBF\r
23         for <notmuch@notmuchmail.org>; Tue, 25 Mar 2014 13:03:23 -0700 (PDT)\r
24 Received: by mail-wi0-f174.google.com with SMTP id d1so3857556wiv.7\r
25         for <notmuch@notmuchmail.org>; Tue, 25 Mar 2014 13:03:21 -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=VfC8O5Tu9ay8+KisWsKw5K35igXFtj7AkCqwgM3Qukg=;\r
29         b=tRRG7fEXFXJPkpZbLK1PojYd5btonx/h1DpKSCHrHO9MHeUF+3BdQyycvVQvifTYey\r
30         weY8j839T6tpQAZBGCjpoRiBXj33ssMP9HQioqcg7FHOxCaFOoI95WD282/3CTxzPjzN\r
31         ievrrnaUpIkT53LnxMWl0O9ddV/Uic1dILxtaO3cjK+HBqqRlBhFfDjhcGgY0wR0MPga\r
32         xqW0DvEKvass48pqWB260ogNWtyRv/YJR4V2aw9loRjFOiASyqzJjsaay9OmzowMegWb\r
33         c24I3mM3TwBw0tP/UDykKot4YbfsurFGiE3AbI7ZaWc/u5CAeDjZvmQx75w/xVlhWpt2\r
34         vHBA==\r
35 X-Received: by 10.180.73.1 with SMTP id h1mr26530880wiv.10.1395777801551;\r
36         Tue, 25 Mar 2014 13:03:21 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id dd5sm984894wib.12.2014.03.25.13.03.20\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Tue, 25 Mar 2014 13:03:20 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [Patch v3 2/3] emacs: show: add an update seen function to\r
45         post-command-hook\r
46 Date: Tue, 25 Mar 2014 20:03:12 +0000\r
47 Message-Id: <1395777793-13297-3-git-send-email-markwalters1009@gmail.com>\r
48 X-Mailer: git-send-email 1.7.10.4\r
49 In-Reply-To: <1395777793-13297-1-git-send-email-markwalters1009@gmail.com>\r
50 References: <1395777793-13297-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: Tue, 25 Mar 2014 20:03:28 -0000\r
64 \r
65 Add a function stub for updating seen messages to the\r
66 post-command-hook. This dummy function gets called with parameters the\r
67 start and end of the current window and can decide what to mark seen\r
68 based on that.\r
69 \r
70 Since this is in the post-command-hook it should get called after most\r
71 user actions (exceptions include user resizing the window) so it\r
72 should be possible to make sure the seen status gets updated whether\r
73 the user uses notmuch commands like next-message or normal emacs\r
74 commands like scroll-up.\r
75 \r
76 It also removes all of the old mark read/seen points to give a clean\r
77 slate for testing new mark read/seen algorithms.\r
78 ---\r
79  emacs/notmuch-show.el |   32 +++++++++++++++++---------------\r
80  1 file changed, 17 insertions(+), 15 deletions(-)\r
81 \r
82 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
83 index f6ca827..1a7de85 100644\r
84 --- a/emacs/notmuch-show.el\r
85 +++ b/emacs/notmuch-show.el\r
86 @@ -1142,6 +1142,8 @@ (defun notmuch-show-build-buffer ()\r
87    (let ((inhibit-read-only t))\r
88  \r
89      (notmuch-show-mode)\r
90 +    (add-hook 'post-command-hook #'notmuch-show-command-hook nil t)\r
91 +\r
92      ;; Don't track undo information for this buffer\r
93      (set 'buffer-undo-list t)\r
94  \r
95 @@ -1530,6 +1532,16 @@ (defun notmuch-show-mark-read (&optional unread)\r
96      (apply 'notmuch-show-tag-message\r
97            (notmuch-tag-change-list notmuch-show-mark-read-tags unread))))\r
98  \r
99 +(defun notmuch-show-do-seen (start end)\r
100 +  "Update seen status for all messages between start and end."\r
101 +  )\r
102 +\r
103 +(defun notmuch-show-command-hook ()\r
104 +  (when (eq major-mode 'notmuch-show-mode)\r
105 +    ;; We need to redisplay to get window-start and window-end correct.\r
106 +    (redisplay)\r
107 +    (notmuch-show-do-seen (window-start) (window-end))))\r
108 +\r
109  ;; Functions for getting attributes of several messages in the current\r
110  ;; thread.\r
111  \r
112 @@ -1665,9 +1677,7 @@ (defun notmuch-show-next-message (&optional pop-at-end)\r
113  thread, navigate to the next thread in the parent search buffer."\r
114    (interactive "P")\r
115    (if (notmuch-show-goto-message-next)\r
116 -      (progn\r
117 -       (notmuch-show-mark-read)\r
118 -       (notmuch-show-message-adjust))\r
119 +      (notmuch-show-message-adjust)\r
120      (if pop-at-end\r
121         (notmuch-show-next-thread)\r
122        (goto-char (point-max)))))\r
123 @@ -1678,7 +1688,6 @@ (defun notmuch-show-previous-message ()\r
124    (if (= (point) (notmuch-show-message-top))\r
125        (notmuch-show-goto-message-previous)\r
126      (notmuch-show-move-to-message-top))\r
127 -  (notmuch-show-mark-read)\r
128    (notmuch-show-message-adjust))\r
129  \r
130  (defun notmuch-show-next-open-message (&optional pop-at-end)\r
131 @@ -1693,9 +1702,7 @@ (defun notmuch-show-next-open-message (&optional pop-at-end)\r
132      (while (and (setq r (notmuch-show-goto-message-next))\r
133                 (not (notmuch-show-message-visible-p))))\r
134      (if r\r
135 -       (progn\r
136 -         (notmuch-show-mark-read)\r
137 -         (notmuch-show-message-adjust))\r
138 +       (notmuch-show-message-adjust)\r
139        (if pop-at-end\r
140           (notmuch-show-next-thread)\r
141         (goto-char (point-max))))\r
142 @@ -1708,9 +1715,7 @@ (defun notmuch-show-next-matching-message ()\r
143      (while (and (setq r (notmuch-show-goto-message-next))\r
144                 (not (notmuch-show-get-prop :match))))\r
145      (if r\r
146 -       (progn\r
147 -         (notmuch-show-mark-read)\r
148 -         (notmuch-show-message-adjust))\r
149 +       (notmuch-show-message-adjust)\r
150        (goto-char (point-max)))))\r
151  \r
152  (defun notmuch-show-open-if-matched ()\r
153 @@ -1721,8 +1726,7 @@ (defun notmuch-show-open-if-matched ()\r
154  (defun notmuch-show-goto-first-wanted-message ()\r
155    "Move to the first open message and mark it read"\r
156    (goto-char (point-min))\r
157 -  (if (notmuch-show-message-visible-p)\r
158 -      (notmuch-show-mark-read)\r
159 +  (unless (notmuch-show-message-visible-p)\r
160      (notmuch-show-next-open-message))\r
161    (when (eobp)\r
162      ;; There are no matched non-excluded messages so open all matched\r
163 @@ -1730,8 +1734,7 @@ (defun notmuch-show-goto-first-wanted-message ()\r
164      (notmuch-show-mapc 'notmuch-show-open-if-matched)\r
165      (force-window-update)\r
166      (goto-char (point-min))\r
167 -    (if (notmuch-show-message-visible-p)\r
168 -       (notmuch-show-mark-read)\r
169 +    (unless (notmuch-show-message-visible-p)\r
170        (notmuch-show-next-open-message))))\r
171  \r
172  (defun notmuch-show-previous-open-message ()\r
173 @@ -1741,7 +1744,6 @@ (defun notmuch-show-previous-open-message ()\r
174                   (notmuch-show-goto-message-previous)\r
175                 (notmuch-show-move-to-message-top))\r
176               (not (notmuch-show-message-visible-p))))\r
177 -  (notmuch-show-mark-read)\r
178    (notmuch-show-message-adjust))\r
179  \r
180  (defun notmuch-show-view-raw-message ()\r
181 -- \r
182 1.7.10.4\r
183 \r