From d02b15f2f9bf9b83641eac4e169ba79ac5026df8 Mon Sep 17 00:00:00 2001 From: Alexander Adolf Date: Fri, 9 Dec 2022 22:15:42 +0100 Subject: [PATCH] Fix bug#59314 * 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/net/eudc-capf.el | 48 ++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 26 deletions(-) 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