From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alexander Adolf Newsgroups: gmane.emacs.bugs Subject: bug#59314: 29.0.50; EUDC and message-mode header completion Date: Mon, 12 Dec 2022 23:10:39 +0100 Message-ID: <7e3a877bcb178da3a5a4be518c7567f1@condition-alpha.com> References: <87a64q7p25.fsf@ericabrahamsen.net> <878rka1y4n.fsf@ericabrahamsen.net> <9cad334f4f42725f2e244c8c81528856@condition-alpha.com> <4d1810369df651d02ceeb522b8f05370@condition-alpha.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24615"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eric Abrahamsen , 59314@debbugs.gnu.org To: Thomas Fitzsimmons Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 12 23:11:24 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p4r1A-0006El-Fy for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 12 Dec 2022 23:11:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4r0s-0004hS-6w; Mon, 12 Dec 2022 17:11:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4r0p-0004ek-5Q for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2022 17:11:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p4r0o-0002nf-Ko for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2022 17:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p4r0o-0004o0-AD for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2022 17:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alexander Adolf Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Dec 2022 22:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59314 X-GNU-PR-Package: emacs Original-Received: via spool by 59314-submit@debbugs.gnu.org id=B59314.167088304618459 (code B ref 59314); Mon, 12 Dec 2022 22:11:02 +0000 Original-Received: (at 59314) by debbugs.gnu.org; 12 Dec 2022 22:10:46 +0000 Original-Received: from localhost ([127.0.0.1]:55707 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4r0X-0004nd-Oy for submit@debbugs.gnu.org; Mon, 12 Dec 2022 17:10:46 -0500 Original-Received: from smtprelay08.ispgateway.de ([134.119.228.98]:1208) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4r0V-0004nT-D7 for 59314@debbugs.gnu.org; Mon, 12 Dec 2022 17:10:45 -0500 Original-Received: from [46.244.193.233] (helo=condition-alpha.com) by smtprelay08.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1p4r0h-0007Uy-Cx; Mon, 12 Dec 2022 23:10:55 +0100 In-Reply-To: X-Df-Sender: YWxleGFuZGVyLmFkb2xmQGNvbmRpdGlvbi1hbHBoYS5jb20= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250755 Archived-At: --=-=-= Content-Type: text/plain Hello Thomas, Thomas Fitzsimmons writes: > [...] > The scenario I'd like you to make work with a minimal patch is: > Scenario 3+1 + (setq message-expand-name-standard-ui t). > > Did you try that? Yes. > I'm pretty sure if you get that working you'll find that we don't need > eudc-capf-complete in completion-at-point-functions (yet), since what > was there will already do what eudc-capf-complete was trying to > achieve. > > Basically, this whole part of the discussion I've been thinking in terms > of "(setq message-expand-name-standard-ui t)". > > When message-expand-name-standard-ui is nil, I think we've determined > that eudc-capf-complete's presence in completion-at-point-functions > breaks EUDC functionality. Do you concur? Yes. > If that's the case we should probably remove eudc-capf-complete from > completion-at-point-functions for Emacs 29.1, since that would > represent a regression. That's one option of addressing this case. The other option would be to apply the last patch I sent to add `(setq-local completion-styles...)` to `eudc-capf-complete` (because this is a defect and needs to be added in any case). Albeit with an updated message, because the message pretends to fix the bug, which it apparently doesn't. My preferred outcome would thus be: 1) Re-remove the `(add-hook 'completion-at-point-functions #'eudc-capf-complete ...)` line from message.el. 2) Add the `(setq-local completion-styles ...)` fix to `eudc-capf-complete`. 3) See if we can figure a root cause for the completion styles breakage within reasonable time and effort. The attached patch implements 1) and 2). > I now understand that the intent of the code that was there before we > added eudc-capf-complete was: > > message-expand-name-standard-ui nil => use EUDC multi-selector UI > message-expand-name-standard-ui t => use completion-at-point selector UI > > But the second case was already broken before we added > eudc-capf-complete. Indeed. And it also broken when not using EUDC at all, as I reported in my last message ('eudc removed from `message-expand-name-databases`). > I want to understand and fix that case. > [...] My suspicion is that something about the completion styles was changed. Mu next step would hence be to meditate over the `git blame` of minibuffer.el. Looking forward to your thoughts, --alexander --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Untangle-EUDC-s-completion-at-point-function-from-me.patch >From bd57cde6c45bf055c900767a4ff4ee817d25810b Mon Sep 17 00:00:00 2001 From: Alexander Adolf Date: Fri, 9 Dec 2022 22:15:42 +0100 Subject: [PATCH] Untangle EUDC's completion-at-point function from message-mode The default completion-styles turned out to not be generous enough to allow useful email address completion. Hence, this commit sets the buffer-local value of completion-styles to a better suited value when performing email completion via eudc-capf-complete, which is also no longer added to completion-at-point-functions in message-mode. message-mode has EUDC support already, and that would have been duplicated functionality. Users are still free to add eudc-capf-complete to completion-at-point-functions at their own discretion (for example in mail-mode). * lisp/net/eudc-capf.el (eudc-capf-complete): set completion-styles buffer locally to a more generous value, so that more candidates can pass the filtering (eudc-capf-message-expand-name): renamed to eudc-capf--message-expand-name to mark it as an internal use function, and improved the doc string * lisp/gnus/message.el (message-mode): no longer add eudc-capf-complete to the buffer-local value of completion-at-point-functions --- lisp/gnus/message.el | 1 - lisp/net/eudc-capf.el | 48 ++++++++++++++++++++----------------------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index e7d11b597b..6c10a4ae97 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -3191,7 +3191,6 @@ message-mode (mail-abbrevs-setup)) ((message-mail-alias-type-p 'ecomplete) (ecomplete-setup))) - (add-hook 'completion-at-point-functions #'eudc-capf-complete -1 t) (add-hook 'completion-at-point-functions #'message-completion-function nil t) (unless buffer-file-name (message-set-auto-save-file-name)) diff --git a/lisp/net/eudc-capf.el b/lisp/net/eudc-capf.el index e2bbd5b28b..c655c14df6 100644 --- a/lisp/net/eudc-capf.el +++ b/lisp/net/eudc-capf.el @@ -101,34 +101,30 @@ eudc-capf-complete The return value is either nil when no match is found, or a completion table as required for functions listed in `completion-at-point-functions'." - (if (and (seq-some #'derived-mode-p eudc-capf-modes) - (let ((mail-abbrev-mode-regexp message-email-recipient-header-regexp)) - (mail-abbrev-in-expansion-header-p))) - (eudc-capf-message-expand-name))) + (when (and (or eudc-server eudc-server-hotlist) + (seq-some #'derived-mode-p eudc-capf-modes) + (let ((mail-abbrev-mode-regexp message-email-recipient-header-regexp)) + (mail-abbrev-in-expansion-header-p))) + (setq-local completion-styles '(substring partial-completion)) + (eudc-capf--message-expand-name))) ;;;###autoload -(defun eudc-capf-message-expand-name () - "Email address completion function for `message-completion-alist'. - -When this function is added to `message-completion-alist', -replacing any existing entry for `message-expand-name' there, -with an appropriate regular expression such as for example -`message-email-recipient-header-regexp', then EUDC will be -queried for email addresses, and the results delivered to -`completion-at-point'." - (if (or eudc-server eudc-server-hotlist) - (progn - (let* ((beg (save-excursion - (re-search-backward "\\([:,]\\|^\\)[ \t]*") - (match-end 0))) - (end (point)) - (prefix (save-excursion (buffer-substring-no-properties beg end)))) - (let ((result - (eudc-query-with-words (split-string prefix "[ \t]+") t))) - (when result - (list beg end - (completion-table-with-cache - (lambda (_) result) t)))))))) +(defun eudc-capf--message-expand-name () + "Helper for `eudc-capf-complete'. + +Computes a completion table as required for functions listed in +`completion-at-point-functions'." + (let* ((beg (save-excursion + (re-search-backward "\\([:,]\\|^\\)[ \t]*") + (match-end 0))) + (end (point)) + (prefix (save-excursion (buffer-substring-no-properties beg end)))) + (let ((result + (eudc-query-with-words (split-string prefix "[ \t]+") t))) + (when result + (list beg end + (completion-table-with-cache + (lambda (_) result) t)))))) (provide 'eudc-capf) ;;; eudc-capf.el ends here -- 2.38.1 --=-=-=--