Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 43 / 3bd9098e0fde4550a596d6417ab8aefaa654e4
1 Return-Path: <jani@nikula.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 0DC6F431FD7\r
6         for <notmuch@notmuchmail.org>; Tue, 27 Aug 2013 12:50:53 -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 MxXRRtpDy0HN for <notmuch@notmuchmail.org>;\r
16         Tue, 27 Aug 2013 12:50:45 -0700 (PDT)\r
17 Received: from mail-ea0-f175.google.com (mail-ea0-f175.google.com\r
18         [209.85.215.175]) (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 535FB431FD6\r
21         for <notmuch@notmuchmail.org>; Tue, 27 Aug 2013 12:50:45 -0700 (PDT)\r
22 Received: by mail-ea0-f175.google.com with SMTP id m14so2494443eaj.34\r
23         for <notmuch@notmuchmail.org>; Tue, 27 Aug 2013 12:50:44 -0700 (PDT)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=google.com; s=20120113;\r
26         h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
27         bh=WjMRj0pWVG0gQQlHymVw/oSv6o9/qOsruuVaZuswOv8=;\r
28         b=ovFL+ewFjOV1w8N0izGk9AVvWkfxqxUK/w5FIVeXJCSA9vRrbferKNThLPTPbw93MX\r
29         s0TqbbJV3bn5y5boCDSfTyB94L2uJgQVxLdmge63F55GHj3o2DcuvhLGoFkGzCSzQZI2\r
30         KYjRDl3wcDxN4STJQXkYmjPNq9ZAZzV14nyJ2qugRD03mp/aB1tralyMZv4/zqn6VPhS\r
31         uAbxRuecHl6VXj/aT5sXFa+CwNvHlOOIZX5hslQEMZGlAdy+cyCPrYZtfnYh+KwXIG2T\r
32         kYeDgAgSlBstnPSTev7E9i/OopvTXTdww98nXpKdx2vsQjy6pM5nneVMNUG0RhaC4J7Z\r
33         BpRQ==\r
34 X-Gm-Message-State:\r
35  ALoCoQnOksbA2Vj+oCCSWxHtM4Y/fGyg0ceMlF9nXiRYYhJKARsiAo4LlH27pNsMy0IMbnm6pdd0\r
36 X-Received: by 10.15.99.72 with SMTP id bk48mr37318155eeb.22.1377633042770;\r
37         Tue, 27 Aug 2013 12:50:42 -0700 (PDT)\r
38 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
39         [88.195.111.91])\r
40         by mx.google.com with ESMTPSA id f49sm31586567eec.7.1969.12.31.16.00.00\r
41         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
42         Tue, 27 Aug 2013 12:50:41 -0700 (PDT)\r
43 From: Jani Nikula <jani@nikula.org>\r
44 To: notmuch@notmuchmail.org\r
45 Subject: [PATCH v2] emacs: insert quotable parts in reply as they are\r
46         displayed in show view\r
47 Date: Tue, 27 Aug 2013 22:50:44 +0300\r
48 Message-Id: <1377633044-22044-1-git-send-email-jani@nikula.org>\r
49 X-Mailer: git-send-email 1.7.10.4\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Tue, 27 Aug 2013 19:50:53 -0000\r
63 \r
64 In reply, insert quotable parts using notmuch-show-insert-bodypart\r
65 instead of calling notmuch-mm-display-part-inline directly to render\r
66 the quoted parts as they are rendered in show view.\r
67 \r
68 The notable change is that replies to text/calendar parts quote the\r
69 pretty printed output of icalendar-import-buffer rather than the ugly\r
70 raw vcalendar.\r
71 ---\r
72  emacs/notmuch-mua.el  |   13 ++++++++++---\r
73  emacs/notmuch-show.el |   18 +++++++++++++-----\r
74  2 files changed, 23 insertions(+), 8 deletions(-)\r
75 \r
76 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
77 index 2baae5f..c3aca80 100644\r
78 --- a/emacs/notmuch-mua.el\r
79 +++ b/emacs/notmuch-mua.el\r
80 @@ -28,6 +28,8 @@\r
81  \r
82  (eval-when-compile (require 'cl))\r
83  \r
84 +(declare-function notmuch-show-insert-bodypart "notmuch-show" (msg part depth &optional hide))\r
85 +\r
86  ;;\r
87  \r
88  (defcustom notmuch-mua-send-hook '(notmuch-mua-message-send-hook)\r
89 @@ -130,9 +132,11 @@ list."\r
90  (defun notmuch-mua-insert-quotable-part (message part)\r
91    (save-restriction\r
92      (narrow-to-region (point) (point))\r
93 -    (notmuch-mm-display-part-inline message part (plist-get part :id)\r
94 -                                   (plist-get part :content-type)\r
95 -                                   notmuch-show-process-crypto)\r
96 +    ;; We don't want hooks, such as notmuch-wash-*, to be run on the\r
97 +    ;; quotable part.\r
98 +    (let ((notmuch-show-insert-text/plain-hook nil))\r
99 +      ;; Show the part but do not add buttons.\r
100 +      (notmuch-show-insert-bodypart message part 0 'no-buttons))\r
101      (goto-char (point-max))))\r
102  \r
103  ;; There is a bug in emacs 23's message.el that results in a newline\r
104 @@ -219,6 +223,9 @@ list."\r
105    (goto-char (point-max))\r
106    (push-mark)\r
107    (message-goto-body)\r
108 +\r
109 +  ;; Display message from the beginning if possible.\r
110 +  (recenter (- (line-number-at-pos) 1))\r
111    (set-buffer-modified-p nil))\r
112  \r
113  (defun notmuch-mua-forward-message ()\r
114 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
115 index 2896aae..904b98e 100644\r
116 --- a/emacs/notmuch-show.el\r
117 +++ b/emacs/notmuch-show.el\r
118 @@ -844,7 +844,11 @@ message at DEPTH in the current thread."\r
119  (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
120    "Insert the body part PART at depth DEPTH in the current thread.\r
121  \r
122 -If HIDE is non-nil then initially hide this part."\r
123 +HIDE determines whether to show or hide the part and the button\r
124 +as follows: If HIDE is nil, show the part and the button. If HIDE\r
125 +is t, hide the part initially and show the button. If HIDE is\r
126 +'no-buttons, show the part but do not add any buttons (this is\r
127 +useful for quoting in replies)."\r
128  \r
129    (let* ((content-type (downcase (plist-get part :content-type)))\r
130          (mime-type (or (and (string= content-type "application/octet-stream")\r
131 @@ -854,15 +858,19 @@ If HIDE is non-nil then initially hide this part."\r
132                         content-type))\r
133          (nth (plist-get part :id))\r
134          (beg (point))\r
135 -        ;; We omit the part button for the first (or only) part if this is text/plain.\r
136 -        (button (unless (and (string= mime-type "text/plain") (<= nth 1))\r
137 +        ;; Hide the part initially if HIDE is t.\r
138 +        (show-part (not (equal hide t)))\r
139 +        ;; We omit the part button for the first (or only) part if\r
140 +        ;; this is text/plain, or HIDE is 'no-buttons.\r
141 +        (button (unless (or (equal hide 'no-buttons)\r
142 +                            (and (string= mime-type "text/plain") (<= nth 1)))\r
143                    (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
144          (content-beg (point)))\r
145  \r
146      ;; Store the computed mime-type for later use (e.g. by attachment handlers).\r
147      (plist-put part :computed-type mime-type)\r
148  \r
149 -    (if (not hide)\r
150 +    (if show-part\r
151          (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button)\r
152        (button-put button :notmuch-lazy-part\r
153                    (list msg part mime-type nth depth button)))\r
154 @@ -875,7 +883,7 @@ If HIDE is non-nil then initially hide this part."\r
155        (insert "\n"))\r
156      ;; We do not create the overlay for hidden (lazy) parts until\r
157      ;; they are inserted.\r
158 -    (if (not hide)\r
159 +    (if show-part\r
160         (notmuch-show-create-part-overlays button content-beg (point))\r
161        (save-excursion\r
162         (notmuch-show-toggle-part-invisibility button)))\r
163 -- \r
164 1.7.10.4\r
165 \r