From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id N/stNlN7qF/CfwAA0tVLHw (envelope-from ) for ; Sun, 08 Nov 2020 23:12:19 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id zGNrMVN7qF9yAgAAB5/wlQ (envelope-from ) for ; Sun, 08 Nov 2020 23:12:19 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 021709407C8 for ; Sun, 8 Nov 2020 23:12:16 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id A1EBC28BED; Sun, 8 Nov 2020 18:12:00 -0500 (EST) Received: from mail.hostpark.net (mail.hostpark.net [212.243.197.30]) by mail.notmuchmail.org (Postfix) with ESMTPS id 783B8270EF for ; Sun, 8 Nov 2020 18:11:53 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 1E289160CE for ; Mon, 9 Nov 2020 00:11:51 +0100 (CET) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id zsn2Ys1gGGOH for ; Mon, 9 Nov 2020 00:11:50 +0100 (CET) Received: from customer (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id CDF9D160AE for ; Mon, 9 Nov 2020 00:11:50 +0100 (CET) From: Jonas Bernoulli To: notmuch@notmuchmail.org Subject: [PATCH 2/3] emacs: allow opting out of notmuch's address completion Date: Mon, 9 Nov 2020 00:11:49 +0100 Message-Id: <20201108231150.5419-3-jonas@bernoul.li> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201108231150.5419-1-jonas@bernoul.li> References: <20201108231150.5419-1-jonas@bernoul.li> MIME-Version: 1.0 Message-ID-Hash: IU67NQSKT2M2VIX7BXXL2AIHRIIKNCNQ X-Message-ID-Hash: IU67NQSKT2M2VIX7BXXL2AIHRIIKNCNQ X-MailFrom: jonas@bernoul.li X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: -0.01 X-TUID: 6yf11bioH5W+ IMO Notmuch should not override the default completion mechanism by default, at least not globally. But since users are already used to this behavior it is probably too late to change it. Do the next best thing and at least allow users to opt out. --- emacs/notmuch-address.el | 48 +++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index 3518beef..6e29b99a 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -52,21 +52,28 @@ (defun notmuch-address--harvest-ready () (defcustom notmuch-address-command 'internal "Determines how address completion candidates are generated. -If it is a string then that string should be an external program -which must take a single argument (searched string) and output a -list of completion candidates, one per line. - -Alternatively, it can be the symbol `internal', in which case -internal completion is used; the variable -`notmuch-address-internal-completion' can be used to customize -this case. - -Finally, if this variable is nil then address completion is -disabled." +If this is a string, then that string should be an external +program, which must take a single argument (searched string) +and output a list of completion candidates, one per line. + +If this is the symbol `internal', then an implementation is used +that relies on the \"notmuch address\" command, but does not use +any third-party (i.e. \"external\") programs. + +If this is the symbol `as-is', then Notmuch does not modify the +value of `message-completion-alist'. This option has to be set to +this value before `notmuch' is loaded, otherwise the modification +to `message-completion-alist' may already have taken place. This +setting obviously does not prevent `message-completion-alist' +from being modified at all; the user or some third-party package +may still modify it. + +Finally, if this is nil, then address completion is disabled." :type '(radio - (const :tag "Use internal address completion" internal) - (const :tag "Disable address completion" nil) - (string :tag "Use external completion command")) + (const :tag "Use internal address completion" internal) + (string :tag "Use external completion command") + (const :tag "Disable address completion" nil) + (const :tag "Use default or third-party mechanism" as-is)) :group 'notmuch-send :group 'notmuch-address :group 'notmuch-external) @@ -156,12 +163,13 @@ (defcustom notmuch-address-use-company t :group 'notmuch-address) (defun notmuch-address-setup () - (when (and notmuch-address-use-company - (require 'company nil t)) - (notmuch-company-setup)) - (cl-pushnew (cons notmuch-address-completion-headers-regexp - #'notmuch-address-expand-name) - message-completion-alist :test #'equal)) + (unless (eq notmuch-address-command 'as-is) + (when (and notmuch-address-use-company + (require 'company nil t)) + (notmuch-company-setup)) + (cl-pushnew (cons notmuch-address-completion-headers-regexp + #'notmuch-address-expand-name) + message-completion-alist :test #'equal))) (defun notmuch-address-toggle-internal-completion () "Toggle use of internal completion for current buffer. -- 2.29.1