Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 2c / f6f8973b96148cab30e6333696a907b924b153
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 12F3A404954\r
6         for <notmuch@notmuchmail.org>; Wed, 17 Mar 2010 03:04:37 -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.442\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.442 tagged_above=-999 required=5 tests=[AWL=0.157,\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 3qJ9iIQL8wxE for <notmuch@notmuchmail.org>;\r
16         Wed, 17 Mar 2010 03:04:36 -0700 (PDT)\r
17 Received: from mail-ew0-f219.google.com (mail-ew0-f219.google.com\r
18         [209.85.219.219])\r
19         by olra.theworths.org (Postfix) with ESMTP id EB15A404946\r
20         for <notmuch@notmuchmail.org>; Wed, 17 Mar 2010 03:04:35 -0700 (PDT)\r
21 Received: by ewy19 with SMTP id 19so57801ewy.2\r
22         for <notmuch@notmuchmail.org>; Wed, 17 Mar 2010 03:04:35 -0700 (PDT)\r
23 Received: by 10.213.37.82 with SMTP id w18mr2276707ebd.97.1268820274896;\r
24         Wed, 17 Mar 2010 03:04:34 -0700 (PDT)\r
25 Received: from ellen.idiomdrottning.org.handgranat.org ([83.251.93.216])\r
26         by mx.google.com with ESMTPS id 16sm3942583ewy.3.2010.03.17.03.04.33\r
27         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
28         Wed, 17 Mar 2010 03:04:33 -0700 (PDT)\r
29 Message-ID: <4ba0a931.1067f10a.15c2.5e9f@mx.google.com>\r
30 Date: Wed, 17 Mar 2010 11:05:57 +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 References: <4b9fe142.0f67f10a.268d.0312@mx.google.com>\r
37 In-Reply-To: <4b9fe142.0f67f10a.268d.0312@mx.google.com>\r
38 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka")\r
39 Content-Type: text/plain; charset=UTF-8\r
40 Content-Transfer-Encoding: quoted-printable\r
41 Subject: Re: [notmuch] [PATCH] To use compose-mail\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Wed, 17 Mar 2010 10:04:37 -0000\r
55 \r
56 I <sandra.snan@handgranat.org> wrote earlier:\r
57 > As I wrote in the other mail, Emacs has an interface called compose-mail =\r
58 which uses whatever mailing mode that you=E2=80=99ve selected in mail-user-=\r
59 agent\r
60 > so if you like the message mode that=E2=80=99s been hard-coded into notmu=\r
61 ch.el, (setq mail-user-agent 'message-user-agent) and this will use that.\r
62 >=20\r
63 > This is a simpler patch that uses as much of the output of notmuch reply =\r
64 as possible, at the expense of emacs more flexible hooks and citing. Both o=\r
65 f the patches (unfortunately) still just call message-modes signature funct=\r
66 ion without one of the standard hooks and wrappers, because I haven=E2=80=\r
67 =99t looked into that yet.\r
68 \r
69 That=E2=80=99s not right, I sent the same patch twice.\r
70 Here=E2=80=99s the one for just compose-mail because the other one has prob=\r
71 lems with non-ascii characters. I guess I=E2=80=99d need to re-implement mo=\r
72 re and more of notmuch reply in the elisp. I started doing that but I figur=\r
73 e that I=E2=80=99d send these patches and see if it was something you like =\r
74 at all.\r
75 \r
76 Signed-off-by: Sandra Snan <sandra.snan@handgranat.org>\r
77 ---\r
78  emacs/notmuch.el |   61 ++++++++++++++++++++++++++++++++++++++++++--------=\r
79 ---\r
80  1 files changed, 48 insertions(+), 13 deletions(-)\r
81 \r
82 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
83 index 117a365..baafac8 100644\r
84 --- a/emacs/notmuch.el\r
85 +++ b/emacs/notmuch.el\r
86 @@ -49,7 +49,7 @@\r
87 =20\r
88  (require 'cl)\r
89  (require 'mm-view)\r
90 -(require 'message)\r
91 +(require 'message) ; not sure if this is needed now\r
92 =20\r
93  (defvar notmuch-show-stash-map\r
94    (let ((map (make-sparse-keymap)))\r
95 @@ -76,7 +76,7 @@\r
96      (define-key map (kbd "M-TAB") 'notmuch-show-previous-button)\r
97      (define-key map (kbd "TAB") 'notmuch-show-next-button)\r
98      (define-key map "s" 'notmuch-search)\r
99 -    (define-key map "m" 'message-mail)\r
100 +    (define-key map "m" 'compose-mail)\r
101      (define-key map "f" 'notmuch-show-forward-current)\r
102      (define-key map "r" 'notmuch-show-reply)\r
103      (define-key map "|" 'notmuch-show-pipe-message)\r
104 @@ -435,16 +435,51 @@ buffer."\r
105        mm-handle (> (notmuch-count-attachments mm-handle) 1))))\r
106    (message "Done"))\r
107 =20\r
108 -(defun notmuch-reply (query-string)\r
109 -  (switch-to-buffer (generate-new-buffer "notmuch-draft"))\r
110 -  (call-process notmuch-command nil t nil "reply" query-string)\r
111 -  (message-insert-signature)\r
112 +\r
113 +(defun jump-to-end-of-header ()\r
114 +  (re-search-forward "^[^:]*.: \\|^$")\r
115 +  (beginning-of-line)\r
116 +  (backward-char)\r
117 +  (point))\r
118 +\r
119 +(defun notmuch-regex-header (re)\r
120    (goto-char (point-min))\r
121 -  (if (re-search-forward "^$" nil t)\r
122 -      (progn\r
123 -       (insert "--text follows this line--")\r
124 -       (forward-line)))\r
125 -  (message-mode))\r
126 +  (if (re-search-forward re nil t)\r
127 +      (buffer-substring-no-properties (point) (jump-to-end-of-header))\r
128 +    ""))\r
129 +\r
130 +(defun notmuch-other-headers (al)\r
131 +  (beginning-of-line)\r
132 +  (if (eq (point-at-bol) (point-at-eol))\r
133 +      al\r
134 +    (if (re-search-forward "^[^:]*.: \\|^$" nil t)\r
135 +       (notmuch-other-headers\r
136 +         (let ((header (buffer-substring-no-properties (point-at-bol) (- (point)=\r
137  2)))\r
138 +               (header-value (buffer-substring-no-properties (point) (jump-to-end-of-he=\r
139 ader))))\r
140 +           (forward-char)\r
141 +           (if (or (string=3D "To" header) (string=3D "Subject" header))\r
142 +               al\r
143 +             (acons\r
144 +              header\r
145 +              header-value\r
146 +              al))))\r
147 +      al)))\r
148 +\r
149 +(defun notmuch-reply (query-string)\r
150 +  (with-temp-buffer\r
151 +    (call-process notmuch-command nil t nil "reply" query-string)\r
152 +    (let ((body\r
153 +          (progn (goto-char (point-min))\r
154 +                 (if (re-search-forward "^$" nil t)\r
155 +                     (buffer-substring-no-properties (+ (point) 1) (point-max))\r
156 +                   ""))))\r
157 +      (compose-mail\r
158 +       (notmuch-regex-header "^To: ")\r
159 +       (notmuch-regex-header "^Subject: ")\r
160 +       (progn (goto-char (point-min))\r
161 +             (notmuch-other-headers '())))\r
162 +      (goto-char (point-max))\r
163 +      (insert body))))\r
164 =20\r
165  (defun notmuch-show-reply ()\r
166    "Begin composing a reply to the current message in a new buffer."\r
167 @@ -1229,7 +1264,7 @@ matching this search term are shown if non-nil. "\r
168      (define-key map "p" 'notmuch-search-previous-thread)\r
169      (define-key map "n" 'notmuch-search-next-thread)\r
170      (define-key map "r" 'notmuch-search-reply-to-thread)\r
171 -    (define-key map "m" 'message-mail)\r
172 +    (define-key map "m" 'compose-mail)\r
173      (define-key map "s" 'notmuch-search)\r
174      (define-key map "o" 'notmuch-search-toggle-order)\r
175      (define-key map "=3D" 'notmuch-search-refresh-view)\r
176 @@ -1651,7 +1686,7 @@ current search results AND that are tagged with the g=\r
177 iven tag."\r
178      (define-key map "?" 'notmuch-help)\r
179      (define-key map "x" 'kill-this-buffer)\r
180      (define-key map "q" 'kill-this-buffer)\r
181 -    (define-key map "m" 'message-mail)\r
182 +    (define-key map "m" 'compose-mail)\r
183      (define-key map "e" 'notmuch-folder-show-empty-toggle)\r
184      (define-key map ">" 'notmuch-folder-last)\r
185      (define-key map "<" 'notmuch-folder-first)\r
186 --=20\r
187 1.7.0\r
188 \r