[PATCH v2 11/14] cli/reply: return internet address list from get header funcs
[notmuch-archives.git] / a1 / 6c4c9cdc158c3eb41e8db7e2f4dd3ddee8330c
1 Return-Path: <dme@dme.org>\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 CA38B429E5B\r
6         for <notmuch@notmuchmail.org>; Tue, 31 Jan 2012 00:47:16 -0800 (PST)\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 k437k3pL1QPy for <notmuch@notmuchmail.org>;\r
16         Tue, 31 Jan 2012 00:47:14 -0800 (PST)\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
18         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 0454E417347\r
21         for <notmuch@notmuchmail.org>; Tue, 31 Jan 2012 00:47:07 -0800 (PST)\r
22 Received: by mail-we0-f181.google.com with SMTP id b10so4655480wer.26\r
23         for <notmuch@notmuchmail.org>; Tue, 31 Jan 2012 00:47:07 -0800 (PST)\r
24 Received: by 10.216.135.76 with SMTP id t54mr8659069wei.14.1327999627614;\r
25         Tue, 31 Jan 2012 00:47:07 -0800 (PST)\r
26 Received: from hotblack-desiato.hh.sledj.net\r
27         (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
28         by mx.google.com with ESMTPS id bj10sm35769862wib.9.2012.01.31.00.47.06\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Tue, 31 Jan 2012 00:47:06 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id D8A27A0336; Tue, 31 Jan 2012 08:47:01 +0000 (GMT)\r
33 From: David Edmondson <dme@dme.org>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH 5/5] emacs: Optionally retain the state of the buffer during\r
36         `notmuch-show-refresh-view'.\r
37 Date: Tue, 31 Jan 2012 08:47:00 +0000\r
38 Message-Id: <1327999620-14595-6-git-send-email-dme@dme.org>\r
39 X-Mailer: git-send-email 1.7.8.3\r
40 In-Reply-To: <1327999620-14595-1-git-send-email-dme@dme.org>\r
41 References: <id:"1327486729-18052-1-git-send-email-dme@dme.org">\r
42         <1327999620-14595-1-git-send-email-dme@dme.org>\r
43 X-BeenThere: notmuch@notmuchmail.org\r
44 X-Mailman-Version: 2.1.13\r
45 Precedence: list\r
46 List-Id: "Use and development of the notmuch mail system."\r
47         <notmuch.notmuchmail.org>\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
51 List-Post: <mailto:notmuch@notmuchmail.org>\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
55 X-List-Received-Date: Tue, 31 Jan 2012 08:47:17 -0000\r
56 \r
57 With an argument, record and reply the state of the buffer during\r
58 `notmuch-show-refresh-view'.\r
59 \r
60 In this context, "state" is defined as:\r
61  - the open/closed state of each message,\r
62  - the current message.\r
63 \r
64 Traditional use of refresh with the = key does not retain the\r
65 state. The recently introduced toggle commands ($, !, < and >) do\r
66 retain the state.\r
67 ---\r
68  emacs/notmuch-show.el |   58 +++++++++++++++++++++++++++++++++++++++++-------\r
69  1 files changed, 49 insertions(+), 9 deletions(-)\r
70 \r
71 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
72 index 28f2148..2f10c42 100644\r
73 --- a/emacs/notmuch-show.el\r
74 +++ b/emacs/notmuch-show.el\r
75 @@ -933,7 +933,7 @@ current buffer, if possible."\r
76    (message (if notmuch-show-process-crypto\r
77                "Processing cryptographic MIME parts."\r
78              "Not processing cryptographic MIME parts."))\r
79 -  (notmuch-show-refresh-view))\r
80 +  (notmuch-show-refresh-view t))\r
81  \r
82  (defun notmuch-show-toggle-elide-non-matching ()\r
83    "Toggle the display of non-matching messages."\r
84 @@ -942,7 +942,7 @@ current buffer, if possible."\r
85    (message (if notmuch-show-elide-non-matching-messages\r
86                "Showing matching messages only."\r
87              "Showing all messages."))\r
88 -  (notmuch-show-refresh-view))\r
89 +  (notmuch-show-refresh-view t))\r
90  \r
91  (defun notmuch-show-toggle-thread-indentation ()\r
92    "Toggle the indentation of threads."\r
93 @@ -951,7 +951,7 @@ current buffer, if possible."\r
94    (message (if notmuch-show-indent-content\r
95                "Content is indented."\r
96              "Content is not indented."))\r
97 -  (notmuch-show-refresh-view))\r
98 +  (notmuch-show-refresh-view t))\r
99  \r
100  (defun notmuch-show-insert-tree (tree depth)\r
101    "Insert the message tree TREE at depth DEPTH in the current thread."\r
102 @@ -1054,15 +1054,55 @@ function is used."\r
103  \r
104      (notmuch-show-mark-read)))\r
105  \r
106 -(defun notmuch-show-refresh-view ()\r
107 +(defun notmuch-show-capture-state ()\r
108 +  "Capture the state of the current buffer.\r
109 +\r
110 +This includes:\r
111 + - the list of open messages,\r
112 + - the current message."\r
113 +  (list (notmuch-show-get-message-id) (notmuch-show-get-message-ids-for-open-messages)))\r
114 +\r
115 +(defun notmuch-show-apply-state (state)\r
116 +  "Apply STATE to the current buffer.\r
117 +\r
118 +This includes:\r
119 + - opening the messages previously opened,\r
120 + - closing all other messages,\r
121 + - moving to the correct current message."\r
122 +  (let ((current (car state))\r
123 +       (open (cadr state)))\r
124 +\r
125 +    ;; Open those that were open.\r
126 +    (goto-char (point-min))\r
127 +    (loop do (notmuch-show-message-visible (notmuch-show-get-message-properties)\r
128 +                                          (member (notmuch-show-get-message-id) open))\r
129 +         until (not (notmuch-show-goto-message-next)))\r
130 +\r
131 +    ;; Go to the previously open message.\r
132 +    (goto-char (point-min))\r
133 +    (unless (loop if (string= current (notmuch-show-get-message-id))\r
134 +                 return t\r
135 +                 until (not (notmuch-show-goto-message-next)))\r
136 +      (goto-char (point-min))\r
137 +      (message "Previously current message not found."))\r
138 +    (notmuch-show-message-adjust)))\r
139 +\r
140 +(defun notmuch-show-refresh-view (&optional retain-state)\r
141    "Refresh the current view.\r
142  \r
143 -Refreshes the current view, observing changes in cryptographic preferences."\r
144 +Refreshes the current view, observing changes in display\r
145 +preferences. If RETAIN-STATE is non-nil then the state of the\r
146 +buffer is stored and re-applied after the refresh."\r
147    (interactive)\r
148 -  (let ((inhibit-read-only t))\r
149 -    (erase-buffer))\r
150 -  (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer\r
151 -                      notmuch-show-query-context))\r
152 +  (let ((inhibit-read-only t)\r
153 +       state)\r
154 +    (if retain-state\r
155 +       (setq state (notmuch-show-capture-state)))\r
156 +    (erase-buffer)\r
157 +    (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer\r
158 +                        notmuch-show-query-context)\r
159 +    (if state\r
160 +       (notmuch-show-apply-state state))))\r
161  \r
162  (defvar notmuch-show-stash-map\r
163    (let ((map (make-sparse-keymap)))\r
164 -- \r
165 1.7.8.3\r
166 \r