1 Return-Path: <amdragon@mit.edu>
\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 1A122429E56
\r
6 for <notmuch@notmuchmail.org>; Tue, 3 Sep 2013 14:46:10 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id oeCQnyX7fwwh for <notmuch@notmuchmail.org>;
\r
16 Tue, 3 Sep 2013 14:46:04 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu
\r
19 by olra.theworths.org (Postfix) with ESMTP id 350A1431FD8
\r
20 for <notmuch@notmuchmail.org>; Tue, 3 Sep 2013 14:45:42 -0700 (PDT)
\r
21 X-AuditID: 12074425-b7f0c8e000000953-c5-52265885fcd2
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 48.EF.02387.58856225; Tue, 3 Sep 2013 17:45:41 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r83LjU4s019872;
\r
27 Tue, 3 Sep 2013 17:45:30 -0400
\r
28 Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r83LjRvf026852
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Tue, 3 Sep 2013 17:45:28 -0400
\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1VGyPe-0004xq-Su; Tue, 03 Sep 2013 17:45:26 -0400
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH v2 2/9] emacs: Refresh hello whenever the user switches to the
\r
41 Date: Tue, 3 Sep 2013 17:45:18 -0400
\r
42 Message-Id: <1378244725-18846-3-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.10.4
\r
44 In-Reply-To: <1378244725-18846-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1378244725-18846-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixG6notsaoRZkcP6LkUXTdGeL1XN5LK7f
\r
48 nMnswOyxc9Zddo9b91+zezxbdYs5gDmKyyYlNSezLLVI3y6BK+PDjWmsBXtUK3ovXmZvYFwp
\r
49 18XIySEhYCLxuv8ME4QtJnHh3nq2LkYuDiGBfYwSV7c/ZoRwNjBK3N/fwQ7hHGaSmHzpO1Rm
\r
50 LqPEi7PzwfrZBDQktu1fzghiiwhIS+y8O5sVxGYWiJY4cnkGG4gtLBAqcf7sTWYQm0VAVeLv
\r
51 oalgNbwCDhIPd/6FukNRovvZBLB6TgFHid4Fi9hBbCGgmqaVl9knMPIvYGRYxSibklulm5uY
\r
52 mVOcmqxbnJyYl5dapGuhl5tZopeaUrqJERxcLqo7GCccUjrEKMDBqMTDu+K+apAQa2JZcWXu
\r
53 IUZJDiYlUd4joWpBQnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4E3yAcrwpiZVVqUX5MClpDhYl
\r
54 cd7nT88GCgmkJ5akZqemFqQWwWRlODiUJHjfhwM1ChalpqdWpGXmlCCkmTg4QYbzAA1/CVLD
\r
55 W1yQmFucmQ6RP8WoKCXOexskIQCSyCjNg+uFRf8rRnGgV4R5j4NU8QATB1z3K6DBTECD0z6r
\r
56 ggwuSURISTUw5vPIMvdnL/2r/rmlKLtbPucPe2bH1/ud9n0HuqXdmvbquZ8p83g818zLXdpA
\r
57 7stkRkbrL+3Kt4pbXvj+Nuz6Yjpli49wt9m0n37Cbzc++MKwLIllUqK29sd2z8s9zmx2atd0
\r
58 DvCHdH511Xh769GsHxOq6oXig//U7Jw52+vFNt8yY5OyzR1KLMUZiYZazEXFiQAO0JLa2QIA AA==
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Tue, 03 Sep 2013 21:46:10 -0000
\r
73 Previously, we refreshed hello when the user quit a search that was
\r
74 started from hello. This is fine assuming purely stack-oriented
\r
75 buffer use, but is quite fragile and requires hacks to search.
\r
77 This replaces that logic with a new approach that refreshes hello
\r
78 whenever the user switches to the hello buffer, regardless of how this
\r
81 emacs/notmuch-hello.el | 58 +++++++++++++++++++++++++++++++++++++++---------
\r
82 1 file changed, 48 insertions(+), 10 deletions(-)
\r
84 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
85 index 9db8c99..24ac1c6 100644
\r
86 --- a/emacs/notmuch-hello.el
\r
87 +++ b/emacs/notmuch-hello.el
\r
88 @@ -232,6 +232,11 @@ supported for \"Customized queries section\" items."
\r
89 notmuch-hello-query-section
\r
90 (function :tag "Custom section"))))
\r
92 +(defcustom notmuch-hello-auto-refresh t
\r
93 + "Automatically refresh when returning to the notmuch-hello buffer."
\r
94 + :group 'notmuch-hello
\r
97 (defvar notmuch-hello-hidden-sections nil
\r
98 "List of sections titles whose contents are hidden")
\r
100 @@ -263,8 +268,7 @@ afterwards.")
\r
101 (setq search (notmuch-hello-trim search))
\r
102 (let ((history-delete-duplicates t))
\r
103 (add-to-history 'notmuch-search-history search)))
\r
104 - (notmuch-search search notmuch-search-oldest-first nil nil
\r
105 - #'notmuch-hello-search-continuation))
\r
106 + (notmuch-search search notmuch-search-oldest-first))
\r
108 (defun notmuch-hello-add-saved-search (widget)
\r
110 @@ -322,8 +326,7 @@ diagonal."
\r
111 (defun notmuch-hello-widget-search (widget &rest ignore)
\r
112 (notmuch-search (widget-get widget
\r
113 :notmuch-search-terms)
\r
114 - notmuch-search-oldest-first
\r
115 - nil nil #'notmuch-hello-search-continuation))
\r
116 + notmuch-search-oldest-first))
\r
118 (defun notmuch-saved-search-count (search)
\r
119 (car (process-lines notmuch-command "count" search)))
\r
120 @@ -476,9 +479,6 @@ Such a list can be computed with `notmuch-hello-query-counts'."
\r
122 (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))
\r
124 -(defun notmuch-hello-search-continuation()
\r
125 - (notmuch-hello-update t))
\r
127 (defun notmuch-hello-update (&optional no-display)
\r
128 "Update the current notmuch view."
\r
129 ;; Lazy - rebuild everything.
\r
130 @@ -491,6 +491,36 @@ Such a list can be computed with `notmuch-hello-query-counts'."
\r
132 (notmuch-hello-update))
\r
134 +(defun notmuch-hello-window-configuration-change ()
\r
135 + "Hook function to update the hello buffer when it is switched to."
\r
136 + (let ((hello-buf (get-buffer "*notmuch-hello*"))
\r
137 + (do-refresh nil))
\r
138 + ;; Consider all windows in the currently selected frame, since
\r
139 + ;; that's where the configuration change happened. This also
\r
140 + ;; refreshes our snapshot of all windows, so we have to do this
\r
141 + ;; even if we know we won't refresh (e.g., hello-buf is null).
\r
142 + (dolist (window (window-list))
\r
143 + (let ((last-buf (window-parameter window 'notmuch-hello-last-buffer))
\r
144 + (cur-buf (window-buffer window)))
\r
145 + (when (not (eq last-buf cur-buf))
\r
146 + ;; This window changed or is new. Update recorded buffer
\r
147 + ;; for next time.
\r
148 + (set-window-parameter window 'notmuch-hello-last-buffer cur-buf)
\r
149 + (when (and (eq cur-buf hello-buf) last-buf)
\r
150 + ;; The user just switched to hello in this window (hello
\r
151 + ;; is currently visible, was not visible on the last
\r
152 + ;; configuration change, and this is not a new window)
\r
153 + (setq do-refresh t)))))
\r
154 + (when (and do-refresh notmuch-hello-auto-refresh)
\r
155 + ;; Refresh hello as soon as we get back to redisplay. On Emacs
\r
156 + ;; 24, we can't do it right here because something in this
\r
157 + ;; hook's call stack overrides hello's point placement.
\r
158 + (run-at-time nil nil #'notmuch-hello t))
\r
159 + (when (null hello-buf)
\r
161 + (remove-hook 'window-configuration-change-hook
\r
162 + #'notmuch-hello-window-configuration-change))))
\r
165 (defvar notmuch-hello-mode-map
\r
166 (let ((map (make-sparse-keymap)))
\r
167 @@ -765,9 +795,17 @@ following:
\r
168 "Run notmuch and display saved searches, known tags, etc."
\r
172 - (set-buffer "*notmuch-hello*")
\r
173 - (switch-to-buffer "*notmuch-hello*"))
\r
174 + ;; This may cause a window configuration change, so if the
\r
175 + ;; auto-refresh hook is already installed, avoid recursive refresh.
\r
176 + (let ((notmuch-hello-auto-refresh nil))
\r
178 + (set-buffer "*notmuch-hello*")
\r
179 + (switch-to-buffer "*notmuch-hello*")))
\r
181 + ;; Install auto-refresh hook
\r
182 + (when notmuch-hello-auto-refresh
\r
183 + (add-hook 'window-configuration-change-hook
\r
184 + #'notmuch-hello-window-configuration-change))
\r
186 (let ((target-line (line-number-at-pos))
\r
187 (target-column (current-column))
\r