[PATCH 2/4] emacs: Move the "prompt for sender" code to a new function.

Thomas Jost schnouki at schnouki.net
Wed May 25 06:22:38 PDT 2011


This allows the code to be reused in different functions without duplicating it.
---
 emacs/notmuch-mua.el |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index cd4d75d..0bde02c 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -157,21 +157,24 @@ name and addresses configured in the notmuch configuration file."
 	      (concat (notmuch-user-name) " <" address ">"))
 	    (cons (notmuch-user-primary-email) (notmuch-user-other-email)))))
 
+(defvar notmuch-mua-sender-history nil)
+
+(defun notmuch-mua-prompt-for-sender ()
+  (interactive)
+  (let ((collection (notmuch-mua-sender-collection)))
+    (ido-completing-read "Send mail From: " collection
+			 nil 'confirm nil 'notmuch-mua-sender-history (car collection))))
+
 (defun notmuch-mua-new-mail-from (&optional sender)
   (if sender
       (notmuch-mua-mail nil nil (list (cons 'from sender)))
     (notmuch-mua-mail)))
 
-(defvar notmuch-mua-sender-history nil)
-
 (defun notmuch-mua-new-mail (&optional prompt-for-sender)
   "Begin composing a new email with notmuch."
   (interactive "P")
   (if prompt-for-sender
-      (let* ((collection (notmuch-mua-sender-collection))
-	     (sender (ido-completing-read "Send mail From: " collection
-					  nil 'confirm nil 'notmuch-mua-sender-history (car collection))))
-	(notmuch-mua-new-mail-from sender))
+      (notmuch-mua-new-mail-from (notmuch-mua-prompt-for-sender))
     (notmuch-mua-mail)))
 
 (defun notmuch-mua-new-mail-prompt-for-sender ()
-- 
1.7.5.1



More information about the notmuch mailing list