Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / f2 / d0add31541c4a7d506af0c883f8294a8cfab18
1 Return-Path: <andreas.amann@tyndall.ie>\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 1FDA240DAD6\r
6         for <notmuch@notmuchmail.org>; Mon,  8 Nov 2010 11:18:49 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -4.2\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3] 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 DM50PXqkJJg7 for <notmuch@notmuchmail.org>;\r
16         Mon,  8 Nov 2010 11:18:37 -0800 (PST)\r
17 Received: from mail2.tyndall.ie (tyndall.ucc.ie [143.239.64.1])\r
18         by olra.theworths.org (Postfix) with ESMTP id 4C51940DAE7\r
19         for <notmuch@notmuchmail.org>; Mon,  8 Nov 2010 11:18:37 -0800 (PST)\r
20 Received: from localhost (localhost [127.0.0.1])\r
21         by mail2.tyndall.ie (Postfix) with ESMTP id 38785B20C2\r
22         for <notmuch@notmuchmail.org>; Mon,  8 Nov 2010 19:18:35 +0000 (GMT)\r
23 X-Virus-Scanned: Debian amavisd-new at mail.tyndall.ie\r
24 Received: from mail2.tyndall.ie ([127.0.0.1])\r
25         by localhost (bastion2.tyndall.ie [127.0.0.1]) (amavisd-new, port 10024)\r
26         with ESMTP id CYY9xZC6IIO4 for <notmuch@notmuchmail.org>;\r
27         Mon,  8 Nov 2010 19:18:35 +0000 (GMT)\r
28 Received: from unixmail.tyndall.ie (unknown [10.1.64.22])\r
29         by mail2.tyndall.ie (Postfix) with ESMTP id 14A24B20C1\r
30         for <notmuch@notmuchmail.org>; Mon,  8 Nov 2010 19:18:35 +0000 (GMT)\r
31 Received: from localhost (localhost [127.0.0.1])\r
32         by unixmail.tyndall.ie (Postfix) with ESMTP id 13F06349E0\r
33         for <notmuch@notmuchmail.org>; Mon,  8 Nov 2010 19:18:35 +0000 (GMT)\r
34 X-Virus-Scanned: amavisd-new at tyndall.ie\r
35 Received: from unixmail.tyndall.ie ([127.0.0.1])\r
36         by localhost (unixmail.tyndall.ie [127.0.0.1]) (amavisd-new, port 10024)\r
37         with ESMTP id yHBpe-zEt1e9 for <notmuch@notmuchmail.org>;\r
38         Mon,  8 Nov 2010 19:18:29 +0000 (GMT)\r
39 Received: from localhost6.localdomain6 (lnx0015f24b24d0.nmrc.ucc.ie\r
40         [10.1.65.104])\r
41         by unixmail.tyndall.ie (Postfix) with ESMTP id 36A7634938\r
42         for <notmuch@notmuchmail.org>; Mon,  8 Nov 2010 19:18:29 +0000 (GMT)\r
43 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1])\r
44         by localhost6.localdomain6 (8.14.4/8.14.4) with ESMTP id oA8JLqEM010483\r
45         for <notmuch@notmuchmail.org>; Mon, 8 Nov 2010 19:21:52 GMT\r
46 Received: (from aamann@localhost)\r
47         by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id oA8JLoWx010481;\r
48         Mon, 8 Nov 2010 19:21:50 GMT\r
49 X-Authentication-Warning: localhost6.localdomain6: aamann set sender to\r
50         andreas.amann@tyndall.ie using -f\r
51 From: Andreas Amann <amann@physik.tu-berlin.de>\r
52 To: notmuch@notmuchmail.org\r
53 Subject: Re: Notmuch Ruby bindings\r
54 In-Reply-To: <87iq07n16w.fsf@yoom.home.cworth.org>\r
55 References: <8639xkv1kz.fsf@harikalardiyari.ev>\r
56         <87vd47n20a.fsf@yoom.home.cworth.org>\r
57         <87sjzbn1w8.fsf@yoom.home.cworth.org>\r
58         <87iq07n16w.fsf@yoom.home.cworth.org>\r
59 User-Agent: Notmuch/0.3.1-133-gc212382 (http://notmuchmail.org)\r
60         Emacs/24.0.50.1 (x86_64-unknown-linux-gnu)\r
61 Date: Mon, 08 Nov 2010 19:21:50 +0000\r
62 Message-ID: <ylpd3qf39kh.fsf@tyndall.ie>\r
63 MIME-Version: 1.0\r
64 Content-Type: multipart/mixed; boundary="=-=-="\r
65 X-Mailman-Approved-At: Mon, 08 Nov 2010 18:16:30 -0800\r
66 X-BeenThere: notmuch@notmuchmail.org\r
67 X-Mailman-Version: 2.1.13\r
68 Precedence: list\r
69 List-Id: "Use and development of the notmuch mail system."\r
70         <notmuch.notmuchmail.org>\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
74 List-Post: <mailto:notmuch@notmuchmail.org>\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
77         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
78 X-List-Received-Date: Mon, 08 Nov 2010 19:18:49 -0000\r
79 \r
80 --=-=-=\r
81 Content-Type: text/plain\r
82 \r
83 On Mon, 08 Nov 2010 10:02:31 -0800, Carl Worth <cworth@cworth.org> wrote:\r
84 > Now, where was that patch adding a "reply to sender only" binding... \r
85\r
86 \r
87 After a number of embarrassing mails I use the attached patch, which\r
88 changes the default behaviour of "r" to "reply to sender only". Usual\r
89 reply to everybody is "R". Maybe you prefer reversed binding?\r
90 \r
91 \r
92 Andreas\r
93 \r
94 \r
95 \r
96 --=-=-=\r
97 Content-Type: text/x-patch\r
98 Content-Disposition: inline;\r
99  filename=0001-Add-reply-to-sender-only-functionality.patch\r
100 \r
101 Add reply to sender only functionality\r
102 \r
103 This changes the default keybinding "r" in notmuch emacs interface to\r
104 mean "reply to sender only". This is an adapted version of a patch by\r
105 Michal Sojka.\r
106 ---\r
107  emacs/notmuch-mua.el  |    2 +-\r
108  emacs/notmuch-show.el |   10 ++++++++--\r
109  emacs/notmuch.el      |   12 ++++++++++--\r
110  notmuch-reply.c       |    9 +++++++--\r
111  notmuch.1             |    6 ++++++\r
112  notmuch.c             |    3 +++\r
113  6 files changed, 35 insertions(+), 7 deletions(-)\r
114 \r
115 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
116 index dc7b386..2cf846e 100644\r
117 --- a/emacs/notmuch-mua.el\r
118 +++ b/emacs/notmuch-mua.el\r
119 @@ -75,7 +75,7 @@ list."\r
120      ;; really only that the headers come first followed by a blank\r
121      ;; line and then the body.\r
122      (with-temp-buffer\r
123 -      (call-process notmuch-command nil t nil "reply" query-string)\r
124 +      (apply 'call-process (append (list notmuch-command nil t nil "reply") query-string))\r
125        (goto-char (point-min))\r
126        (if (re-search-forward "^$" nil t)\r
127           (save-excursion\r
128 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
129 index 98a2fbc..b634b8d 100644\r
130 --- a/emacs/notmuch-show.el\r
131 +++ b/emacs/notmuch-show.el\r
132 @@ -563,7 +563,8 @@ function is used. "\r
133         (define-key map "s" 'notmuch-search)\r
134         (define-key map "m" 'notmuch-mua-mail)\r
135         (define-key map "f" 'notmuch-show-forward-message)\r
136 -       (define-key map "r" 'notmuch-show-reply)\r
137 +       (define-key map "R" 'notmuch-show-reply)\r
138 +       (define-key map "r" 'notmuch-show-reply-to-sender)\r
139         (define-key map "|" 'notmuch-show-pipe-message)\r
140         (define-key map "w" 'notmuch-show-save-attachments)\r
141         (define-key map "V" 'notmuch-show-view-raw-message)\r
142 @@ -870,7 +871,12 @@ any effects from previous calls to\r
143  (defun notmuch-show-reply ()\r
144    "Reply to the current message."\r
145    (interactive)\r
146 -  (notmuch-mua-reply (notmuch-show-get-message-id)))\r
147 +  (notmuch-mua-reply (list (notmuch-show-get-message-id))))\r
148 +\r
149 +(defun notmuch-show-reply-to-sender ()\r
150 +  "Reply to the current message (only to the sender)."\r
151 +  (interactive)\r
152 +  (notmuch-mua-reply (list "--sender-only" (notmuch-show-get-message-id))))\r
153  \r
154  (defun notmuch-show-forward-message ()\r
155    "Forward the current message."\r
156 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
157 index 2a87ab9..8897d09 100644\r
158 --- a/emacs/notmuch.el\r
159 +++ b/emacs/notmuch.el\r
160 @@ -203,7 +203,8 @@ For a mouse binding, return nil."\r
161      (define-key map ">" 'notmuch-search-last-thread)\r
162      (define-key map "p" 'notmuch-search-previous-thread)\r
163      (define-key map "n" 'notmuch-search-next-thread)\r
164 -    (define-key map "r" 'notmuch-search-reply-to-thread)\r
165 +    (define-key map "R" 'notmuch-search-reply-to-thread)\r
166 +    (define-key map "r" 'notmuch-search-reply-to-thread-sender)\r
167      (define-key map "m" 'notmuch-mua-mail)\r
168      (define-key map "s" 'notmuch-search)\r
169      (define-key map "o" 'notmuch-search-toggle-order)\r
170 @@ -427,7 +428,14 @@ Complete list of currently available key bindings:\r
171    "Begin composing a reply to the entire current thread in a new buffer."\r
172    (interactive)\r
173    (let ((message-id (notmuch-search-find-thread-id)))\r
174 -    (notmuch-mua-reply message-id)))\r
175 +    (notmuch-mua-reply (list message-id))))\r
176 +\r
177 +(defun notmuch-search-reply-to-thread-sender ()\r
178 +  "Begin composing a reply to the sender only of the  current thread in a new buffer."\r
179 +  (interactive)\r
180 +  (let ((message-id (notmuch-search-find-thread-id)))\r
181 +    (notmuch-mua-reply (list "--sender-only" message-id))))\r
182 +\r
183  \r
184  (defun notmuch-call-notmuch-process (&rest args)\r
185    "Synchronously invoke \"notmuch\" with the given list of arguments.\r
186 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
187 index 23d04b8..886157a 100644\r
188 --- a/notmuch-reply.c\r
189 +++ b/notmuch-reply.c\r
190 @@ -24,6 +24,8 @@\r
191  #include "gmime-filter-reply.h"\r
192  #include "gmime-filter-headers.h"\r
193  \r
194 +static notmuch_bool_t sender_only = FALSE;\r
195 +\r
196  static void\r
197  reply_part_content (GMimeObject *part)\r
198  {\r
199 @@ -272,6 +274,7 @@ add_recipients_from_message (GMimeMessage *reply,\r
200      };\r
201      const char *from_addr = NULL;\r
202      unsigned int i;\r
203 +    unsigned int max;\r
204  \r
205      /* Some mailing lists munge the Reply-To header despite it being A Bad\r
206       * Thing, see http://www.unicom.com/pw/reply-to-harmful.html\r
207 @@ -288,8 +291,8 @@ add_recipients_from_message (GMimeMessage *reply,\r
208         reply_to_map[0].header = "from";\r
209         reply_to_map[0].fallback = NULL;\r
210      }\r
211 -\r
212 -    for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {\r
213 +    max = sender_only ? 1 : ARRAY_SIZE (reply_to_map);\r
214 +    for (i = 0; i < max; i++) {\r
215         const char *addr, *recipients;\r
216  \r
217         recipients = notmuch_message_get_header (message,\r
218 @@ -595,6 +598,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
219                 fprintf (stderr, "Invalid value for --format: %s\n", opt);\r
220                 return 1;\r
221             }\r
222 +       } else if (STRNCMP_LITERAL (argv[i], "--sender-only") == 0) {\r
223 +           sender_only = TRUE;\r
224         } else {\r
225             fprintf (stderr, "Unrecognized option: %s\n", argv[i]);\r
226             return 1;\r
227 diff --git a/notmuch.1 b/notmuch.1\r
228 index 2c33749..6bd5dc0 100644\r
229 --- a/notmuch.1\r
230 +++ b/notmuch.1\r
231 @@ -353,6 +353,12 @@ Includes subject and quoted message body.\r
232  .BR headers\-only\r
233  Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.\r
234  .RE\r
235 +.TP 4\r
236 +.B \-\-sender\-only\r
237 +\r
238 +Only setup the To: header as described above, not the additional Cc\r
239 +headers.\r
240 +.RE\r
241  \r
242  See the\r
243  .B "SEARCH SYNTAX"\r
244 diff --git a/notmuch.c b/notmuch.c\r
245 index 030e494..1780dbe 100644\r
246 --- a/notmuch.c\r
247 +++ b/notmuch.c\r
248 @@ -297,6 +297,9 @@ command_t commands[] = {\r
249        "\t\t\tOnly produces In-Reply-To, References, To\n"\r
250        "\t\t\tCc, and Bcc headers.\n"\r
251        "\n"\r
252 +      "\t\t--sender-only\n"\r
253 +      "\t\t\tReply only to sender.\n"\r
254 +      "\n"\r
255        "\tSee \"notmuch help search-terms\" for details of the search\n"\r
256        "\tterms syntax." },\r
257      { "tag", notmuch_tag_command,\r
258 -- \r
259 1.7.2.3\r
260 \r
261 \r
262 --=-=-=--\r