Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 40 / 35f8548b32274fb64500e607c9ae0a04398788
1 Return-Path: <amdragon@mit.edu>\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 DC73E431FAF\r
6         for <notmuch@notmuchmail.org>; Thu, 27 Feb 2014 10:11:10 -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: -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 UmaNpR+p7DYu for <notmuch@notmuchmail.org>;\r
16         Thu, 27 Feb 2014 10:11:04 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
18         [18.7.68.35])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 7B53D431FAE\r
22         for <notmuch@notmuchmail.org>; Thu, 27 Feb 2014 10:11:04 -0800 (PST)\r
23 X-AuditID: 12074423-f79726d000000cc9-64-530f7fb5580e\r
24 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
25         (using TLS with cipher AES256-SHA (256/256 bits))\r
26         (Client did not present a certificate)\r
27         by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id 8D.8D.03273.5BF7F035; Thu, 27 Feb 2014 13:11:01 -0500 (EST)\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
30         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s1RIAx57006187; \r
31         Thu, 27 Feb 2014 13:10:59 -0500\r
32 Received: from drake.dyndns.org\r
33         (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
34         [216.15.114.40]) (authenticated bits=0)\r
35         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
36         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s1RIAvat014764\r
37         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
38         Thu, 27 Feb 2014 13:10:58 -0500\r
39 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
40         (envelope-from <amdragon@mit.edu>)\r
41         id 1WJ5Q8-0005Ms-NE; Thu, 27 Feb 2014 13:10:56 -0500\r
42 From: Austin Clements <amdragon@MIT.EDU>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v2] emacs: Simplify and fix `notmuch-mua-prompt-for-sender'\r
45 Date: Thu, 27 Feb 2014 13:10:54 -0500\r
46 Message-Id: <1393524654-20502-1-git-send-email-amdragon@mit.edu>\r
47 X-Mailer: git-send-email 1.8.4.rc3\r
48 In-Reply-To: <87fvndfm3k.fsf@qmul.ac.uk>\r
49 References: <87fvndfm3k.fsf@qmul.ac.uk>\r
50 X-Brightmail-Tracker:\r
51  H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsUixG6noru1nj/Y4NBbS4vVc3ksrt+cyezA\r
52         5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZfx88YS5YLNUxbcps5kbGKeIdjFyckgImEhs\r
53         e3+ZBcIWk7hwbz1bFyMXh5DAbCaJFxfvsUA4Gxkljl59xQ7h3GGSuPVnIiOEM5dRYuOx72D9\r
54         bAIaEtv2L2cEsUUEpCV23p3NCmIzCzhKfN6/iA3EFhbwljjV9xWsnkVAVeJR13xmEJtXwEHi\r
55         +76VbBB3KEksPLUNrJcTaOaNJdPBaoQE1CUav3ezT2DkX8DIsIpRNiW3Sjc3MTOnODVZtzg5\r
56         MS8vtUjXTC83s0QvNaV0EyM4lFyUdzD+Oah0iFGAg1GJh3eiJ3+wEGtiWXFl7iFGSQ4mJVHe\r
57         YzVAIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8J6qBcrwpiZVVqUX5MClpDhYlcd5ai19BQgLp\r
58         iSWp2ampBalFMFkZDg4lCV6ROqBGwaLU9NSKtMycEoQ0EwcnyHAeoOFKIDW8xQWJucWZ6RD5\r
59         U4y6HO8X/P3EKMSSl5+XKiXO+60WqEgApCijNA9uDiwFvGIUB3pLmJcLZBQPMH3ATXoFtIQJ\r
60         aMlRaR6QJSWJCCmpBsbdm9+9u98Z/+Z76rY1ym//MbS4Tt2/zHauz/t3mtqMvAItL1fy6ESm\r
61         2P3XEX0fbvCsudN8cXr/wulHuHpZ9hqH//t5Uuzj1ncHHR++3f5PebGjqG2i8L09hxRrp2+T\r
62         mFUT28S3WF/r0UI3DzNrY9WNvMeZWPkXqxhtjT8s+UJlxZyAh266B34rsRRnJBpqMRcVJwIA\r
63         mFoin9wCAAA=\r
64 X-BeenThere: notmuch@notmuchmail.org\r
65 X-Mailman-Version: 2.1.13\r
66 Precedence: list\r
67 List-Id: "Use and development of the notmuch mail system."\r
68         <notmuch.notmuchmail.org>\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
72 List-Post: <mailto:notmuch@notmuchmail.org>\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
75         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
76 X-List-Received-Date: Thu, 27 Feb 2014 18:11:11 -0000\r
77 \r
78 `notmuch-mua-prompt-for-sender' is over-engineered and often wrong.\r
79 It attempts to detect when all identities have the same name and\r
80 specialize the prompt to just the email address part.  However, to do\r
81 this it uses `mail-extract-address-components', which is meant for\r
82 displaying email addresses, not general-purpose parsing, and hence\r
83 performs many canonicalizations that can interfere with this use.  For\r
84 example, configuring notmuch-identities to ("Austin\r
85 <austin@example.com>"), will cause `notmuch-mua-prompt-for-sender' to\r
86 lose the name part entirely and return " <austin@example.com>".\r
87 \r
88 This patch rewrites `notmuch-mua-prompt-for-sender' to simply prompt\r
89 for a full identity when notmuch-identities is configured, or to\r
90 prompt for a sender address when it isn't.\r
91 \r
92 The original code also did several strange things, like using `eval'\r
93 and specifying that this function was interactive.  As a side-effect,\r
94 this patch fixes these problems.  And it adds a docstring.\r
95 ---\r
96 \r
97 Mark, is this better?\r
98 \r
99 emacs/notmuch-mua.el | 37 +++++++++++++------------------------\r
100  1 file changed, 13 insertions(+), 24 deletions(-)\r
101 \r
102 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
103 index f2df770..b16a10e 100644\r
104 --- a/emacs/notmuch-mua.el\r
105 +++ b/emacs/notmuch-mua.el\r
106 @@ -286,30 +286,19 @@ the From: header is already filled in by notmuch."\r
107        (ad-activate 'ido-completing-read)))\r
108  \r
109  (defun notmuch-mua-prompt-for-sender ()\r
110 -  (interactive)\r
111 -  (let (name addresses one-name-only)\r
112 -    ;; If notmuch-identities is non-nil, check if there is a fixed user name.\r
113 -    (if notmuch-identities\r
114 -       (let ((components (mapcar 'mail-extract-address-components notmuch-identities)))\r
115 -         (setq name          (caar components)\r
116 -               addresses     (mapcar 'cadr components)\r
117 -               one-name-only (eval\r
118 -                              (cons 'and\r
119 -                                    (mapcar (lambda (identity)\r
120 -                                              (string-equal name (car identity)))\r
121 -                                            components)))))\r
122 -      ;; If notmuch-identities is nil, use values from the notmuch configuration file.\r
123 -      (setq name          (notmuch-user-name)\r
124 -           addresses     (cons (notmuch-user-primary-email) (notmuch-user-other-email))\r
125 -           one-name-only t))\r
126 -    ;; Now prompt the user, either for an email address only or for a full identity.\r
127 -    (if one-name-only\r
128 -       (let ((address\r
129 -              (ido-completing-read (concat "Sender address for " name ": ") addresses\r
130 -                                   nil nil nil 'notmuch-mua-sender-history (car addresses))))\r
131 -         (concat name " <" address ">"))\r
132 -      (ido-completing-read "Send mail From: " notmuch-identities\r
133 -                          nil nil nil 'notmuch-mua-sender-history (car notmuch-identities)))))\r
134 +  "Prompt for a sender from the user's configured identities."\r
135 +  (if notmuch-identities\r
136 +      (ido-completing-read "Send mail from: " notmuch-identities\r
137 +                          nil nil nil 'notmuch-mua-sender-history\r
138 +                          (car notmuch-identities))\r
139 +    (let* ((name (notmuch-user-name))\r
140 +          (addrs (cons (notmuch-user-primary-email)\r
141 +                       (notmuch-user-other-email)))\r
142 +          (address\r
143 +           (ido-completing-read (concat "Sender address for " name ": ") addrs\r
144 +                                nil nil nil 'notmuch-mua-sender-history\r
145 +                                (car addrs))))\r
146 +      (concat name " <" address ">"))))\r
147  \r
148  (put 'notmuch-mua-new-mail 'notmuch-prefix-doc "... and prompt for sender")\r
149  (defun notmuch-mua-new-mail (&optional prompt-for-sender)\r
150 -- \r
151 1.8.4.rc3\r
152 \r