[PATCH 2/2] emacs: Cleaner interface when prompting for sender address
authorThomas Jost <schnouki@schnouki.net>
Fri, 27 May 2011 09:15:00 +0000 (11:15 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:38:24 +0000 (09:38 -0800)
40/a6e8a2f00786c47f5b71ff2972797415c146b7 [new file with mode: 0644]

diff --git a/40/a6e8a2f00786c47f5b71ff2972797415c146b7 b/40/a6e8a2f00786c47f5b71ff2972797415c146b7
new file mode 100644 (file)
index 0000000..943faa8
--- /dev/null
@@ -0,0 +1,133 @@
+Return-Path: <schnouki@schnouki.net>\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 DB865429E2D\r
+       for <notmuch@notmuchmail.org>; Fri, 27 May 2011 02:15:24 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1]\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 QUaziOEaIq0n for <notmuch@notmuchmail.org>;\r
+       Fri, 27 May 2011 02:15:24 -0700 (PDT)\r
+Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])\r
+       by olra.theworths.org (Postfix) with ESMTP id D35BE429E2B\r
+       for <notmuch@notmuchmail.org>; Fri, 27 May 2011 02:15:23 -0700 (PDT)\r
+Received: from localhost.localdomain (thor.loria.fr [152.81.12.250])\r
+       by ks3536.kimsufi.com (Postfix) with ESMTPSA id D459D6A06AD;\r
+       Fri, 27 May 2011 11:15:22 +0200 (CEST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;\r
+       s=key-schnouki; t=1306487722;\r
+       bh=4ZGWJpwZPAz5OkQ8JPB5PqQoStQFjzjJ3rs6zrr6hOc=;\r
+       h=From:To:Subject:Date:Message-Id:In-Reply-To:References;\r
+       b=UuqqhFuxp/k6pioi/PTBKZSyKB5A2wVeZ87OXzoojuoeKnODm7t8UhFbBc6D8HvtZ\r
+       qUMig7IMtvZ3VGImgMQJFybePyxuHkrcfn9u+EWHXCAQQwWtbtAkDZJb0LXbn4o4uG\r
+       XuShxYaDUyNmJzNDtv7NeCMo95EPfXdF702ceahA=\r
+From: Thomas Jost <schnouki@schnouki.net>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>,\r
+       Carl Worth <cworth@cworth.org>, Stewart Smith <stewart@flamingspork.com>,\r
+       notmuch <notmuch@notmuchmail.org>\r
+Subject: [PATCH 2/2] emacs: Cleaner interface when prompting for sender\r
+ address\r
+Date: Fri, 27 May 2011 11:15:00 +0200\r
+Message-Id: <1306487700-21358-2-git-send-email-schnouki@schnouki.net>\r
+X-Mailer: git-send-email 1.7.5.2\r
+In-Reply-To: <1306487700-21358-1-git-send-email-schnouki@schnouki.net>\r
+References: <87mxi9ytvt.fsf@servo.factory.finestructure.net>\r
+       <1306487700-21358-1-git-send-email-schnouki@schnouki.net>\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: Fri, 27 May 2011 09:15:25 -0000\r
+\r
+Most of the time, every entry in the list of identities has the same user name\r
+part. It can then be filled in automatically, and the user can only be prompted\r
+for the email address, which makes the interface much cleaner.\r
+---\r
+Hi Jameson,\r
+\r
+Once again, a very good suggestion. I had doubts at first (because I sometimes\r
+send mails using a nickname or on behalf of a group using that group's name),\r
+but then I noticed I already had only one name in notmuch-identities :) So\r
+here's a patch.\r
+\r
+It handle 3 different cases:\r
+- notmuch-identities is not set --> only one name\r
+- notmuch-identities set with only one name\r
+- notmuch-identities set with several different names\r
+\r
+I tried to make it as compact and readable as possible, so the first two cases\r
+are handled by a single call to ido-completing-read. But there is probably still\r
+room for improvements: reviews, comments and suggestions are welcome.\r
+\r
+Regards,\r
+Thomas\r
+\r
+ emacs/notmuch-mua.el |   33 +++++++++++++++++++++++----------\r
+ 1 files changed, 23 insertions(+), 10 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 556d2bf..274c5da 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -162,20 +162,33 @@ the From: header is already filled in by notmuch."\r
+   :group 'notmuch\r
+   :type 'boolean)\r
\r
+-(defun notmuch-mua-sender-collection ()\r
+-  (if notmuch-identities\r
+-      notmuch-identities\r
+-    (mapcar (lambda (address)\r
+-            (concat (notmuch-user-name) " <" address ">"))\r
+-          (cons (notmuch-user-primary-email) (notmuch-user-other-email)))))\r
+-\r
+ (defvar notmuch-mua-sender-history nil)\r
\r
+ (defun notmuch-mua-prompt-for-sender ()\r
+   (interactive)\r
+-  (let ((collection (notmuch-mua-sender-collection)))\r
+-    (ido-completing-read "Send mail From: " collection\r
+-                       nil 'confirm nil 'notmuch-mua-sender-history (car collection))))\r
++  (let (name addresses one-name-only)\r
++    ;; If notmuch-identities is non-nil, check if there is a fixed user name.\r
++    (if notmuch-identities\r
++      (let ((components (mapcar 'mail-extract-address-components notmuch-identities)))\r
++        (setq name          (caar components)\r
++              addresses     (mapcar 'cadr components)\r
++              one-name-only (eval\r
++                             (cons 'and\r
++                                   (mapcar (lambda (identity)\r
++                                             (string-equal name (car identity)))\r
++                                           components)))))\r
++      ;; If notmuch-identities is nil, use values from the notmuch configuration file.\r
++      (setq name          (notmuch-user-name)\r
++          addresses     (cons (notmuch-user-primary-email) (notmuch-user-other-email))\r
++          one-name-only t))\r
++    ;; Now prompt the user, either for an email address only or for a full identity.\r
++    (if one-name-only\r
++      (let ((address\r
++             (ido-completing-read (concat "Sender address for " name ": ") addresses\r
++                                  nil nil nil 'notmuch-mua-sender-history (car addresses))))\r
++        (concat name " <" address ">"))\r
++      (ido-completing-read "Send mail From: " notmuch-identities\r
++                         nil nil nil 'notmuch-mua-sender-history (car notmuch-identities)))))\r
\r
+ (defun notmuch-mua-new-mail (&optional prompt-for-sender)\r
+   "Invoke the notmuch mail composition window.\r
+-- \r
+1.7.5.2\r
+\r