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 oMFSHngJ+1/heAAA0tVLHw (envelope-from ) for ; Sun, 10 Jan 2021 14:04:40 +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 mPcAGngJ+18UcQAAB5/wlQ (envelope-from ) for ; Sun, 10 Jan 2021 14:04:40 +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 0CCE8940463 for ; Sun, 10 Jan 2021 14:04:40 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 42A962BF78; Sun, 10 Jan 2021 09:02:20 -0500 (EST) Received: from mail.hostpark.net (mail.hostpark.net [212.243.197.30]) by mail.notmuchmail.org (Postfix) with ESMTPS id 8BFEB29D11 for ; Sun, 10 Jan 2021 09:01:19 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id D08F1166B5 for ; Sun, 10 Jan 2021 15:01:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=sel2011a; t=1610287274; bh=YmWvn7Mapy9JAbq MMmhDqIgP2wQGDEbkVUuQHXdRPgk=; b=dzOfs+pmLZMvw2eJB+TemWtji6E414f saxR9tZoPKXxS38ieL556cXYmAA+SYHkULv0fAfzPhFFLqxOdLTKme2n5hIp7ygM KYZ/3L7StqirHapuHu+rJCSJTnvrNNeK7HGcHc3jN1XMtCjU+uUl1WS9M7p0Z9e4 nyRGkDgJuDIA= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id 7ENyosIJeY3M for ; Sun, 10 Jan 2021 15:01:14 +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 A15FF166B6 for ; Sun, 10 Jan 2021 15:01:14 +0100 (CET) From: Jonas Bernoulli To: notmuch@notmuchmail.org Subject: [PATCH v2 35/36] emacs: allow opting out of notmuch's address completion Date: Sun, 10 Jan 2021 15:01:11 +0100 Message-Id: <20210110140112.25930-36-jonas@bernoul.li> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20210110140112.25930-1-jonas@bernoul.li> References: <20201214162401.19569-1-jonas@bernoul.li> <20210110140112.25930-1-jonas@bernoul.li> MIME-Version: 1.0 Message-ID-Hash: YM6U4ASP3PKUCHY345D3M2XSXFFC64ND X-Message-ID-Hash: YM6U4ASP3PKUCHY345D3M2XSXFFC64ND 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-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 0.06 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=bernoul.li header.s=sel2011a header.b=dzOfs+pm; 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-Migadu-Queue-Id: 0CCE8940463 X-Spam-Score: 0.06 X-Migadu-Scanner: scn1.migadu.com X-TUID: zy73iKTnwKEc 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 ca24c744..6e136473 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -54,21 +54,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) @@ -160,12 +167,13 @@ (defun notmuch-address-message-insinuate () (message "calling notmuch-address-message-insinuate is no longer needed")) (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