How does notmuch track mails?
[notmuch-archives.git] / 0d / 5aef5c350c8b95c5b8a720a13cc775c2bc0ae0
1 Return-Path: <cworth@cworth.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 5BED3431FD0\r
6         for <notmuch@notmuchmail.org>; Tue, 24 May 2011 15:02:10 -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: 0.01\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.01 tagged_above=-999 required=5\r
12         tests=[T_MIME_NO_TEXT=0.01] 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 4xskCaMDtIqb for <notmuch@notmuchmail.org>;\r
16         Tue, 24 May 2011 15:02:09 -0700 (PDT)\r
17 Received: from arlo.cworth.org (arlo.cworth.org [50.43.72.2])\r
18         by olra.theworths.org (Postfix) with ESMTP id 62256431FB6\r
19         for <notmuch@notmuchmail.org>; Tue, 24 May 2011 15:02:09 -0700 (PDT)\r
20 Received: from yoom.home.cworth.org (localhost [127.0.0.1])\r
21         by arlo.cworth.org (Postfix) with ESMTP id 1A92329A058;\r
22         Tue, 24 May 2011 15:02:08 -0700 (PDT)\r
23 Received: by yoom.home.cworth.org (Postfix, from userid 1000)\r
24         id 197E925417E; Tue, 24 May 2011 15:02:08 -0700 (PDT)\r
25 From: Carl Worth <cworth@cworth.org>\r
26 To: Stewart Smith <stewart@flamingspork.com>,\r
27  notmuch <notmuch@notmuchmail.org>\r
28 Subject: [PATCH] emacs: Allow user to choose "From" address when composing a\r
29         new message.\r
30 In-Reply-To: <87wrhfvk6a.fsf@yoom.home.cworth.org>\r
31 References: <87vcxb0za4.fsf@flamingspork.com>\r
32         <87wrhfvk6a.fsf@yoom.home.cworth.org>\r
33 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1\r
34         (i486-pc-linux-gnu)\r
35 Date: Tue, 24 May 2011 15:02:01 -0700\r
36 Message-ID: <87lixvvjty.fsf@yoom.home.cworth.org>\r
37 MIME-Version: 1.0\r
38 Content-Type: multipart/signed; boundary="=-=-=";\r
39         micalg=pgp-sha1; protocol="application/pgp-signature"\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, 24 May 2011 22:02:10 -0000\r
53 \r
54 --=-=-=\r
55 Content-Transfer-Encoding: quoted-printable\r
56 \r
57 In order to select a From address, the user simply presses M instead of\r
58 m to begin composing a message. By default the list of names/addresses\r
59 to be used during completion will be automatically generated by the\r
60 settings in the notmuch configuration file. The user can customize\r
61 the notmuch-identities variable to provide an alternate list.\r
62 =2D--\r
63  emacs/notmuch-hello.el |    3 ++-\r
64  emacs/notmuch-mua.el   |   40 ++++++++++++++++++++++++++++++++++++++--\r
65  emacs/notmuch.el       |    3 ++-\r
66  3 files changed, 42 insertions(+), 4 deletions(-)\r
67 \r
68 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
69 index e58dd24..5f3bcc8 100644\r
70 =2D-- a/emacs/notmuch-hello.el\r
71 +++ b/emacs/notmuch-hello.el\r
72 @@ -298,7 +298,8 @@ should be. Returns a cons cell `(tags-per-line width)'."\r
73      (define-key map "=3D" 'notmuch-hello-update)\r
74      (define-key map "G" 'notmuch-hello-poll-and-update)\r
75      (define-key map (kbd "<C-tab>") 'widget-backward)\r
76 =2D    (define-key map "m" 'notmuch-mua-mail)\r
77 +    (define-key map "m" 'notmuch-mua-new-mail)\r
78 +    (define-key map "M" 'notmuch-mua-new-mail-prompt-for-sender)\r
79      (define-key map "s" 'notmuch-hello-goto-search)\r
80      map)\r
81    "Keymap for \"notmuch hello\" buffers.")\r
82 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
83 index dc7b386..76bcba4 100644\r
84 =2D-- a/emacs/notmuch-mua.el\r
85 +++ b/emacs/notmuch-mua.el\r
86 @@ -118,8 +118,7 @@ list."\r
87 =20\r
88  (defun notmuch-mua-mail (&optional to subject other-headers continue\r
89                                    switch-function yank-action send-actions)\r
90 =2D  "Invoke the notmuch mail composition window."\r
91 =2D  (interactive)\r
92 +  "Invoke the notmuch mail composition window with optional headers."\r
93 =20\r
94    (when notmuch-mua-user-agent-function\r
95      (let ((user-agent (funcall notmuch-mua-user-agent-function)))\r
96 @@ -138,6 +137,43 @@ list."\r
97 =20\r
98    (message-goto-to))\r
99 =20\r
100 +(defcustom notmuch-identities nil\r
101 +  "Identities that can be used as the From: address when composing a new m=\r
102 essage.\r
103 +\r
104 +If this variable is left unset, then a list will be constructed from the\r
105 +name and addresses configured in the notmuch configuration file."\r
106 +  :group 'notmuch\r
107 +  :type '(repeat string))\r
108 +\r
109 +(defun notmuch-mua-sender-collection ()\r
110 +  (if notmuch-identities\r
111 +      notmuch-identities\r
112 +    (mapcar (lambda (address)\r
113 +             (concat (notmuch-user-name) " <" address ">"))\r
114 +           (cons (notmuch-user-primary-email) (notmuch-user-other-email)))))\r
115 +\r
116 +(defun notmuch-mua-new-mail-from (&optional sender)\r
117 +  (if sender\r
118 +      (notmuch-mua-mail nil nil (list (cons 'from sender)))\r
119 +    (notmuch-mua-mail)))\r
120 +\r
121 +(defvar notmuch-mua-sender-history nil)\r
122 +\r
123 +(defun notmuch-mua-new-mail (&optional prompt-for-sender)\r
124 +  "Begin composing a new email with notmuch."\r
125 +  (interactive "P")\r
126 +  (if prompt-for-sender\r
127 +      (let* ((collection (notmuch-mua-sender-collection))\r
128 +            (sender (ido-completing-read "Send mail From: " collection\r
129 +                                         nil 'confirm nil 'notmuch-mua-sender-history (car collection))))\r
130 +       (notmuch-mua-new-mail-from sender))\r
131 +    (notmuch-mua-mail)))\r
132 +\r
133 +(defun notmuch-mua-new-mail-prompt-for-sender ()\r
134 +  "Begin composing a new email with notmuch, and prompt for the From: addr=\r
135 ess."\r
136 +  (interactive)\r
137 +  (notmuch-mua-new-mail t))\r
138 +\r
139  (defun notmuch-mua-send-and-exit (&optional arg)\r
140    (interactive "P")\r
141    (message-send-and-exit arg))\r
142 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
143 index 64f72a0..0c1c8d0 100644\r
144 =2D-- a/emacs/notmuch.el\r
145 +++ b/emacs/notmuch.el\r
146 @@ -204,7 +204,8 @@ For a mouse binding, return nil."\r
147      (define-key map "p" 'notmuch-search-previous-thread)\r
148      (define-key map "n" 'notmuch-search-next-thread)\r
149      (define-key map "r" 'notmuch-search-reply-to-thread)\r
150 =2D    (define-key map "m" 'notmuch-mua-mail)\r
151 +    (define-key map "m" 'notmuch-mua-new-mail)\r
152 +    (define-key map "M" 'notmuch-mua-new-mail-prompt-for-sender)\r
153      (define-key map "s" 'notmuch-search)\r
154      (define-key map "o" 'notmuch-search-toggle-order)\r
155      (define-key map "c" 'notmuch-search-stash-map)\r
156 =2D-=20\r
157 1.7.5.1\r
158 \r
159 \r
160 --=-=-=\r
161 Content-Type: application/pgp-signature\r
162 \r
163 -----BEGIN PGP SIGNATURE-----\r
164 Version: GnuPG v1.4.11 (GNU/Linux)\r
165 \r
166 iEYEARECAAYFAk3cKtkACgkQ6JDdNq8qSWj4wQCff9dg7GDRYtPCdayNVHe+KaYm\r
167 sOoAn2YyqYJcnm1tD6FwQ1FsE5zgtUE7\r
168 =AJzE\r
169 -----END PGP SIGNATURE-----\r
170 --=-=-=--\r