--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 2117B6DE1766\r
+ for <notmuch@notmuchmail.org>; Sun, 25 Oct 2015 06:02:22 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.11\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.11 tagged_above=-999 required=5 tests=[AWL=0.460, \r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Sj4MSccq9ouh for <notmuch@notmuchmail.org>;\r
+ Sun, 25 Oct 2015 06:02:20 -0700 (PDT)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+ [209.85.212.181])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id C9D8B6DE1472\r
+ for <notmuch@notmuchmail.org>; Sun, 25 Oct 2015 06:02:19 -0700 (PDT)\r
+Received: by wijp11 with SMTP id p11so131538585wij.0\r
+ for <notmuch@notmuchmail.org>; Sun, 25 Oct 2015 06:02:17 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=pZjHvBriRr3V8fxgQ3KnQsbNnP/1ZzjhmoKN2xVA47E=;\r
+ b=sBEvwLYX3l0X1kJC2dMuWiWKhlQ7d/8U0UsLngBuDyTRfiFgzRXuKoNdTCPvJ+LJup\r
+ ssKPNNJu/yMpqp3kW+0Mfrhc1Y9pkghnCVvirmlvIBu94G+csPVh8udb9mKZqttw3YjW\r
+ ppH0PEVf8pc6P0CeIvGoVUDduLgp0C0zgi2tFYDQ5CSiFc3DxP8d66GZInljsO+pYkY9\r
+ IPAEaaIp7BH9VfqvH/xnSly+NuvkByITB5oDPbCZLWVjEnB75GOVIZF1v+clyYhbvrFA\r
+ RDgQ+vsrhNICEwfoGzNNYNW9PIun84GBPa1Ma24AJ4iEBPGtbqPhjHzErqogvi+T75ud\r
+ Pqig==\r
+X-Received: by 10.194.81.74 with SMTP id y10mr14172505wjx.110.1445778137719;\r
+ Sun, 25 Oct 2015 06:02:17 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id ka10sm33472047wjc.30.2015.10.25.06.02.14\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sun, 25 Oct 2015 06:02:14 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] address completion tweaks\r
+Date: Sun, 25 Oct 2015 13:02:11 +0000\r
+Message-Id: <1445778131-3004-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1445764618-29250-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1445764618-29250-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 25 Oct 2015 13:02:22 -0000\r
+\r
+If the user has company installed and notmuch is configured to use it,\r
+then use it for all the completions. In particular, pressing tab now\r
+forces company to run immediately.\r
+\r
+In addition this patch fixes a semi-bug where address completion was\r
+used for more headers than company mode was. With the change above\r
+this became important. Thus make company mode work for all headers\r
+that address completion does.\r
+---\r
+\r
+I think this is an improvement: without pressing tab quickly brings up\r
+the normal mini-buffer completion mode, but waiting a second means\r
+company has started and then tab doesn't bring up the mini-buffer.\r
+\r
+The change in notmuch-mua is just so that company-setup runs before we\r
+setup the message-completion-alist.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+emacs/notmuch-address.el | 7 ++++---\r
+ emacs/notmuch-company.el | 5 +++--\r
+ emacs/notmuch-mua.el | 10 +++++-----\r
+ 3 files changed, 12 insertions(+), 10 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
+index 228135e..0a73ddf 100644\r
+--- a/emacs/notmuch-address.el\r
++++ b/emacs/notmuch-address.el\r
+@@ -64,9 +64,11 @@ (defun notmuch-address-selection-function (prompt collection initial-input)\r
+ (completing-read\r
+ prompt collection nil nil initial-input 'notmuch-address-history))\r
+ \r
++(defvar notmuch-address-completion-headers-regexp\r
++ "^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):")\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
++ (cons notmuch-address-completion-headers-regexp 'notmuch-address-expand-name))\r
+ \r
+ (defvar notmuch-address-history nil)\r
+ \r
+@@ -221,7 +223,6 @@ (defun notmuch-address-harvest-trigger ()\r
+ (if (string= event "finished\n")\r
+ (setq notmuch-address-full-harvest-finished t)\r
+ (setq notmuch-address-last-harvest 0)))))))\r
+-\r
+ ;;\r
+ \r
+ (provide 'notmuch-address)\r
+diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el\r
+index 9e57914..3157ed7 100644\r
+--- a/emacs/notmuch-company.el\r
++++ b/emacs/notmuch-company.el\r
+@@ -41,6 +41,8 @@ (defvar company-backends)\r
+ ;;;###autoload\r
+ (defun notmuch-company-setup ()\r
+ (company-mode)\r
++ (setq notmuch-address-message-alist-member\r
++ (cons notmuch-address-completion-headers-regexp 'company-manual-begin))\r
+ (make-local-variable 'company-backends)\r
+ (setq company-backends '(notmuch-company)))\r
+ \r
+@@ -54,7 +56,7 @@ (defun notmuch-company (command &optional arg &rest _ignore)\r
+ (case command\r
+ (interactive (company-begin-backend 'notmuch-company))\r
+ (prefix (and (derived-mode-p 'message-mode)\r
+- (looking-back "^\\(To\\|Cc\\|Bcc\\):.*"\r
++ (looking-back (concat notmuch-address-completion-headers-regexp ".*")\r
+ (line-beginning-position))\r
+ (setq notmuch-company-last-prefix (company-grab "[:,][ \t]*\\(.*\\)" 1 (point-at-bol)))))\r
+ (candidates (cond\r
+@@ -77,5 +79,4 @@ (defun notmuch-company (command &optional arg &rest _ignore)\r
+ 0))\r
+ (no-cache t))))\r
+ \r
+-\r
+ (provide 'notmuch-company)\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 63fc8db..8cbf38c 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -276,13 +276,13 @@ (defcustom notmuch-message-use-company t\r
+ (define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"\r
+ "Notmuch message composition mode. Mostly like `message-mode'"\r
+ (when notmuch-address-command\r
++ (when (and notmuch-message-use-company\r
++ (eq notmuch-address-command 'internal)\r
++ (require 'company nil t))\r
++ (notmuch-company-setup))\r
+ (unless (memq notmuch-address-message-alist-member message-completion-alist)\r
+ (setq message-completion-alist\r
+- (push notmuch-address-message-alist-member message-completion-alist))))\r
+- (when (and notmuch-message-use-company\r
+- (eq notmuch-address-command 'internal)\r
+- (require 'company nil t))\r
+- (notmuch-company-setup)))\r
++ (push notmuch-address-message-alist-member message-completion-alist)))))\r
+ \r
+ (define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)\r
+ (define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send)\r
+-- \r
+2.1.4\r
+\r