Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / f1 / 8a91784fd6cd858d6c380cd4c2375049d7fbe7
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 35D77431FC9\r
6         for <notmuch@notmuchmail.org>; Wed,  8 Feb 2012 00:02:42 -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 W1OFkQOpwD72 for <notmuch@notmuchmail.org>;\r
16         Wed,  8 Feb 2012 00:02:39 -0800 (PST)\r
17 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
18         [209.85.212.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 64BE3431FD0\r
21         for <notmuch@notmuchmail.org>; Wed,  8 Feb 2012 00:02:32 -0800 (PST)\r
22 Received: by mail-wi0-f181.google.com with SMTP id hi8so201602wib.26\r
23         for <notmuch@notmuchmail.org>; Wed, 08 Feb 2012 00:02:32 -0800 (PST)\r
24 Received: by 10.180.24.202 with SMTP id w10mr38957249wif.9.1328688152091;\r
25         Wed, 08 Feb 2012 00:02:32 -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 cs4sm645075wib.8.2012.02.08.00.02.27\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Wed, 08 Feb 2012 00:02:29 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id 4EE83A3806; Wed,  8 Feb 2012 08:02:21 +0000 (GMT)\r
33 From: David Edmondson <dme@dme.org>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH v8 5/8] emacs: Optionally retain the state of the buffer\r
36         during `notmuch-show-refresh-view'.\r
37 Date: Wed,  8 Feb 2012 08:02:16 +0000\r
38 Message-Id: <1328688139-3865-8-git-send-email-dme@dme.org>\r
39 X-Mailer: git-send-email 1.7.8.3\r
40 In-Reply-To: <1328688139-3865-1-git-send-email-dme@dme.org>\r
41 References: <1327486729-18052-1-git-send-email-dme@dme.org>\r
42         <1328688139-3865-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: Wed, 08 Feb 2012 08:02:42 -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 |   56 ++++++++++++++++++++++++++++++++++++++++++-------\r
69  1 files changed, 48 insertions(+), 8 deletions(-)\r
70 \r
71 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
72 index 6c79511..a668625 100644\r
73 --- a/emacs/notmuch-show.el\r
74 +++ b/emacs/notmuch-show.el\r
75 @@ -951,7 +951,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 @@ -960,7 +960,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 @@ -969,7 +969,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 @@ -1073,14 +1073,54 @@ 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))\r
151 +  (let ((inhibit-read-only t)\r
152 +       state)\r
153 +    (if retain-state\r
154 +       (setq state (notmuch-show-capture-state)))\r
155 +    (erase-buffer)\r
156 +    (notmuch-show-worker)\r
157 +    (if state\r
158 +       (notmuch-show-apply-state state))))\r
159  \r
160  (defvar notmuch-show-stash-map\r
161    (let ((map (make-sparse-keymap)))\r
162 -- \r
163 1.7.8.3\r
164 \r