From 2a2bd17474489636660d150a8741da3a37ad6726 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Fri, 20 May 2016 21:13:03 +0100 Subject: [PATCH] [PATCH 2/2] emacs: address: allow internal completion on an individual basis --- e1/ca8f99af93081e19e835d7a37d301aeb425667 | 148 ++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 e1/ca8f99af93081e19e835d7a37d301aeb425667 diff --git a/e1/ca8f99af93081e19e835d7a37d301aeb425667 b/e1/ca8f99af93081e19e835d7a37d301aeb425667 new file mode 100644 index 000000000..4b9cede65 --- /dev/null +++ b/e1/ca8f99af93081e19e835d7a37d301aeb425667 @@ -0,0 +1,148 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 2CBFD6DE02C4 + for ; Fri, 20 May 2016 13:13:34 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.318 +X-Spam-Level: +X-Spam-Status: No, score=-0.318 tagged_above=-999 required=5 tests=[AWL=0.252, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id WJvYFAwtgBYc for ; + Fri, 20 May 2016 13:13:26 -0700 (PDT) +Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com + [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id 849C96DE0173 for + ; Fri, 20 May 2016 13:13:25 -0700 (PDT) +Received: by mail-wm0-f65.google.com with SMTP id q62so3807155wmg.3 + for ; Fri, 20 May 2016 13:13:25 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=UccHfVDFLI7UgDSXQTwrT3d+P9JOFAeOgKElCRfaWNM=; + b=IDaXfi3js9vqprv9CYTyWX3ZG3pfc2SDAHPGwKYZGRftphhZtRTVU0ULbK/n4IXahJ + HpYnrP65FS/NvH3nPGW+GDX1x71JcIvNlWqWUtkbK9y95wYxyHZ3CxT4Bq4Hxhvfzcbr + D5RLN4qzDOC77ewnV/T+p+XTIdG4XImI727h0TRZ7TO6AXw/nik/GB1LkzjijsfnJUq4 + 230dleve1KGSLA9oztpdWrcFbZ9fFdDEWAHmUsKI8lHeIxZz/4AcJOhkOPkiiUMtEaE+ + nbc6dBRisYWX8SpGyY/aQlEXOCobykood4o2N5+ScVrgTOIwG2smwcncSIBGrjRw6KZk + /Xwg== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=UccHfVDFLI7UgDSXQTwrT3d+P9JOFAeOgKElCRfaWNM=; + b=XNKzebBW1yrXgr31jfy8jT/nzr/aNUy0uaSCeHxsyzgNx0bcY9H8YFM8fhhHRXbKop + g4s3VzxQj1qkWjiz/claxjPf9858maj17CrlYKv+VgOkVKljs1HkGkDfqPNq4j+gpLdW + Pkpw7iw0yjARFEveBSQmB4qkH1UGA3WqwGarF32XYiWb2bZpwa3+l143YEXjevmzcLfE + Spo/7t5ljwNlAKKgr9zTioyN09Snw1MOkArQKrFINgsRRzFGdnHbGOugB/1GrAkJFJOE + 6Ehn40CnMUFGaQOB+g5ELXQzCQtSleFIwXqJ2DU45uJUw4i82yBaUvggvOF3RmwsYLSJ + lLuw== +X-Gm-Message-State: + AOPr4FXzCxEZ1MfBf8EAftxCeDP/lyvw+nLNy8rvSSo3yzuoOOSmSUs3Y26dhHEAHSE/pA== +X-Received: by 10.194.205.105 with SMTP id lf9mr5040865wjc.25.1463775204205; + Fri, 20 May 2016 13:13:24 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by smtp.gmail.com with ESMTPSA id 63sm6246571wmz.5.2016.05.20.13.13.23 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 20 May 2016 13:13:23 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 2/2] emacs: address: allow internal completion on an + individual basis +Date: Fri, 20 May 2016 21:13:03 +0100 +Message-Id: <1463775183-16234-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1463775183-16234-1-git-send-email-markwalters1009@gmail.com> +References: <1463775183-16234-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 20 May 2016 20:13:34 -0000 + +This commit makes two changes. The first allows the user to override +an external completion method with the internal notmuch address based +completion for an individual buffer. + +Secondly, if the user has company-mode enabled then it sets up company +mode (based on internal completion) but disables the automatic timeout +completion -- the user can still activate it in when desired with +standard company commands such as company-complete. +--- + emacs/notmuch-address.el | 19 ++++++++++++++++--- + emacs/notmuch-company.el | 8 +++++++- + 2 files changed, 23 insertions(+), 4 deletions(-) + +diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el +index 3e7bdab..b5bd151 100644 +--- a/emacs/notmuch-address.el ++++ b/emacs/notmuch-address.el +@@ -118,17 +118,30 @@ to know how address selection is made by default." + :group 'notmuch-send) + + (defun notmuch-address-setup () +- (let* ((use-company (and notmuch-address-use-company +- (eq notmuch-address-command 'internal) ++ (let* ((setup-company (and notmuch-address-use-company + (require 'company nil t))) + (pair (cons notmuch-address-completion-headers-regexp + #'notmuch-address-expand-name))) +- (when use-company ++ (when setup-company + (notmuch-company-setup)) + (unless (memq pair message-completion-alist) + (setq message-completion-alist + (push pair message-completion-alist))))) + ++(defun notmuch-address-toggle-internal-completion () ++ "Toggle use of internal completion for current buffer. ++ ++This overrides the global setting for address completion and ++toggles the setting in this buffer." ++ (interactive) ++ (if (local-variable-p 'notmuch-address-command) ++ (kill-local-variable 'notmuch-address-command) ++ (setq-local notmuch-address-command 'internal)) ++ (if (boundp 'company-idle-delay) ++ (if (local-variable-p 'company-idle-delay) ++ (kill-local-variable 'company-idle-delay) ++ (setq-local company-idle-delay nil)))) ++ + (defun notmuch-address-matching (substring) + "Returns a list of completion candidates matching SUBSTRING. + The candidates are taken from `notmuch-address-completions'." +diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el +index dcb59cd..5febc49 100644 +--- a/emacs/notmuch-company.el ++++ b/emacs/notmuch-company.el +@@ -47,7 +47,13 @@ + (defun notmuch-company-setup () + (company-mode) + (make-local-variable 'company-backends) +- (setq company-backends '(notmuch-company))) ++ (setq company-backends '(notmuch-company)) ++ ;; Disable automatic company completion unless an internal ++ ;; completion method is configured. Company completion (using ++ ;; internal completion) can still be accessed via standard company ++ ;; functions, e.g., company-complete. ++ (unless (eq notmuch-address-command 'internal) ++ (setq-local company-idle-delay nil))) + + ;;;###autoload + (defun notmuch-company (command &optional arg &rest _ignore) +-- +2.1.4 + -- 2.26.2