Re: Problem with draft mails when using offlineimap
[notmuch-archives.git] / 86 / 59d5daf90bc6fb46843eab8c4ba45f17dbf089
1 Return-Path: <too@guru-group.fi>\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 3B0FF431FAF\r
6         for <notmuch@notmuchmail.org>; Wed,  3 Apr 2013 08:09:06 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 wvwUAWb78Ox4 for <notmuch@notmuchmail.org>;\r
16         Wed,  3 Apr 2013 08:09:05 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 1D3EF431FAE\r
19         for <notmuch@notmuchmail.org>; Wed,  3 Apr 2013 08:09:05 -0700 (PDT)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id AAC021000CF; Wed,  3 Apr 2013 18:09:02 +0300 (EEST)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH 1/1] emacs/notmuch-address.el: add\r
25         notmuch-address-selection-function\r
26 Date: Wed,  3 Apr 2013 18:08:54 +0300\r
27 Message-Id: <1365001734-3160-1-git-send-email-tomi.ollila@iki.fi>\r
28 X-Mailer: git-send-email 1.8.0\r
29 Cc: tomi.ollila@iki.fi\r
30 X-BeenThere: notmuch@notmuchmail.org\r
31 X-Mailman-Version: 2.1.13\r
32 Precedence: list\r
33 List-Id: "Use and development of the notmuch mail system."\r
34         <notmuch.notmuchmail.org>\r
35 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
36         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
38 List-Post: <mailto:notmuch@notmuchmail.org>\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
40 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
42 X-List-Received-Date: Wed, 03 Apr 2013 15:09:06 -0000\r
43 \r
44 Added a customizable variable notmuch-address-selection-function\r
45 and the function with the same name to provide a way for user to\r
46 change the function called to do address selection.\r
47 \r
48 By default the functionality is exactly the same as it has been so\r
49 far; completing-read is called with the same parameters as before.\r
50 \r
51 Setting equivalent lambda expression in place of using\r
52 notmuch-address-selection-function function is done as follows:\r
53 \r
54 (setq notmuch-address-selection-function\r
55    (lambda (prompt collection initial-input)\r
56      (completing-read prompt collection nil nil initial-input)))\r
57 \r
58 For example drop-in replacement with ido-completing-read can be done\r
59 easily as an one alternative to the default.\r
60 ---\r
61 \r
62 My replacement is:\r
63 \r
64 (require 'selection-menu)\r
65 (setq notmuch-address-selection-function\r
66    (lambda (prompt collection initial-input)\r
67     (selection-menu "Send To:" collection t)))\r
68 \r
69  emacs/notmuch-address.el | 23 ++++++++++++++++++++---\r
70  1 file changed, 20 insertions(+), 3 deletions(-)\r
71 \r
72 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
73 index 2bf762b..fa65cd5 100644\r
74 --- a/emacs/notmuch-address.el\r
75 +++ b/emacs/notmuch-address.el\r
76 @@ -31,6 +31,23 @@ line."\r
77    :group 'notmuch-send\r
78    :group 'notmuch-external)\r
79  \r
80 +(defcustom notmuch-address-selection-function 'notmuch-address-selection-function\r
81 +  "The function to select address from given list. The function is\r
82 +called with PROMPT, COLLECTION, and INITIAL-INPUT as arguments\r
83 +(subset of what `completing-read' can be called with).\r
84 +While executed the value of `completion-ignore-case' is t.\r
85 +See documentation of function `notmuch-address-selection-function'\r
86 +to know how address selection is made by default."\r
87 +  :type 'function\r
88 +  :group 'notmuch-send\r
89 +  :group 'notmuch-external)\r
90 +\r
91 +(defun notmuch-address-selection-function (prompt collection initial-input)\r
92 +  "Call (`completing-read'\r
93 +      PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)"\r
94 +  (completing-read\r
95 +   prompt collection nil nil initial-input 'notmuch-address-history))\r
96 +\r
97  (defvar notmuch-address-message-alist-member\r
98    '("^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):"\r
99               . notmuch-address-expand-name))\r
100 @@ -61,9 +78,9 @@ line."\r
101                   ((eq num-options 1)\r
102                    (car options))\r
103                   (t\r
104 -                  (completing-read (format "Address (%s matches): " num-options)\r
105 -                                   (cdr options) nil nil (car options)\r
106 -                                   'notmuch-address-history)))))\r
107 +                  (funcall notmuch-address-selection-function\r
108 +                           (format "Address (%s matches): " num-options)\r
109 +                           (cdr options) (car options))))))\r
110      (if chosen\r
111         (progn\r
112           (push chosen notmuch-address-history)\r
113 -- \r
114 1.8.0\r
115 \r