Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d1 / 38dd0dcce75fed1feb112b66e181b418cac128
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 C540D431FC9\r
6         for <notmuch@notmuchmail.org>; Sat, 21 Jul 2012 10:37:21 -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 wq2tmDAbOKiL for <notmuch@notmuchmail.org>;\r
16         Sat, 21 Jul 2012 10:37:20 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
18         [18.7.68.36])\r
19         by olra.theworths.org (Postfix) with ESMTP id B9960431FBF\r
20         for <notmuch@notmuchmail.org>; Sat, 21 Jul 2012 10:37:19 -0700 (PDT)\r
21 X-AuditID: 12074424-b7f2a6d0000008bf-76-500ae8ce4abd\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 36.3D.02239.EC8EA005; Sat, 21 Jul 2012 13:37:18 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q6LHbHdr018461; \r
27         Sat, 21 Jul 2012 13:37:17 -0400\r
28 Received: from drake.dyndns.org\r
29         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [209.6.116.242]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6LHbFs3008010\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Sat, 21 Jul 2012 13:37:16 -0400 (EDT)\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1SsdcB-0001Zc-55; Sat, 21 Jul 2012 13:37:15 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v4 0/8] emacs: JSON-based search cleanups\r
41 Date: Sat, 21 Jul 2012 13:37:04 -0400\r
42 Message-Id: <1342892232-5659-1-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.7.10\r
44 In-Reply-To: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
45 References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
46 X-Brightmail-Tracker:\r
47  H4sIAAAAAAAAA+NgFrrIIsWRmVeSWpSXmKPExsUixCmqrXvuBVeAwfaJIhZ79nlZrJ7LY3H9\r
48         5kxmB2aPu6e5PHbOusvu8WzVLeYA5igum5TUnMyy1CJ9uwSujJfrWtgKWjQrzvZ+Zm5g/KLQ\r
49         xcjJISFgIrHi8VF2CFtM4sK99WxdjFwcQgL7GCXu3n7CBOFsYJS4enIllPOISaK1fREjhDOX\r
50         UWLG9YesIP1sAhoS2/YvZwSxRQSkJXbenQ0WZxawlPjeeg8sLgxk7944B8xmEVCVmL1/KpjN\r
51         K2AvserdfDaIO+Qlnt7vA7M5BRwlVtw8ywJiCwk4SGz70ME6gZF/ASPDKkbZlNwq3dzEzJzi\r
52         1GTd4uTEvLzUIl1zvdzMEr3UlNJNjKDQYndR2cHYfEjpEKMAB6MSD6+lEleAEGtiWXFl7iFG\r
53         SQ4mJVHevvtAIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8m04D5XhTEiurUovyYVLSHCxK4rzX\r
54         U276CwmkJ5akZqemFqQWwWRlODiUJHjdgTEkJFiUmp5akZaZU4KQZuLgBBnOAzQ8GKSGt7gg\r
55         Mbc4Mx0if4pRl+Paw1u3GIVY8vLzUqXEee1AigRAijJK8+DmwFLCK0ZxoLeEeQ1AqniA6QRu\r
56         0iugJUxAS6SzwJaUJCKkpBoYhd/+l16aK1126qZE/kG5yxz1QZr5d+UkTu8UVH/H1jz1549l\r
57         L3zaHbKEWFW3qH/7GaJ/XH41x6WpP7j+nNTu+1C48/3vrZIhCTNV/DU3seU+OTyxeZuizy/f\r
58         CEm9ZQeWLZCKbyqwjv4pfT1QId7pwrFHcQvsmzyPHni35pH96YvXt21S8/wVrcRSnJFoqMVc\r
59         VJwIADDODqTkAgAA\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: Sat, 21 Jul 2012 17:37:22 -0000\r
73 \r
74 This version fixes several bugs found in the previous version.  I\r
75 replaced the insert-before-markers trick in\r
76 notmuch-search-update-result with direct point manipulation.  This\r
77 fixes the problem with authors getting unhidden when a result is\r
78 updated with point after the authors on the line (since it no longer\r
79 deletes the region with the invisibility overlay).  I also removed the\r
80 scrolling hack (which was partially necessitated by\r
81 insert-before-markers), so that archiving the last visible result will\r
82 properly scroll the buffer instead of jumping point to the middle of\r
83 the visible window.  As a result, the window may scroll when updating\r
84 a multiline result, however, it will scroll to show the entire result\r
85 (unlike an earlier version where it scrolled to cut off the result\r
86 because of an interaction with insert-before-markers).  Finally, I\r
87 fixed notmuch-search-last-thread so that it behaves like it did before\r
88 when there are no results, rather than failing with an obscure error.\r
89 \r
90 I also updated the customize documentation and NEWS to indicate that\r
91 multiline search results are considered experimental.\r
92 \r
93 Diff from v3:\r
94 \r
95 diff --git a/NEWS b/NEWS\r
96 index 7b33f0d..7b1f36c 100644\r
97 --- a/NEWS\r
98 +++ b/NEWS\r
99 @@ -25,7 +25,7 @@ The formatting of tags in search results can now be customized\r
100    `notmuch-search-result-format` would usually break tagging from\r
101    search-mode.  We no longer make assumptions about the format.\r
102  \r
103 -Multi-line search result formats are now supported\r
104 +Experimental support for multi-line search result formats\r
105  \r
106    It is now possible to embed newlines in\r
107    `notmuch-search-result-format` to make individual search results\r
108 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
109 index ec760dc..fd1836f 100644\r
110 --- a/emacs/notmuch.el\r
111 +++ b/emacs/notmuch.el\r
112 @@ -70,12 +70,12 @@\r
113  For example:\r
114         (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)\r
115                                              \(\"subject\" . \"%s\"\)\)\)\r
116 -Line breaks are permitted in format strings.  Note that a line\r
117 -break at the end of an \"authors\" field will get elided if the\r
118 -authors list is long; place it instead at the beginning of the\r
119 -following field.  To enter a line break when setting this\r
120 -variable with setq, use \\n.  To enter a line break in customize,\r
121 -press \\[quoted-insert] C-j."\r
122 +Line breaks are permitted in format strings (though this is\r
123 +currently experimental).  Note that a line break at the end of an\r
124 +\"authors\" field will get elided if the authors list is long;\r
125 +place it instead at the beginning of the following field.  To\r
126 +enter a line break when setting this variable with setq, use \\n.\r
127 +To enter a line break in customize, press \\[quoted-insert] C-j."\r
128    :type '(alist :key-type (string) :value-type (string))\r
129    :group 'notmuch-search)\r
130  \r
131 @@ -310,7 +310,8 @@ For a mouse binding, return nil."\r
132    (interactive)\r
133    (goto-char (point-max))\r
134    (forward-line -2)\r
135 -  (goto-char (notmuch-search-result-beginning)))\r
136 +  (let ((beg (notmuch-search-result-beginning)))\r
137 +    (when beg (goto-char beg))))\r
138  \r
139  (defun notmuch-search-first-thread ()\r
140    "Select the first thread in the search results."\r
141 @@ -599,30 +600,31 @@ This function advances the next thread when finished."\r
142  \r
143  (defun notmuch-search-update-result (result &optional pos)\r
144    "Replace the result object of the thread at POS (or point) by\r
145 -RESULT and redraw it."\r
146 +RESULT and redraw it.\r
147 +\r
148 +This will keep point in a reasonable location.  However, if there\r
149 +are enclosing save-excursions and the saved point is in the\r
150 +result being updated, the point will be restored to the beginning\r
151 +of the result."\r
152    (let ((start (notmuch-search-result-beginning pos))\r
153         (end (notmuch-search-result-end pos))\r
154         (init-point (point))\r
155 -       (init-start (window-start))\r
156         (inhibit-read-only t))\r
157      ;; Delete the current thread\r
158      (delete-region start end)\r
159      ;; Insert the updated thread\r
160      (notmuch-search-show-result result start)\r
161 -    ;; There may have been markers pointing into the text we just\r
162 -    ;; replaced.  For the most part, there's nothing we can do about\r
163 -    ;; this, but we can fix markers that were at point (which includes\r
164 -    ;; point itself and any save-excursions for which point hasn't\r
165 -    ;; moved) by re-inserting the text that should come before point\r
166 -    ;; before markers.\r
167 +    ;; If point was inside the old result, make an educated guess\r
168 +    ;; about where to place it now.  Unfortunately, this won't work\r
169 +    ;; with save-excursion (or any other markers that would be nice to\r
170 +    ;; preserve, such as the window start), but there's nothing we can\r
171 +    ;; do about that without a way to retrieve markers in a region.\r
172      (when (and (>= init-point start) (<= init-point end))\r
173        (let* ((new-end (notmuch-search-result-end start))\r
174              (new-point (if (= init-point end)\r
175                             new-end\r
176                           (min init-point (- new-end 1)))))\r
177 -       (insert-before-markers (delete-and-extract-region start new-point))))\r
178 -    ;; We also may have shifted the window scroll.  Fix it.\r
179 -    (set-window-start (selected-window) init-start)))\r
180 +       (goto-char new-point)))))\r
181  \r
182  (defun notmuch-search-process-sentinel (proc msg)\r
183    "Add a message to let user know when \"notmuch search\" exits"\r
184 \r
185 \r
186 \r