[PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / e1 / ca8f99af93081e19e835d7a37d301aeb425667
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id 2CBFD6DE02C4\r
6  for <notmuch@notmuchmail.org>; Fri, 20 May 2016 13:13:34 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.318\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.318 tagged_above=-999 required=5 tests=[AWL=0.252,\r
12   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
15  autolearn=disabled\r
16 Received: from arlo.cworth.org ([127.0.0.1])\r
17  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
18  with ESMTP id WJvYFAwtgBYc for <notmuch@notmuchmail.org>;\r
19  Fri, 20 May 2016 13:13:26 -0700 (PDT)\r
20 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com\r
21  [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id 849C96DE0173 for\r
22  <notmuch@notmuchmail.org>; Fri, 20 May 2016 13:13:25 -0700 (PDT)\r
23 Received: by mail-wm0-f65.google.com with SMTP id q62so3807155wmg.3\r
24  for <notmuch@notmuchmail.org>; Fri, 20 May 2016 13:13:25 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
27  bh=UccHfVDFLI7UgDSXQTwrT3d+P9JOFAeOgKElCRfaWNM=;\r
28  b=IDaXfi3js9vqprv9CYTyWX3ZG3pfc2SDAHPGwKYZGRftphhZtRTVU0ULbK/n4IXahJ\r
29  HpYnrP65FS/NvH3nPGW+GDX1x71JcIvNlWqWUtkbK9y95wYxyHZ3CxT4Bq4Hxhvfzcbr\r
30  D5RLN4qzDOC77ewnV/T+p+XTIdG4XImI727h0TRZ7TO6AXw/nik/GB1LkzjijsfnJUq4\r
31  230dleve1KGSLA9oztpdWrcFbZ9fFdDEWAHmUsKI8lHeIxZz/4AcJOhkOPkiiUMtEaE+\r
32  nbc6dBRisYWX8SpGyY/aQlEXOCobykood4o2N5+ScVrgTOIwG2smwcncSIBGrjRw6KZk\r
33  /Xwg==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
37  :references;\r
38  bh=UccHfVDFLI7UgDSXQTwrT3d+P9JOFAeOgKElCRfaWNM=;\r
39  b=XNKzebBW1yrXgr31jfy8jT/nzr/aNUy0uaSCeHxsyzgNx0bcY9H8YFM8fhhHRXbKop\r
40  g4s3VzxQj1qkWjiz/claxjPf9858maj17CrlYKv+VgOkVKljs1HkGkDfqPNq4j+gpLdW\r
41  Pkpw7iw0yjARFEveBSQmB4qkH1UGA3WqwGarF32XYiWb2bZpwa3+l143YEXjevmzcLfE\r
42  Spo/7t5ljwNlAKKgr9zTioyN09Snw1MOkArQKrFINgsRRzFGdnHbGOugB/1GrAkJFJOE\r
43  6Ehn40CnMUFGaQOB+g5ELXQzCQtSleFIwXqJ2DU45uJUw4i82yBaUvggvOF3RmwsYLSJ\r
44  lLuw==\r
45 X-Gm-Message-State:\r
46  AOPr4FXzCxEZ1MfBf8EAftxCeDP/lyvw+nLNy8rvSSo3yzuoOOSmSUs3Y26dhHEAHSE/pA==\r
47 X-Received: by 10.194.205.105 with SMTP id lf9mr5040865wjc.25.1463775204205;\r
48  Fri, 20 May 2016 13:13:24 -0700 (PDT)\r
49 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
50  by smtp.gmail.com with ESMTPSA id 63sm6246571wmz.5.2016.05.20.13.13.23\r
51  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
52  Fri, 20 May 2016 13:13:23 -0700 (PDT)\r
53 From: Mark Walters <markwalters1009@gmail.com>\r
54 To: notmuch@notmuchmail.org\r
55 Subject: [PATCH 2/2] emacs: address: allow internal completion on an\r
56  individual basis\r
57 Date: Fri, 20 May 2016 21:13:03 +0100\r
58 Message-Id: <1463775183-16234-3-git-send-email-markwalters1009@gmail.com>\r
59 X-Mailer: git-send-email 2.1.4\r
60 In-Reply-To: <1463775183-16234-1-git-send-email-markwalters1009@gmail.com>\r
61 References: <1463775183-16234-1-git-send-email-markwalters1009@gmail.com>\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.20\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66  <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
68  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
73  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Fri, 20 May 2016 20:13:34 -0000\r
75 \r
76 This commit makes two changes. The first allows the user to override\r
77 an external completion method with the internal notmuch address based\r
78 completion for an individual buffer.\r
79 \r
80 Secondly, if the user has company-mode enabled then it sets up company\r
81 mode (based on internal completion) but disables the automatic timeout\r
82 completion -- the user can still activate it in when desired with\r
83 standard company commands such as company-complete.\r
84 ---\r
85  emacs/notmuch-address.el | 19 ++++++++++++++++---\r
86  emacs/notmuch-company.el |  8 +++++++-\r
87  2 files changed, 23 insertions(+), 4 deletions(-)\r
88 \r
89 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
90 index 3e7bdab..b5bd151 100644\r
91 --- a/emacs/notmuch-address.el\r
92 +++ b/emacs/notmuch-address.el\r
93 @@ -118,17 +118,30 @@ to know how address selection is made by default."\r
94    :group 'notmuch-send)\r
95  \r
96  (defun notmuch-address-setup ()\r
97 -  (let* ((use-company (and notmuch-address-use-company\r
98 -                          (eq notmuch-address-command 'internal)\r
99 +  (let* ((setup-company (and notmuch-address-use-company\r
100                            (require 'company nil t)))\r
101          (pair (cons notmuch-address-completion-headers-regexp\r
102                        #'notmuch-address-expand-name)))\r
103 -      (when use-company\r
104 +      (when setup-company\r
105         (notmuch-company-setup))\r
106        (unless (memq pair message-completion-alist)\r
107         (setq message-completion-alist\r
108               (push pair message-completion-alist)))))\r
109  \r
110 +(defun notmuch-address-toggle-internal-completion ()\r
111 +  "Toggle use of internal completion for current buffer.\r
112 +\r
113 +This overrides the global setting for address completion and\r
114 +toggles the setting in this buffer."\r
115 +  (interactive)\r
116 +  (if (local-variable-p 'notmuch-address-command)\r
117 +      (kill-local-variable 'notmuch-address-command)\r
118 +    (setq-local notmuch-address-command 'internal))\r
119 +  (if (boundp 'company-idle-delay)\r
120 +      (if (local-variable-p 'company-idle-delay)\r
121 +         (kill-local-variable 'company-idle-delay)\r
122 +       (setq-local company-idle-delay nil))))\r
123 +\r
124  (defun notmuch-address-matching (substring)\r
125    "Returns a list of completion candidates matching SUBSTRING.\r
126  The candidates are taken from `notmuch-address-completions'."\r
127 diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el\r
128 index dcb59cd..5febc49 100644\r
129 --- a/emacs/notmuch-company.el\r
130 +++ b/emacs/notmuch-company.el\r
131 @@ -47,7 +47,13 @@\r
132  (defun notmuch-company-setup ()\r
133    (company-mode)\r
134    (make-local-variable 'company-backends)\r
135 -  (setq company-backends '(notmuch-company)))\r
136 +  (setq company-backends '(notmuch-company))\r
137 +  ;; Disable automatic company completion unless an internal\r
138 +  ;; completion method is configured. Company completion (using\r
139 +  ;; internal completion) can still be accessed via standard company\r
140 +  ;; functions, e.g., company-complete.\r
141 +  (unless (eq notmuch-address-command 'internal)\r
142 +    (setq-local company-idle-delay nil)))\r
143  \r
144  ;;;###autoload\r
145  (defun notmuch-company (command &optional arg &rest _ignore)\r
146 -- \r
147 2.1.4\r
148 \r