Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / c3 / ad87da9899e5935d1c53430a7acce95f36a828
1 Return-Path: <dmitry.kurochkin@gmail.com>\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 B1EBA431FD0\r
6         for <notmuch@notmuchmail.org>; Fri, 27 May 2011 18:28:56 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id JKyN67Q5y9V6 for <notmuch@notmuchmail.org>;\r
17         Fri, 27 May 2011 18:28:56 -0700 (PDT)\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
19         [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id C8959431FB6\r
22         for <notmuch@notmuchmail.org>; Fri, 27 May 2011 18:28:55 -0700 (PDT)\r
23 Received: by fxm8 with SMTP id 8so1788845fxm.26\r
24         for <notmuch@notmuchmail.org>; Fri, 27 May 2011 18:28:54 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=domainkey-signature:from:to:subject:in-reply-to:references\r
27         :user-agent:date:message-id:mime-version:content-type;\r
28         bh=aXSDq5M1BIGcE6EhAz1Lgp0y2wlM2vY8rsqKoNg9sE4=;\r
29         b=k5kaQYOgTq0hlfchK1IkeX/ZWsMVnbHTUItfFm9F39BkPvRSfvHCj4vtxsjpr1SonS\r
30         gYK/UI3oZsK6HKU4g37a5xtLpWse17eKiGuzn/bituff2J8zwO3WKu7KTjMyhQmW897z\r
31         48+p2Xk35ocuMMWMPx57KS5orBGUBVG1SlNng=\r
32 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
33         h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
34         :mime-version:content-type;\r
35         b=t+t8YjIVnwbeg15KFEmuOS2HWRk/hIQwfBAObfiRAVvx0AyFh/VsXMRj+ubTtXdGUn\r
36         L23z0ld/OsqeqwLEJdVnL8kIX6styHh6jaifCpMstGaFSLk934h7WJCDqfaXw4PsSwot\r
37         ZigOlEkTpxXllmkTdUHUOrGClGMP+4CL28ARo=\r
38 Received: by 10.223.7.8 with SMTP id b8mr1410766fab.19.1306546134557;\r
39         Fri, 27 May 2011 18:28:54 -0700 (PDT)\r
40 Received: from localhost ([91.144.186.21])\r
41         by mx.google.com with ESMTPS id e16sm22463fak.17.2011.05.27.18.28.52\r
42         (version=TLSv1/SSLv3 cipher=OTHER);\r
43         Fri, 27 May 2011 18:28:53 -0700 (PDT)\r
44 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
45 To: notmuch@notmuchmail.org\r
46 Subject: Re: [PATCH 2/2] Workaround for Emacs bug #8721.\r
47 In-Reply-To: <874o4hp205.fsf@gmail.com>\r
48 References: <1306361416-5019-1-git-send-email-dmitry.kurochkin@gmail.com>\r
49         <1306445915-9474-1-git-send-email-dmitry.kurochkin@gmail.com>\r
50         <1306445915-9474-2-git-send-email-dmitry.kurochkin@gmail.com>\r
51         <874o4hp205.fsf@gmail.com>\r
52 User-Agent: Notmuch/0.5-216-g0104e23 (http://notmuchmail.org) Emacs/23.3.1\r
53         (x86_64-pc-linux-gnu)\r
54 Date: Sat, 28 May 2011 05:29:17 +0400\r
55 Message-ID: <871uzjpq8i.fsf@gmail.com>\r
56 MIME-Version: 1.0\r
57 Content-Type: multipart/mixed; boundary="=-=-="\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Sat, 28 May 2011 01:28:56 -0000\r
71 \r
72 --=-=-=\r
73 \r
74 This is an amended patch which uses `isearch-range-invisible' from Emacs\r
75 trunk r104393 (includes the second patch from #8721).\r
76 \r
77 Regards,\r
78   Dmitry\r
79 \r
80 --=-=-=\r
81 Content-Type: text/x-diff\r
82 Content-Disposition: inline;\r
83  filename=0001-Workaround-for-Emacs-bug-8721.patch\r
84 \r
85 >From d56f2c308c995639aad04f0e5388b52912e603b0 Mon Sep 17 00:00:00 2001\r
86 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
87 Date: Fri, 27 May 2011 01:35:09 +0400\r
88 Subject: [PATCH] Workaround for Emacs bug #8721.\r
89 \r
90 The patch adds `notmuch-isearch-range-invisible' function which\r
91 is the same as `isearch-range-invisible' but with fixed Emacs bug\r
92  #8721.  Advice added for `isearch-range-invisible' which calls\r
93 `notmuch-isearch-range-invisible' instead of the original\r
94 `isearch-range-invisible' when in `notmuch-show-mode'.\r
95 ---\r
96  emacs/notmuch-wash.el |   67 +++++++++++++++++++++++++++++++++++++++++++++++++\r
97  1 files changed, 67 insertions(+), 0 deletions(-)\r
98 \r
99 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
100 index 992fa8f..e046d62 100644\r
101 --- a/emacs/notmuch-wash.el\r
102 +++ b/emacs/notmuch-wash.el\r
103 @@ -298,4 +298,71 @@ for error."\r
104  \r
105  ;;\r
106  \r
107 +;; Temporary workaround for Emacs bug #8721\r
108 +;; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8721\r
109 +\r
110 +(defun notmuch-isearch-range-invisible (beg end)\r
111 +  "Same as `isearch-range-invisible' but with fixed Emacs bug #8721."\r
112 +  (when (/= beg end)\r
113 +    ;; Check that invisibility runs up to END.\r
114 +    (save-excursion\r
115 +      (goto-char beg)\r
116 +      (let (;; can-be-opened keeps track if we can open some overlays.\r
117 +           (can-be-opened (eq search-invisible 'open))\r
118 +           ;; the list of overlays that could be opened\r
119 +           (crt-overlays nil))\r
120 +       (when (and can-be-opened isearch-hide-immediately)\r
121 +         (isearch-close-unnecessary-overlays beg end))\r
122 +       ;; If the following character is currently invisible,\r
123 +       ;; skip all characters with that same `invisible' property value.\r
124 +       ;; Do that over and over.\r
125 +       (while (and (< (point) end) (invisible-p (point)))\r
126 +         (if (invisible-p (get-text-property (point) 'invisible))\r
127 +             (progn\r
128 +               (goto-char (next-single-property-change (point) 'invisible\r
129 +                                                       nil end))\r
130 +               ;; if text is hidden by an `invisible' text property\r
131 +               ;; we cannot open it at all.\r
132 +               (setq can-be-opened nil))\r
133 +           (when can-be-opened\r
134 +             (let ((overlays (overlays-at (point)))\r
135 +                   ov-list\r
136 +                   o\r
137 +                   invis-prop)\r
138 +               (while overlays\r
139 +                 (setq o (car overlays)\r
140 +                       invis-prop (overlay-get o 'invisible))\r
141 +                 (if (invisible-p invis-prop)\r
142 +                     (if (overlay-get o 'isearch-open-invisible)\r
143 +                         (setq ov-list (cons o ov-list))\r
144 +                       ;; We found one overlay that cannot be\r
145 +                       ;; opened, that means the whole chunk\r
146 +                       ;; cannot be opened.\r
147 +                       (setq can-be-opened nil)))\r
148 +                 (setq overlays (cdr overlays)))\r
149 +               (if can-be-opened\r
150 +                   ;; It makes sense to append to the open\r
151 +                   ;; overlays list only if we know that this is\r
152 +                   ;; t.\r
153 +                   (setq crt-overlays (append ov-list crt-overlays)))))\r
154 +           (goto-char (next-overlay-change (point)))))\r
155 +       ;; See if invisibility reaches up thru END.\r
156 +       (if (>= (point) end)\r
157 +           (if (and can-be-opened (consp crt-overlays))\r
158 +               (progn\r
159 +                 (setq isearch-opened-overlays\r
160 +                       (append isearch-opened-overlays crt-overlays))\r
161 +                 (mapc 'isearch-open-overlay-temporary crt-overlays)\r
162 +                 nil)\r
163 +             (setq isearch-hidden t)))))))\r
164 +\r
165 +(defadvice isearch-range-invisible (around notmuch-isearch-range-invisible-advice activate)\r
166 +  "Call `notmuch-isearch-range-invisible' instead of the original\r
167 +`isearch-range-invisible' when in `notmuch-show-mode' mode."\r
168 +  (if (eq major-mode 'notmuch-show-mode)\r
169 +      (setq ad-return-value (notmuch-isearch-range-invisible beg end))\r
170 +    ad-do-it))\r
171 +\r
172 +;;\r
173 +\r
174  (provide 'notmuch-wash)\r
175 -- \r
176 1.7.5.1\r
177 \r
178 \r
179 --=-=-=--\r