Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 86 / 8c1c4adab5e1e670148cd234e419e120688c98
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 3679E431FAE\r
6         for <notmuch@notmuchmail.org>; Thu, 29 Aug 2013 09:26:17 -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.7\r
10 X-Spam-Level: \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 ngprB3rWJp5I for <notmuch@notmuchmail.org>;\r
16         Thu, 29 Aug 2013 09:26:11 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
18         [18.7.68.35])\r
19         by olra.theworths.org (Postfix) with ESMTP id AF8C4431FC9\r
20         for <notmuch@notmuchmail.org>; Thu, 29 Aug 2013 09:26:05 -0700 (PDT)\r
21 X-AuditID: 12074423-b7f168e00000095a-c9-521f761d7688\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id BB.9E.02394.D167F125; Thu, 29 Aug 2013 12:26:05 -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 r7TGQ3uZ025416; \r
27         Thu, 29 Aug 2013 12:26:04 -0400\r
28 Received: from drake.dyndns.org\r
29         (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [216.15.114.40]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r7TGQ1UJ014991\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Thu, 29 Aug 2013 12:26:02 -0400\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1VF52m-0007Wk-VE; Thu, 29 Aug 2013 12:26:00 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 2/9] emacs: Refresh hello whenever the user switches to the\r
41         buffer\r
42 Date: Thu, 29 Aug 2013 12:25:50 -0400\r
43 Message-Id: <1377793557-28878-3-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.10.4\r
45 In-Reply-To: <1377793557-28878-1-git-send-email-amdragon@mit.edu>\r
46 References: <1377793557-28878-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsUixG6noitbJh9k0NvEb3H95kxmB0aPZ6tu\r
49         MQcwRnHZpKTmZJalFunbJXBl7Fn8mqVgmmLFsvv/2BoYW6W7GDk5JARMJJqOXWGEsMUkLtxb\r
50         z9bFyMUhJLCPUeLVtynsEM5GRon5VxdAZe4wSexbcIQRwpnLKHF3+wZWkH42AQ2JbfuXg80S\r
51         EZCW2Hl3NlCcg4NZQE3iT5cKSFhYIEjiRNt8dhCbRUBV4vTs42wgNq+Ag8Sj7e+YIc5QlOh+\r
52         NgEszingKNF/9y0LiC0EVPPn4lP2CYz8CxgZVjHKpuRW6eYmZuYUpybrFicn5uWlFuma6eVm\r
53         luilppRuYgSHjYvyDsY/B5UOMQpwMCrx8HYEygcJsSaWFVfmHmKU5GBSEuUNLAEK8SXlp1Rm\r
54         JBZnxBeV5qQWH2KU4GBWEuF9ywmU401JrKxKLcqHSUlzsCiJ8z57ejZQSCA9sSQ1OzW1ILUI\r
55         JivDwaEkwXsfZKhgUWp6akVaZk4JQpqJgxNkOA/Q8H8gNbzFBYm5xZnpEPlTjIpS4rw/QRIC\r
56         IImM0jy4Xlhcv2IUB3pFmPcOSBUPMCXAdb8CGswENHhCvhzI4JJEhJRUA2P4warprYF5H5lq\r
57         E5uqT4heVVwQGdqVmdZjvLRJ+cLe0Ou/+5zq7UK0Kye0XH991bo6rmrXg1Z37vztLBtVIhq5\r
58         1fWz9RYo13xrt+Oda8h/V5xtktWJk3+4HJU3pMf7+Mx6I1zNJupT2fSp29wh49rWNOtovuNO\r
59         qyVz10bo3cxs27CwN+GQEktxRqKhFnNRcSIAM24LHMYCAAA=\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Thu, 29 Aug 2013 16:26:17 -0000\r
73 \r
74 Previously, we refreshed hello when the user quit a search that was\r
75 started from hello.  This is fine assuming purely stack-oriented\r
76 buffer use, but is quite fragile and requires hacks to search.\r
77 \r
78 This replaces that logic with a new approach that refreshes hello\r
79 whenever the user switches to the hello buffer, regardless of how this\r
80 happens.\r
81 ---\r
82  emacs/notmuch-hello.el |   52 ++++++++++++++++++++++++++++++++++++++----------\r
83  1 file changed, 42 insertions(+), 10 deletions(-)\r
84 \r
85 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
86 index 9db8c99..c4f102f 100644\r
87 --- a/emacs/notmuch-hello.el\r
88 +++ b/emacs/notmuch-hello.el\r
89 @@ -263,8 +263,7 @@ afterwards.")\r
90      (setq search (notmuch-hello-trim search))\r
91      (let ((history-delete-duplicates t))\r
92        (add-to-history 'notmuch-search-history search)))\r
93 -  (notmuch-search search notmuch-search-oldest-first nil nil\r
94 -                 #'notmuch-hello-search-continuation))\r
95 +  (notmuch-search search notmuch-search-oldest-first))\r
96  \r
97  (defun notmuch-hello-add-saved-search (widget)\r
98    (interactive)\r
99 @@ -322,8 +321,7 @@ diagonal."\r
100  (defun notmuch-hello-widget-search (widget &rest ignore)\r
101    (notmuch-search (widget-get widget\r
102                               :notmuch-search-terms)\r
103 -                 notmuch-search-oldest-first\r
104 -                 nil nil #'notmuch-hello-search-continuation))\r
105 +                 notmuch-search-oldest-first))\r
106  \r
107  (defun notmuch-saved-search-count (search)\r
108    (car (process-lines notmuch-command "count" search)))\r
109 @@ -476,9 +474,6 @@ Such a list can be computed with `notmuch-hello-query-counts'."\r
110  \r
111  (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))\r
112  \r
113 -(defun notmuch-hello-search-continuation()\r
114 -  (notmuch-hello-update t))\r
115 -\r
116  (defun notmuch-hello-update (&optional no-display)\r
117    "Update the current notmuch view."\r
118    ;; Lazy - rebuild everything.\r
119 @@ -491,6 +486,36 @@ Such a list can be computed with `notmuch-hello-query-counts'."\r
120    (notmuch-poll)\r
121    (notmuch-hello-update))\r
122  \r
123 +(defvar notmuch-hello-inhibit-auto-refresh nil\r
124 +  "Don't refresh notmuch-hello on window configuration changes.")\r
125 +\r
126 +(defun notmuch-hello-window-configuration-change ()\r
127 +  "Hook function to update the hello buffer when it is switched to."\r
128 +  (let ((hello-buf (get-buffer "*notmuch-hello*"))\r
129 +       (do-refresh nil))\r
130 +    ;; Consider all windows in the currently selected frame, since\r
131 +    ;; that's where the configuration change happened.  This also\r
132 +    ;; refreshes our snapshot of all windows, so we have to do this\r
133 +    ;; even if we know we won't refresh (e.g., hello-buf is null).\r
134 +    (dolist (window (window-list))\r
135 +      (let ((last-buf (window-parameter window 'notmuch-hello-last-buffer))\r
136 +           (cur-buf (window-buffer window)))\r
137 +       (when (not (eq last-buf cur-buf))\r
138 +         ;; This window changed or is new.  Update recorded buffer\r
139 +         ;; for next time.\r
140 +         (set-window-parameter window 'notmuch-hello-last-buffer cur-buf)\r
141 +         (when (and (eq cur-buf hello-buf) last-buf)\r
142 +           ;; The user just switched to hello in this window (hello\r
143 +           ;; is currently visible, was not visible on the last\r
144 +           ;; configuration change, and this is not a new window)\r
145 +           (setq do-refresh t)))))\r
146 +    (when (and do-refresh (not notmuch-hello-inhibit-auto-refresh))\r
147 +      (notmuch-hello t))\r
148 +    (when (null hello-buf)\r
149 +      ;; Clean up hook\r
150 +      (remove-hook 'window-configuration-change-hook\r
151 +                  #'notmuch-hello-window-configuration-change))))\r
152 +\r
153  \r
154  (defvar notmuch-hello-mode-map\r
155    (let ((map (make-sparse-keymap)))\r
156 @@ -765,9 +790,16 @@ following:\r
157    "Run notmuch and display saved searches, known tags, etc."\r
158    (interactive)\r
159  \r
160 -  (if no-display\r
161 -      (set-buffer "*notmuch-hello*")\r
162 -    (switch-to-buffer "*notmuch-hello*"))\r
163 +  ;; This may cause a window configuration change, so if the\r
164 +  ;; auto-refresh hook is already installed, avoid recursive refresh.\r
165 +  (let ((notmuch-hello-inhibit-auto-refresh t))\r
166 +    (if no-display\r
167 +       (set-buffer "*notmuch-hello*")\r
168 +      (switch-to-buffer "*notmuch-hello*")))\r
169 +\r
170 +  ;; Install auto-refresh hook\r
171 +  (add-hook 'window-configuration-change-hook\r
172 +           #'notmuch-hello-window-configuration-change)\r
173  \r
174    (let ((target-line (line-number-at-pos))\r
175         (target-column (current-column))\r
176 -- \r
177 1.7.10.4\r
178 \r