[PATCH 1/1] emacs/notmuch-address.el: add notmuch-address-selection-function
authorTomi Ollila <tomi.ollila@iki.fi>
Wed, 3 Apr 2013 15:08:54 +0000 (18:08 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:54:14 +0000 (09:54 -0800)
86/59d5daf90bc6fb46843eab8c4ba45f17dbf089 [new file with mode: 0644]

diff --git a/86/59d5daf90bc6fb46843eab8c4ba45f17dbf089 b/86/59d5daf90bc6fb46843eab8c4ba45f17dbf089
new file mode 100644 (file)
index 0000000..8e8efd9
--- /dev/null
@@ -0,0 +1,115 @@
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 3B0FF431FAF\r
+       for <notmuch@notmuchmail.org>; Wed,  3 Apr 2013 08:09:06 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id wvwUAWb78Ox4 for <notmuch@notmuchmail.org>;\r
+       Wed,  3 Apr 2013 08:09:05 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1D3EF431FAE\r
+       for <notmuch@notmuchmail.org>; Wed,  3 Apr 2013 08:09:05 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id AAC021000CF; Wed,  3 Apr 2013 18:09:02 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/1] emacs/notmuch-address.el: add\r
+       notmuch-address-selection-function\r
+Date: Wed,  3 Apr 2013 18:08:54 +0300\r
+Message-Id: <1365001734-3160-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.8.0\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 03 Apr 2013 15:09:06 -0000\r
+\r
+Added a customizable variable notmuch-address-selection-function\r
+and the function with the same name to provide a way for user to\r
+change the function called to do address selection.\r
+\r
+By default the functionality is exactly the same as it has been so\r
+far; completing-read is called with the same parameters as before.\r
+\r
+Setting equivalent lambda expression in place of using\r
+notmuch-address-selection-function function is done as follows:\r
+\r
+(setq notmuch-address-selection-function\r
+   (lambda (prompt collection initial-input)\r
+     (completing-read prompt collection nil nil initial-input)))\r
+\r
+For example drop-in replacement with ido-completing-read can be done\r
+easily as an one alternative to the default.\r
+---\r
+\r
+My replacement is:\r
+\r
+(require 'selection-menu)\r
+(setq notmuch-address-selection-function\r
+   (lambda (prompt collection initial-input)\r
+    (selection-menu "Send To:" collection t)))\r
+\r
+ emacs/notmuch-address.el | 23 ++++++++++++++++++++---\r
+ 1 file changed, 20 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
+index 2bf762b..fa65cd5 100644\r
+--- a/emacs/notmuch-address.el\r
++++ b/emacs/notmuch-address.el\r
+@@ -31,6 +31,23 @@ line."\r
+   :group 'notmuch-send\r
+   :group 'notmuch-external)\r
\r
++(defcustom notmuch-address-selection-function 'notmuch-address-selection-function\r
++  "The function to select address from given list. The function is\r
++called with PROMPT, COLLECTION, and INITIAL-INPUT as arguments\r
++(subset of what `completing-read' can be called with).\r
++While executed the value of `completion-ignore-case' is t.\r
++See documentation of function `notmuch-address-selection-function'\r
++to know how address selection is made by default."\r
++  :type 'function\r
++  :group 'notmuch-send\r
++  :group 'notmuch-external)\r
++\r
++(defun notmuch-address-selection-function (prompt collection initial-input)\r
++  "Call (`completing-read'\r
++      PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)"\r
++  (completing-read\r
++   prompt collection nil nil initial-input 'notmuch-address-history))\r
++\r
+ (defvar notmuch-address-message-alist-member\r
+   '("^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):"\r
+             . notmuch-address-expand-name))\r
+@@ -61,9 +78,9 @@ line."\r
+                 ((eq num-options 1)\r
+                  (car options))\r
+                 (t\r
+-                 (completing-read (format "Address (%s matches): " num-options)\r
+-                                  (cdr options) nil nil (car options)\r
+-                                  'notmuch-address-history)))))\r
++                 (funcall notmuch-address-selection-function\r
++                          (format "Address (%s matches): " num-options)\r
++                          (cdr options) (car options))))))\r
+     (if chosen\r
+       (progn\r
+         (push chosen notmuch-address-history)\r
+-- \r
+1.8.0\r
+\r