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 37131431FBF
\r
6 for <notmuch@notmuchmail.org>; Fri, 3 Feb 2012 23:38:08 -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 bxOaV2hPmw1a for <notmuch@notmuchmail.org>;
\r
17 Fri, 3 Feb 2012 23:38:06 -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 A78BA431FBD
\r
22 for <notmuch@notmuchmail.org>; Fri, 3 Feb 2012 23:38:01 -0800 (PST)
\r
23 Received: by mail-bk0-f53.google.com with SMTP id 11so4129597bke.26
\r
24 for <notmuch@notmuchmail.org>; Fri, 03 Feb 2012 23:38:01 -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=aapfVS/zekS+J/nz9YvJRaJhbTb24pMJyTWE1Rky5Bs=;
\r
28 b=Y0D3fdpe8TGR3I81aQPAxt08p0+p5F3PTBMhIjtZaRKGL/QFQAr7b/Xm4e/hTHd2HN
\r
29 l6bs9c1C3Rjew1h7/UPtv2sWebmG8Fk2e4ejUjMVjmX6CUVnqnjCTxFJf3kPffe+tNp0
\r
30 D0+mvIgFFPLes1yUr+qoHLj7IrlSgdoLI62UM=
\r
31 Received: by 10.204.128.202 with SMTP id l10mr4817540bks.116.1328341081326;
\r
32 Fri, 03 Feb 2012 23:38:01 -0800 (PST)
\r
33 Received: from localhost ([91.144.186.21])
\r
34 by mx.google.com with ESMTPS id 20sm23921774bkr.0.2012.02.03.23.38.00
\r
35 (version=TLSv1/SSLv3 cipher=OTHER);
\r
36 Fri, 03 Feb 2012 23:38:00 -0800 (PST)
\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH v2 2/2] emacs: fix `notmuch-wash-region-to-button' to work at
\r
41 Date: Sat, 4 Feb 2012 11:36:37 +0400
\r
42 Message-Id: <1328340997-29004-3-git-send-email-dmitry.kurochkin@gmail.com>
\r
43 X-Mailer: git-send-email 1.7.9
\r
44 In-Reply-To: <1328340997-29004-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
45 References: <1327926286-16680-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
46 <1328340997-29004-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
47 X-BeenThere: notmuch@notmuchmail.org
\r
48 X-Mailman-Version: 2.1.13
\r
50 List-Id: "Use and development of the notmuch mail system."
\r
51 <notmuch.notmuchmail.org>
\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
55 List-Post: <mailto:notmuch@notmuchmail.org>
\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
59 X-List-Received-Date: Sat, 04 Feb 2012 07:38:08 -0000
\r
61 `Notmuch-wash-region-to-button' is the function that creates hidden
\r
62 regions with buttons for signatures, citations and original messages.
\r
63 Before the change, it did not work correctly if the to-be-hidden
\r
64 region started at the beginning of a message: the visibility toggle
\r
65 button was hidden as well. The patch fixes this. There are two parts
\r
68 * Use `insert-before-markers' instead of `insert' for creating the
\r
69 button, so that it does not get added to the hidden overlay.
\r
71 * Stop using PREFIX argument for adding a newline before the button.
\r
72 The newline should not be added before a button at the beginning of
\r
75 The corresponding test is fixed now.
\r
77 emacs/notmuch-wash.el | 24 ++++++++++++++----------
\r
78 test/emacs-show | 1 -
\r
79 2 files changed, 14 insertions(+), 11 deletions(-)
\r
81 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
\r
82 index 67143e5..56981d0 100644
\r
83 --- a/emacs/notmuch-wash.el
\r
84 +++ b/emacs/notmuch-wash.el
\r
85 @@ -136,12 +136,13 @@ collapse the remaining lines into a button.")
\r
86 (lines-count (count-lines (overlay-start overlay) (overlay-end overlay))))
\r
87 (format label-format lines-count)))
\r
89 -(defun notmuch-wash-region-to-button (msg beg end type prefix)
\r
90 +(defun notmuch-wash-region-to-button (msg beg end type &optional prefix)
\r
91 "Auxiliary function to do the actual making of overlays and buttons
\r
93 BEG and END are buffer locations. TYPE should a string, either
\r
94 -\"citation\" or \"signature\". PREFIX is some arbitrary text to
\r
95 -insert before the button, probably for indentation."
\r
96 +\"citation\" or \"signature\". Optional PREFIX is some arbitrary
\r
97 +text to insert before the button, probably for indentation. Note
\r
98 +that PREFIX should not include a newline."
\r
100 ;; This uses some slightly tricky conversions between strings and
\r
101 ;; symbols because of the way the button code works. Note that
\r
102 @@ -160,12 +161,15 @@ insert before the button, probably for indentation."
\r
103 (overlay-put overlay 'type type)
\r
104 (goto-char (1+ end))
\r
106 - (goto-char (1- beg))
\r
108 - (insert-button (notmuch-wash-button-label overlay)
\r
111 + (insert-before-markers prefix))
\r
112 + (let ((button-beg (point)))
\r
113 + (insert-before-markers (notmuch-wash-button-label overlay) "\n")
\r
114 + (make-button button-beg (1- (point))
\r
115 'invisibility-spec invis-spec
\r
117 - :type button-type))))
\r
118 + :type button-type)))))
\r
120 (defun notmuch-wash-excerpt-citations (msg depth)
\r
121 "Excerpt citations and up to one signature."
\r
122 @@ -177,7 +181,7 @@ insert before the button, probably for indentation."
\r
123 (msg-end (point-max))
\r
124 (msg-lines (count-lines msg-start msg-end)))
\r
125 (notmuch-wash-region-to-button
\r
126 - msg msg-start msg-end "original" "\n")))
\r
127 + msg msg-start msg-end "original")))
\r
128 (while (and (< (point) (point-max))
\r
129 (re-search-forward notmuch-wash-citation-regexp nil t))
\r
130 (let* ((cite-start (match-beginning 0))
\r
131 @@ -194,7 +198,7 @@ insert before the button, probably for indentation."
\r
132 (forward-line (- notmuch-wash-citation-lines-suffix))
\r
133 (notmuch-wash-region-to-button
\r
134 msg hidden-start (point-marker)
\r
135 - "citation" "\n")))))
\r
137 (if (and (not (eobp))
\r
138 (re-search-forward notmuch-wash-signature-regexp nil t))
\r
139 (let* ((sig-start (match-beginning 0))
\r
140 @@ -208,7 +212,7 @@ insert before the button, probably for indentation."
\r
141 (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
\r
142 (notmuch-wash-region-to-button
\r
143 msg sig-start-marker sig-end-marker
\r
144 - "signature" "\n"))))))
\r
145 + "signature"))))))
\r
149 diff --git a/test/emacs-show b/test/emacs-show
\r
150 index 9800575..5700d2e 100755
\r
151 --- a/test/emacs-show
\r
152 +++ b/test/emacs-show
\r
153 @@ -4,7 +4,6 @@ test_description="Testing emacs notmuch-show view"
\r
156 test_begin_subtest "Hiding Original Message region at beginning of a message"
\r
157 -test_subtest_known_broken
\r
158 message_id='OriginalMessageHiding.1@notmuchmail.org'
\r
160 [id]="$message_id" \
\r