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