--- /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 6BBBD6DE0281\r
+ for <notmuch@notmuchmail.org>; Fri, 20 May 2016 13:13:26 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.182\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.182 tagged_above=-999 required=5 tests=[AWL=-0.248,\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, FREEMAIL_REPLY=1,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,\r
+ 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 0FBO0F28V99r for <notmuch@notmuchmail.org>;\r
+ Fri, 20 May 2016 13:13:18 -0700 (PDT)\r
+Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com\r
+ [74.125.82.48]) by arlo.cworth.org (Postfix) with ESMTPS id 0F6E66DE01CE for\r
+ <notmuch@notmuchmail.org>; Fri, 20 May 2016 13:13:18 -0700 (PDT)\r
+Received: by mail-wm0-f48.google.com with SMTP id v200so2818136wmv.0\r
+ for <notmuch@notmuchmail.org>; Fri, 20 May 2016 13:13: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;\r
+ bh=di1RZqcqxyYRh+BASsJS1UDdmRgJtVtovHAKBWtI60E=;\r
+ b=yTjJ75N1BpirPdvPp0Pz+mtEawM9CuVH1cNpia3bDGVHmKlzkgcu2BjuJwWgfFYLUe\r
+ Y/tgL7Hb2Rk9o4NxEdMg9mbP8dbNpKONhuOLLrwGcWpkgCHiH5UfqkQqeH1ob9OPdf9w\r
+ DsyL/4IHyMSvmCz+7zplRmckGFQ8q23NyZs1Aq0FzbykkClAQItZWnNVCWN1qDVUafyH\r
+ PWNM2/OqJ7a3OnfbS+pj8eNHfLSE2TJUg5MeKcevZPJdntm1TUpXPa+nSYrJEGaXW+V9\r
+ JgZJUtfsK50He2Th8RD5V5HZFkZ/SA2ezttjIiwavpO4Hvt57FCxwhDMfPmVvGz8ZyjU\r
+ Us8g==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
+ bh=di1RZqcqxyYRh+BASsJS1UDdmRgJtVtovHAKBWtI60E=;\r
+ b=c3iZYCTtS/hzQfbblY2ckf+9E/SFSNfpGh8aK6khySiThyjWvDcQxkOseI4PUUcMV3\r
+ VO5bZxSkTV94trQi3NvGGFzHNEoOD/fFbIaGn71pkqX+14SV01RjSQaOHEsF5cBX1ilY\r
+ PqnUdFCg1axjQ28q5FNEnW4AsiZMnvkePU6An0D2znQYB1WknNEOJdWFr85Z+v+anP0J\r
+ etFTXF+kcg5CMK8N88FoXBra/sQBSdzoz2S4BTwcjaFnZgM33iusHevnsGNrjsA7HSNT\r
+ cQFRa/a64LUch0nZvQat+AHl/WWqqy9Ca4+KGmka8wlxuh5ezEXCdoaeTS66AlYdslOW\r
+ jsVA==\r
+X-Gm-Message-State:\r
+ AOPr4FVQgfNV6IhgDom9MGhFxzMRJUozYUAs5FgvIJwYzBSP53n0838LkXlW/jcGkmaG0A==\r
+X-Received: by 10.28.56.4 with SMTP id f4mr5289227wma.70.1463775196014;\r
+ Fri, 20 May 2016 13:13:16 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id ug8sm21346747wjc.42.2016.05.20.13.13.13\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Fri, 20 May 2016 13:13:13 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 0/2] Address completion configuration\r
+Date: Fri, 20 May 2016 21:13:01 +0100\r
+Message-Id: <1463775183-16234-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\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: Fri, 20 May 2016 20:13:26 -0000\r
+\r
+These two patches allow some customization of the notmuch-address\r
+completion.\r
+\r
+The first patch is very similar to the patch at\r
+id:1463558813-23603-1-git-send-email-markwalters1009@gmail.com\r
+\r
+The second allows the user to use the internal completion on a case by\r
+case basis. Typically this would be useful for users who normally use\r
+some external command for completion, but would like to use the\r
+internal completion when that fails.\r
+\r
+This necessitated some changes to the first patch: it made sense to\r
+separate the customisation of the internal address (as this will be\r
+also used for the case by case uses of the internal completion) from\r
+the choice of whether to use internal or external completion by\r
+default. I include the inter-diff of the first patch and the previous\r
+version at\r
+id:1463558813-23603-1-git-send-email-markwalters1009@gmail.com at the\r
+end of this email.\r
+\r
+The downside is that it does mean there is an extra defcustom, but the\r
+code is slightly cleaner.\r
+\r
+It might make sense to have a keybinding for company-complete\r
+and/or notmuch-address-toggle-internal-completion in\r
+notmuch-mesage-mode but I had no idea what bindings would make sense.\r
+\r
+I don't know how many people still use external completion -- but the\r
+extra complexity on top of the previous version is fairly small. Also,\r
+I haven't tested this heavily -- and there are quite a lot of cases.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+\r
+Mark Walters (2):\r
+ emacs: address completion, allow sender/recipient and filters\r
+ emacs: address: allow internal completion on an individual basis\r
+\r
+ emacs/notmuch-address.el | 154 ++++++++++++++++++++++++++++++++++-------------\r
+ emacs/notmuch-company.el | 10 ++-\r
+ emacs/notmuch-mua.el | 3 +-\r
+ 3 files changed, 121 insertions(+), 46 deletions(-)\r
+\r
+\r
+inter-diff from id:1463558813-23603-1-git-send-email-markwalters1009@gmail.com \r
+\r
+diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
+index 62df8ba..3e7bdab 100644\r
+--- a/emacs/notmuch-address.el\r
++++ b/emacs/notmuch-address.el\r
+@@ -39,34 +39,45 @@\r
+ "t indicates that full completion address harvesting has been\r
+ finished")\r
+ \r
+-(defcustom notmuch-address-command '(sent nil)\r
+- "Determines how to generate address completion candidates.\r
++(defcustom notmuch-address-command 'internal\r
++ "Determines how address completion candidates are generated.\r
+ \r
+ If it is a string then that string should be an external program\r
+ which must take a single argument (searched string) and output a\r
+ list of completion candidates, one per line.\r
+ \r
+-Alternatively, it can be a (non-nil) list, in which case internal\r
+-completion is used; in this case the list should have form\r
+-'(DIRECTION FILTER), where DIRECTION is either sent or received\r
+-and specifies whether the candidates are searched in messages\r
+-sent by the user or received by the user (note received by is\r
+-much faster), and FILTER is either nil or a filter-string, such\r
+-as \"date:1y..\" to append to the query.\r
++Alternatively, it can be the symbol 'internal, in which case\r
++internal completion is used; the variable\r
++`notmuch-address-internal-completion` can be used to customize\r
++this case.\r
+ \r
+-If this variable is nil then address completion is disabled."\r
++Finally, if this variable is nil then address completion is\r
++disabled."\r
+ :type '(radio\r
+- (list :tag "Use internal address completion"\r
+- (radio\r
+- :tag "Base completion on messages you have"\r
+- :value sent\r
+- (const :tag "sent (more accurate)" sent)\r
+- (const :tag "received (faster)" received))\r
+- (radio :tag "Filter messages used for completion"\r
+- (const :tag "Use all messages" nil)\r
+- (string :tag "Filter query")))\r
++ (const :tag "Use internal address completion" internal)\r
+ (const :tag "Disable address completion" nil)\r
+ (string :tag "Use external completion command"))\r
++ :group 'notmuch-send\r
++ :group 'notmuch-external)\r
++\r
++(defcustom notmuch-address-internal-completion '(sent nil)\r
++ "Determines how internal address completion generates candidates.\r
++\r
++This should be a list of the form '(DIRECTION FILTER), where\r
++ DIRECTION is either sent or received and specifies whether the\r
++ candidates are searched in messages sent by the user or received\r
++ by the user (note received by is much faster), and FILTER is\r
++ either nil or a filter-string, such as \"date:1y..\" to append\r
++ to the query."\r
++ :type '(list :tag "Use internal address completion"\r
++ (radio\r
++ :tag "Base completion on messages you have"\r
++ :value sent\r
++ (const :tag "sent (more accurate)" sent)\r
++ (const :tag "received (faster)" received))\r
++ (radio :tag "Filter messages used for completion"\r
++ (const :tag "Use all messages" nil)\r
++ (string :tag "Filter query")))\r
+ ;; We override set so that we can clear the cache when this changes\r
+ :set (lambda (symbol value)\r
+ (set-default symbol value)\r
+@@ -108,13 +119,10 @@ to know how address selection is made by default."\r
+ \r
+ (defun notmuch-address-setup ()\r
+ (let* ((use-company (and notmuch-address-use-company\r
+- notmuch-address-command\r
+- (listp notmuch-address-command)\r
++ (eq notmuch-address-command 'internal)\r
+ (require 'company nil t)))\r
+ (pair (cons notmuch-address-completion-headers-regexp\r
+- (if use-company\r
+- #'company-manual-begin\r
+- #'notmuch-address-expand-name))))\r
++ #'notmuch-address-expand-name)))\r
+ (when use-company\r
+ (notmuch-company-setup))\r
+ (unless (memq pair message-completion-alist)\r
+@@ -137,7 +145,7 @@ The candidates are taken from `notmuch-address-completions'."\r
+ elisp-based implementation or older implementation requiring\r
+ external commands."\r
+ (cond\r
+- ((and notmuch-address-command (listp notmuch-address-command))\r
++ ((eq notmuch-address-command 'internal)\r
+ (when (not notmuch-address-full-harvest-finished)\r
+ ;; First, run quick synchronous harvest based on what the user\r
+ ;; entered so far\r
+@@ -149,7 +157,12 @@ external commands."\r
+ (process-lines notmuch-address-command original))))\r
+ \r
+ (defun notmuch-address-expand-name ()\r
+- (when notmuch-address-command\r
++ (cond\r
++ ((and (eq notmuch-address-command 'internal)\r
++ notmuch-address-use-company\r
++ (bound-and-true-p company-mode))\r
++ (company-manual-begin))\r
++ (notmuch-address-command\r
+ (let* ((end (point))\r
+ (beg (save-excursion\r
+ (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")\r
+@@ -175,7 +188,8 @@ external commands."\r
+ (delete-region beg end)\r
+ (insert chosen))\r
+ (message "No matches.")\r
+- (ding)))))\r
++ (ding))))\r
++ (t nil)))\r
+ \r
+ ;; Copied from `w3m-which-command'.\r
+ (defun notmuch-address-locate-command (command)\r
+@@ -232,8 +246,8 @@ Address harvesting may take some time so the address collection runs\r
+ asynchronously unless SYNCHRONOUS is t. In case of asynchronous\r
+ execution, CALLBACK is called when harvesting finishes."\r
+ \r
+- (let* ((sent (eq (car notmuch-address-command) 'sent))\r
+- (config-query (cadr notmuch-address-command))\r
++ (let* ((sent (eq (car notmuch-address-internal-completion) 'sent))\r
++ (config-query (cadr notmuch-address-internal-completion))\r
+ (prefix-query (when addr-prefix\r
+ (format "%s:%s*" (if sent "to" "from") addr-prefix)))\r
+ (from-or-to-me-query\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 399e138..93a4d4b 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -276,8 +276,7 @@ mutiple parts get a header."\r
+ \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
+- (notmuch-address-setup)))\r
++ (notmuch-address-setup))\r
+ \r
+ (put 'notmuch-message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)\r
+ \r
+\r