Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / b9 / c15fe6ef45c105b7487e14063f7ed27336bd02
1 Return-Path: <sandra.snan@handgranat.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 B68D7404947\r
6         for <notmuch@notmuchmail.org>; Tue, 16 Mar 2010 12:51:33 -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: -2.395\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.395 tagged_above=-999 required=5 tests=[AWL=0.204,\r
12         BAYES_00=-2.599] autolearn=ham\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 ZU5sqXHv3VNJ for <notmuch@notmuchmail.org>;\r
16         Tue, 16 Mar 2010 12:51:32 -0700 (PDT)\r
17 Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com\r
18  [74.125.82.53])        by olra.theworths.org (Postfix) with ESMTP id 364AD404946       for\r
19  <notmuch@notmuchmail.org>; Tue, 16 Mar 2010 12:51:32 -0700 (PDT)\r
20 Received: by wwi17 with SMTP id 17so229073wwi.26\r
21         for <notmuch@notmuchmail.org>; Tue, 16 Mar 2010 12:51:31 -0700 (PDT)\r
22 Received: by 10.216.86.19 with SMTP id v19mr3860wee.236.1268769090810;\r
23         Tue, 16 Mar 2010 12:51:30 -0700 (PDT)\r
24 Received: from ellen.idiomdrottning.org.handgranat.org\r
25         (c83-251-93-216.bredband.comhem.se [83.251.93.216])\r
26         by mx.google.com with ESMTPS id 15sm20721ewy.4.2010.03.16.12.51.30\r
27         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
28         Tue, 16 Mar 2010 12:51:30 -0700 (PDT)\r
29 Message-ID: <4b9fe142.0f67f10a.268d.0312@mx.google.com>\r
30 Date: Tue, 16 Mar 2010 20:52:53 +0100\r
31 From: Sandra Snan <sandra.snan@handgranat.org>\r
32 To: notmuch@notmuchmail.org\r
33 User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.9\r
34         (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.1 (x86_64-pc-linux-gnu)\r
35         MULE/6.0 (HANACHIRUSATO)\r
36 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka")\r
37 Content-Type: text/plain; charset=UTF-8\r
38 Content-Transfer-Encoding: quoted-printable\r
39 Subject: [notmuch] [PATCH] To use compose-mail\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Tue, 16 Mar 2010 19:51:33 -0000\r
53 \r
54 As I wrote in the other mail, Emacs has an interface called compose-mail wh=\r
55 ich uses whatever mailing mode that you=E2=80=99ve selected in mail-user-ag=\r
56 ent\r
57 so if you like the message mode that=E2=80=99s been hard-coded into notmuch=\r
58 .el, (setq mail-user-agent 'message-user-agent) and this will use that.\r
59 \r
60 This is a simpler patch that uses as much of the output of notmuch reply as=\r
61  possible, at the expense of emacs more flexible hooks and citing. Both of =\r
62 the patches (unfortunately) still just call message-modes signature functio=\r
63 n without one of the standard hooks and wrappers, because I haven=E2=80=99t=\r
64  looked into that yet.\r
65 \r
66 Sandra\r
67 \r
68 Signed-off-by: Sandra Snan <sandra.snan@handgranat.org>\r
69 ---\r
70  emacs/notmuch.el |   66 +++++++++++++++++++++++++++++++++++++++++++-------=\r
71 ---\r
72  1 files changed, 53 insertions(+), 13 deletions(-)\r
73 \r
74 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
75 index 117a365..68e2d43 100644\r
76 --- a/emacs/notmuch.el\r
77 +++ b/emacs/notmuch.el\r
78 @@ -49,7 +49,7 @@\r
79 =20\r
80  (require 'cl)\r
81  (require 'mm-view)\r
82 -(require 'message)\r
83 +(require 'message) ; not sure if this is needed now\r
84 =20\r
85  (defvar notmuch-show-stash-map\r
86    (let ((map (make-sparse-keymap)))\r
87 @@ -76,7 +76,7 @@\r
88      (define-key map (kbd "M-TAB") 'notmuch-show-previous-button)\r
89      (define-key map (kbd "TAB") 'notmuch-show-next-button)\r
90      (define-key map "s" 'notmuch-search)\r
91 -    (define-key map "m" 'message-mail)\r
92 +    (define-key map "m" 'compose-mail)\r
93      (define-key map "f" 'notmuch-show-forward-current)\r
94      (define-key map "r" 'notmuch-show-reply)\r
95      (define-key map "|" 'notmuch-show-pipe-message)\r
96 @@ -435,16 +435,56 @@ buffer."\r
97        mm-handle (> (notmuch-count-attachments mm-handle) 1))))\r
98    (message "Done"))\r
99 =20\r
100 -(defun notmuch-reply (query-string)\r
101 -  (switch-to-buffer (generate-new-buffer "notmuch-draft"))\r
102 -  (call-process notmuch-command nil t nil "reply" query-string)\r
103 -  (message-insert-signature)\r
104 +\r
105 +(defun jump-to-end-of-header ()\r
106 +  (re-search-forward "^[^:]*.: \\|^$")\r
107 +  (beginning-of-line)\r
108 +  (backward-char)\r
109 +  (point))\r
110 +\r
111 +(defun notmuch-regex-header (re)\r
112    (goto-char (point-min))\r
113 -  (if (re-search-forward "^$" nil t)\r
114 -      (progn\r
115 -       (insert "--text follows this line--")\r
116 -       (forward-line)))\r
117 -  (message-mode))\r
118 +  (if (re-search-forward re nil t)\r
119 +      (buffer-substring-no-properties (point) (jump-to-end-of-header))\r
120 +    ""))\r
121 +\r
122 +(defun notmuch-other-headers (al)\r
123 +  (beginning-of-line)\r
124 +  (if (eq (point-at-bol) (point-at-eol))\r
125 +      al\r
126 +    (if (re-search-forward "^[^:]*.: \\|^$" nil t)\r
127 +       (notmuch-other-headers\r
128 +         (let ((header (buffer-substring-no-properties (point-at-bol) (- (point)=\r
129  2)))\r
130 +               (header-value (buffer-substring-no-properties (point) (jump-to-end-of-he=\r
131 ader))))\r
132 +           (forward-char)\r
133 +           (if (or (string=3D "To" header) (string=3D "Subject" header))\r
134 +               al\r
135 +             (acons\r
136 +              header\r
137 +              header-value\r
138 +              al))))\r
139 +      al)))\r
140 +\r
141 +(defun notmuch-reply (query-string)\r
142 +  (let ((body\r
143 +        (save-excursion\r
144 +          (let ((filename (notmuch-show-get-filename)))\r
145 +            (with-temp-buffer\r
146 +              (insert-file-contents filename)\r
147 +              (set-mark (point-max))\r
148 +              (goto-char (point-min))\r
149 +              (run-hooks 'mail-citation-hook)\r
150 +              (message-insert-signature) ;; FIXME is there a standard hook for s=\r
151 ignatures, too?\r
152 +              (buffer-substring (point-min) (point-max)))))))\r
153 +    (with-temp-buffer\r
154 +      (call-process notmuch-command nil t nil "reply" query-string)\r
155 +      (compose-mail\r
156 +       (notmuch-regex-header "^To: ")\r
157 +       (notmuch-regex-header "^Subject: ")\r
158 +       (progn (goto-char (point-min))\r
159 +             (notmuch-other-headers '())))\r
160 +      (goto-char (point-max))\r
161 +      (insert body))))\r
162 =20\r
163  (defun notmuch-show-reply ()\r
164    "Begin composing a reply to the current message in a new buffer."\r
165 @@ -1229,7 +1269,7 @@ matching this search term are shown if non-nil. "\r
166      (define-key map "p" 'notmuch-search-previous-thread)\r
167      (define-key map "n" 'notmuch-search-next-thread)\r
168      (define-key map "r" 'notmuch-search-reply-to-thread)\r
169 -    (define-key map "m" 'message-mail)\r
170 +    (define-key map "m" 'compose-mail)\r
171      (define-key map "s" 'notmuch-search)\r
172      (define-key map "o" 'notmuch-search-toggle-order)\r
173      (define-key map "=3D" 'notmuch-search-refresh-view)\r
174 @@ -1651,7 +1691,7 @@ current search results AND that are tagged with the g=\r
175 iven tag."\r
176      (define-key map "?" 'notmuch-help)\r
177      (define-key map "x" 'kill-this-buffer)\r
178      (define-key map "q" 'kill-this-buffer)\r
179 -    (define-key map "m" 'message-mail)\r
180 +    (define-key map "m" 'compose-mail)\r
181      (define-key map "e" 'notmuch-folder-show-empty-toggle)\r
182      (define-key map ">" 'notmuch-folder-last)\r
183      (define-key map "<" 'notmuch-folder-first)\r
184 --=20\r
185 1.7.0\r
186 \r