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 411C941ED81
\r
6 for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 04:26:11 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 yXM8tcPiQJf5 for <notmuch@notmuchmail.org>;
\r
17 Mon, 30 Jan 2012 04:26:09 -0800 (PST)
\r
18 Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com
\r
19 [209.85.214.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 3ABA5429E54
\r
22 for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 04:26:05 -0800 (PST)
\r
23 Received: by mail-bk0-f53.google.com with SMTP id 11so1334291bke.26
\r
24 for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 04:26:04 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=from:to:subject:date:message-id:x-mailer:in-reply-to:references;
\r
27 bh=fqAnqCvQC2ewoLsKIaOU+SrpGYlVP7DRsx06mtWLLZs=;
\r
28 b=NSqsd8MiMUxcxiKa0+pyi18V+8FUeLVtKwTewbsAXXlvf7MaRwTCKB5u/SZRmfYbBl
\r
29 bUoHLbHrVyvje0727qz+hHbMudONJ9Zkd7t+ZmjhfQDRbMFeguumTr0cU1Xgy7Rn+ZPN
\r
30 ByU/ygRVBBTpTVYrqJ3DOjN5N9wbWstO7Zp0A=
\r
31 Received: by 10.204.151.218 with SMTP id d26mr8702346bkw.64.1327926364839;
\r
32 Mon, 30 Jan 2012 04:26:04 -0800 (PST)
\r
33 Received: from localhost ([91.144.186.21])
\r
34 by mx.google.com with ESMTPS id cz3sm37301847bkb.3.2012.01.30.04.26.03
\r
35 (version=TLSv1/SSLv3 cipher=OTHER);
\r
36 Mon, 30 Jan 2012 04:26:04 -0800 (PST)
\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH 2/2] emacs: fix `notmuch-wash-region-to-button' to work at
\r
41 Date: Mon, 30 Jan 2012 16:24:46 +0400
\r
42 Message-Id: <1327926286-16680-3-git-send-email-dmitry.kurochkin@gmail.com>
\r
43 X-Mailer: git-send-email 1.7.8.3
\r
44 In-Reply-To: <1327926286-16680-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
45 References: <1327926286-16680-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
46 X-BeenThere: notmuch@notmuchmail.org
\r
47 X-Mailman-Version: 2.1.13
\r
49 List-Id: "Use and development of the notmuch mail system."
\r
50 <notmuch.notmuchmail.org>
\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
54 List-Post: <mailto:notmuch@notmuchmail.org>
\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
58 X-List-Received-Date: Mon, 30 Jan 2012 12:26:11 -0000
\r
60 `Notmuch-wash-region-to-button' is the function that creates hidden
\r
61 regions with buttons for signatures, citations and original messages.
\r
62 Before the change, it did not work correctly if the to-be-hidden
\r
63 region started at the beginning of a message: the visibility toggle
\r
64 button was hidden as well. The patch fixes this. There are two parts
\r
67 * Use `insert-before-markers' instead of `insert' for creating the
\r
68 button, so that it does not get added to the hidden overlay.
\r
70 * Stop using PREFIX argument for adding a newline before the button.
\r
71 The newline should not be added before a button at the beginning of
\r
74 The corresponding test is fixed now.
\r
76 emacs/notmuch-wash.el | 24 ++++++++++++++----------
\r
77 test/emacs-show | 1 -
\r
78 2 files changed, 14 insertions(+), 11 deletions(-)
\r
80 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
\r
81 index 5c1e830..9d3d13f 100644
\r
82 --- a/emacs/notmuch-wash.el
\r
83 +++ b/emacs/notmuch-wash.el
\r
84 @@ -136,12 +136,13 @@ collapse the remaining lines into a button.")
\r
85 (lines-count (count-lines (overlay-start overlay) (overlay-end overlay))))
\r
86 (format label-format lines-count)))
\r
88 -(defun notmuch-wash-region-to-button (msg beg end type prefix)
\r
89 +(defun notmuch-wash-region-to-button (msg beg end type &optional prefix)
\r
90 "Auxiliary function to do the actual making of overlays and buttons
\r
92 BEG and END are buffer locations. TYPE should a string, either
\r
93 -\"citation\" or \"signature\". PREFIX is some arbitrary text to
\r
94 -insert before the button, probably for indentation."
\r
95 +\"citation\" or \"signature\". Optional PREFIX is some arbitrary
\r
96 +text to insert before the button, probably for indentation. Note
\r
97 +that PREFIX should not include a newline."
\r
99 ;; This uses some slightly tricky conversions between strings and
\r
100 ;; symbols because of the way the button code works. Note that
\r
101 @@ -160,12 +161,15 @@ insert before the button, probably for indentation."
\r
102 (overlay-put overlay 'type type)
\r
103 (goto-char (1+ end))
\r
105 - (goto-char (1- beg))
\r
107 - (insert-button (notmuch-wash-button-label overlay)
\r
110 + (insert-before-markers prefix))
\r
111 + (let ((button-beg (point)))
\r
112 + (insert-before-markers (notmuch-wash-button-label overlay) "\n")
\r
113 + (make-button button-beg (1- (point))
\r
114 'invisibility-spec invis-spec
\r
116 - :type button-type))))
\r
117 + :type button-type)))))
\r
119 (defun notmuch-wash-excerpt-citations (msg depth)
\r
120 "Excerpt citations and up to one signature."
\r
121 @@ -177,7 +181,7 @@ insert before the button, probably for indentation."
\r
122 (msg-end (point-max))
\r
123 (msg-lines (count-lines msg-start msg-end)))
\r
124 (notmuch-wash-region-to-button
\r
125 - msg msg-start msg-end "original" "\n")))
\r
126 + msg msg-start msg-end "original")))
\r
127 (while (and (< (point) (point-max))
\r
128 (re-search-forward notmuch-wash-citation-regexp nil t))
\r
129 (let* ((cite-start (match-beginning 0))
\r
130 @@ -194,7 +198,7 @@ insert before the button, probably for indentation."
\r
131 (forward-line (- notmuch-wash-citation-lines-suffix))
\r
132 (notmuch-wash-region-to-button
\r
133 msg hidden-start (point-marker)
\r
134 - "citation" "\n")))))
\r
136 (if (and (not (eobp))
\r
137 (re-search-forward notmuch-wash-signature-regexp nil t))
\r
138 (let* ((sig-start (match-beginning 0))
\r
139 @@ -208,7 +212,7 @@ insert before the button, probably for indentation."
\r
140 (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
\r
141 (notmuch-wash-region-to-button
\r
142 msg sig-start-marker sig-end-marker
\r
143 - "signature" "\n"))))))
\r
144 + "signature"))))))
\r
148 diff --git a/test/emacs-show b/test/emacs-show
\r
149 index 9800575..5700d2e 100755
\r
150 --- a/test/emacs-show
\r
151 +++ b/test/emacs-show
\r
152 @@ -4,7 +4,6 @@ test_description="Testing emacs notmuch-show view"
\r
155 test_begin_subtest "Hiding Original Message region at beginning of a message"
\r
156 -test_subtest_known_broken
\r
157 message_id='OriginalMessageHiding.1@notmuchmail.org'
\r
159 [id]="$message_id" \
\r