Re: [PATCH v4 04/16] Provide _notmuch_crypto_{set,get}_gpg_path
[notmuch-archives.git] / c4 / d0c85ad913f4d8cbfb08c2b59c2a74b63999f4
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 2A46E431FD5\r
6         for <notmuch@notmuchmail.org>; Thu, 20 Feb 2014 11:16:54 -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 0F53ZaSnHOuK for <notmuch@notmuchmail.org>;\r
16         Thu, 20 Feb 2014 11:16:50 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu\r
18         [18.9.25.13])\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 99143431FC0\r
22         for <notmuch@notmuchmail.org>; Thu, 20 Feb 2014 11:16:47 -0800 (PST)\r
23 X-AuditID: 1209190d-f79776d000000ce9-ed-5306549e7d8d\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-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id A0.04.03305.E9456035; Thu, 20 Feb 2014 14:16:46 -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 s1KJGht8026147; \r
31         Thu, 20 Feb 2014 14:16:44 -0500\r
32 Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])\r
33         (authenticated bits=0)\r
34         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
35         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s1KJGfZl012830\r
36         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
37         Thu, 20 Feb 2014 14:16:42 -0500\r
38 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
39         (envelope-from <amdragon@mit.edu>)\r
40         id 1WGZ6v-0004ZC-2b; Thu, 20 Feb 2014 14:16:41 -0500\r
41 From: Austin Clements <amdragon@MIT.EDU>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH 4/4] emacs: Simplify and fix `notmuch-mua-prompt-for-sender'\r
44 Date: Thu, 20 Feb 2014 14:16:37 -0500\r
45 Message-Id: <1392923797-17045-5-git-send-email-amdragon@mit.edu>\r
46 X-Mailer: git-send-email 1.8.4.rc3\r
47 In-Reply-To: <1392923797-17045-1-git-send-email-amdragon@mit.edu>\r
48 References: <1392923797-17045-1-git-send-email-amdragon@mit.edu>\r
49 X-Brightmail-Tracker:\r
50  H4sIAAAAAAAAA+NgFjrBIsWRmVeSWpSXmKPExsUixG6nojsvhC3Y4MJRJYvXCyaxWVy/OZPZ\r
51         gclj9dpOFo9nq24xBzBFcdmkpOZklqUW6dslcGX8+/SOueCUVEVT02OmBsY9ol2MnBwSAiYS\r
52         28+uZoawxSQu3FvPBmILCcxmkuhc4N3FyAVkb2SU+Nj/lR3COcIkcezpT1YIZy6jxMUT38Ha\r
53         2QQ0JLbtX84IYosISEvsvDubFcRmFrCR2PzxMVhcWMBHYs62pUwgNouAqkTXt0fsIDavgIPE\r
54         iZ9fGSHOUJJYeGobWC+ngKPE0v4PQDYH0DIHic6tOhMY+RcwMqxilE3JrdLNTczMKU5N1i1O\r
55         TszLSy3SNdLLzSzRS00p3cQICiROSd4djO8OKh1iFOBgVOLhPSHFFizEmlhWXJl7iFGSg0lJ\r
56         lHdFAFCILyk/pTIjsTgjvqg0J7X4EKMEB7OSCG+TDVCONyWxsiq1KB8mJc3BoiTOW2vxK0hI\r
57         ID2xJDU7NbUgtQgmK8PBoSTBGxoM1ChYlJqeWpGWmVOCkGbi4AQZzgM0PDIIZHhxQWJucWY6\r
58         RP4Uoy7H+wV/PzEKseTl56VKifM+BSkSACnKKM2DmwNLAK8YxYHeEuadD7KOB5g84Ca9AlrC\r
59         BLSkZCMryJKSRISUVANjTs27c7NnrHO+EPPwocG2U0Gnux8/FP70qNf1VJDt1l4PM8ZO8dKQ\r
60         75y2cRoiMgbG8l4CBrUdSgsW71zoOnsLw1pZ7aAV72aeVVvHzRL17fi9y8cWiky71e8pV/sy\r
61         jKUsRNSlPnCh/TPpHJuT5scLptw/lWQfZr1vTnO9x3HXPy/bNFpPr2dWYinOSDTUYi4qTgQA\r
62         EJQD1tsCAAA=\r
63 Cc: bjonnh-nm@bjonnh.net\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, 20 Feb 2014 19:16:54 -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, but this has\r
81 several problems.  First, it uses `mail-extract-address-components',\r
82 which is meant for displaying email addresses, not general-purpose\r
83 parsing, and hence performs many canonicalizations that can interfere\r
84 with this use.  For example, configuring notmuch-identities to\r
85 ("Austin <austin@example.com>"), will cause\r
86 `notmuch-mua-prompt-for-sender' to lose the name part entirely and\r
87 return " <austin@example.com>".  Second, though less serious, the\r
88 prompt specialization means the user can't enter a different name like\r
89 they can if their identities have different names.\r
90 \r
91 This patch rewrites `notmuch-mua-prompt-for-sender' to simply prompt\r
92 for a full identity, where the list of identities is derived from\r
93 either notmuch-identities or the user's Notmuch configuration.\r
94 \r
95 The original code also did several strange things, like using `eval'\r
96 and specifying that this function was interactive.  As a side-effect,\r
97 this patch fixes these problems.  And it adds a docstring.\r
98 ---\r
99  emacs/notmuch-mua.el | 33 +++++++++------------------------\r
100  1 file changed, 9 insertions(+), 24 deletions(-)\r
101 \r
102 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
103 index f2df770..4a485a4 100644\r
104 --- a/emacs/notmuch-mua.el\r
105 +++ b/emacs/notmuch-mua.el\r
106 @@ -286,30 +286,15 @@ 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 +  (let ((identities (or notmuch-identities\r
136 +                       (let ((name (notmuch-user-name)))\r
137 +                         (mapcar (lambda (addr) (concat name " <" addr ">"))\r
138 +                                 (cons (notmuch-user-primary-email)\r
139 +                                       (notmuch-user-other-email)))))))\r
140 +    (ido-completing-read "Send mail from: " identities\r
141 +                        nil nil nil 'notmuch-mua-sender-history\r
142 +                        (car identities))))\r
143  \r
144  (put 'notmuch-mua-new-mail 'notmuch-prefix-doc "... and prompt for sender")\r
145  (defun notmuch-mua-new-mail (&optional prompt-for-sender)\r
146 -- \r
147 1.8.4.rc3\r
148 \r