From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 53929429E2A for ; Wed, 25 May 2011 06:23:04 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.1 X-Spam-Level: X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DNkLjAZBaxZr for ; Wed, 25 May 2011 06:23:03 -0700 (PDT) Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222]) by olra.theworths.org (Postfix) with ESMTP id 05828429E25 for ; Wed, 25 May 2011 06:23:03 -0700 (PDT) Received: from localhost.localdomain (thor.loria.fr [152.81.12.250]) by ks3536.kimsufi.com (Postfix) with ESMTPSA id 5B8C86A06AD; Wed, 25 May 2011 15:23:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net; s=key-schnouki; t=1306329782; bh=KjrheITkPEpwwgePerUJgm7T1mq00vUBtbxJzG9cc+c=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References; b=d3ms/MR2k5LOGTtPGRDkwuCLi2G8rB81nsTznOJGaZkV+k25uwchzEmciZbppU1eA nWksV0mPh/51cIvG9usQ3NrS9hnxBDSUc1nZGCdIZ1MlWj8ojBMHqebWLgA/vJ9fIA FuaMC1KcKKhuJ/ioY1DM5xA7s2w74p2fNiMaTlW0= From: Thomas Jost To: notmuch@notmuchmail.org Subject: [PATCH 2/4] emacs: Move the "prompt for sender" code to a new function. Date: Wed, 25 May 2011 15:22:38 +0200 Message-Id: <1306329760-16665-2-git-send-email-schnouki@schnouki.net> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1306329760-16665-1-git-send-email-schnouki@schnouki.net> References: <87lixu7w71.fsf@thor.loria.fr> <1306329760-16665-1-git-send-email-schnouki@schnouki.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2011 13:23:04 -0000 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