--- /dev/null
+Return-Path: <sebastian.fischmeister@uwaterloo.ca>\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 85BC5431FBC\r
+ for <notmuch@notmuchmail.org>; Tue, 16 Sep 2014 05:53:15 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] 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 lBUQcDxCs3O2 for <notmuch@notmuchmail.org>;\r
+ Tue, 16 Sep 2014 05:53:09 -0700 (PDT)\r
+X-Greylist: delayed 312 seconds by postgrey-1.32 at olra;\r
+ Tue, 16 Sep 2014 05:53:09 PDT\r
+Received: from connect.uwaterloo.ca (connhub2.connect.uwaterloo.ca\r
+ [129.97.149.119]) (using TLSv1 with cipher AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 99E9E431FAE\r
+ for <notmuch@notmuchmail.org>; Tue, 16 Sep 2014 05:53:09 -0700 (PDT)\r
+Received: from CONNHUB4.connect.uwaterloo.ca (129.97.149.122) by\r
+ connhub2.connect.uwaterloo.ca (129.97.149.119) with Microsoft SMTP\r
+ Server (TLS) id 14.3.195.1; Tue, 16 Sep 2014 08:47:54 -0400\r
+Received: from uwaterloo.ca (188.20.152.214) by connhub4.connect.uwaterloo.ca\r
+ (129.97.149.122) with Microsoft SMTP Server (TLS) id 14.3.195.1;\r
+ Tue, 16 Sep 2014 08:47:53 -0400\r
+From: Sebastian Fischmeister <sfischme@uwaterloo.ca>\r
+To: <notmuch@notmuchmail.org>\r
+Subject: Better support for helm in the address completion\r
+User-Agent: Notmuch/0.18.1 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Homepage: http://esg.uwaterloo.ca\r
+Date: Tue, 16 Sep 2014 08:47:53 -0400\r
+Message-ID: <87vbonhgwe.fsf@uwaterloo.ca>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+Reply-To: sfischme@uwaterloo.ca\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: Tue, 16 Sep 2014 12:53:15 -0000\r
+\r
+Hi,\r
+\r
+I noticed that the completing-read in notmuch-address-selection-function\r
+was eating the first returned address when using helm. Here's a patch\r
+that fixes it. The defaults are as they used to be.\r
+\r
+For helm use:\r
+\r
+(setq notmuch-address-suggest-initial-match nil)\r
+\r
+If you don't want to enter a new address in the selection (with helm)\r
+use:\r
+\r
+(setq notmuch-address-require-match t)\r
+\r
+ Sebastian\r
+\r
+diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
+index fa65cd5..d9b66cd 100644\r
+--- a/emacs/notmuch-address.el\r
++++ b/emacs/notmuch-address.el\r
+@@ -42,11 +42,25 @@ to know how address selection is made by default."\r
+ :group 'notmuch-send\r
+ :group 'notmuch-external)\r
+ \r
++(defcustom notmuch-address-suggest-initial-match t\r
++ "Pass an initial match to the address completing read."\r
++ :type 'boolean\r
++ :group 'notmuch-send)\r
++\r
++(defcustom notmuch-address-require-match nil\r
++ "Require a match in the address selection in `notmuch-address-selection-function'."\r
++ :type 'boolean\r
++ :group 'notmuch-send)\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
++ prompt\r
++ (if notmuch-address-suggest-initial-match 'collection (list initial-input collection))\r
++ nil notmuch-address-require-match\r
++ (if notmuch-address-suggest-initial-match 'initial-input nil)\r
++ '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