Subject: bug#59314: 29.0.50; EUDC and message-mode header completion

From: Thomas Fitzsimmons <[email-masked]>
Date: Fri, 10 Feb 2023 22:30:28 -0500

Hi Stefan,

We've been trying to make the standard completion UI code in message.el
work with EUDC.

Would you be able to try this recipe and figure out why step 5 doesn't
work?

1. Build Emacs "emacs-29" branch.

2. Create test BBDB configuration:

mkdir -p /tmp/test/.emacs.d
cat >/tmp/test/.emacs.d/bbdb <<EOF
;; -*- mode: Emacs-Lisp; coding: utf-8; -*-
;;; file-format: 9
["Emacs" "ERT3" nil nil nil nil nil ("[email-masked]") ((notes . " ")) "c8bd3a63-3a83-48a7-a95b-be118a923e00" "2022-11-19 16:36:04 +0000" "2022-11-19 16:36:04 +0000" nil]
["Emacs" "ERT4" nil nil nil nil nil ("[email-masked]") ((notes . " ")) "5a93c3c5-9270-4e10-8b28-d28cfa2562cf" "2022-11-19 16:47:49 +0000" "2022-11-19 16:47:49 +0000" nil]
EOF

3. Install BBDB:

HOME=/tmp/test emacs
M-x list-packages
(install BBDB from GNU ELPA)
(exit Emacs)

4. Test EUDC using BBDB backend, and EUDC completion UI:

HOME=/tmp/test emacs
C-: (eudc-set-server "localhost" 'bbdb t)
C-x m
emacs-ertTAB

The EUDC UI pops up, and the completed email address is correctly added
to the To: line, e.g. "Emacs ERT3 <[email-masked]>".

5. Test EUDC using BBDB backend, and the standard completion UI:

HOME=/tmp/test emacs
C-: (setq message-expand-name-standard-ui t)
C-: (eudc-set-server "localhost" 'bbdb t)
C-x m
emacs-ertTAB

This produces the string " <emacs-ert-test-" in the To: line.  Pressing
TAB again inserts three spaces.  Can you figure out why the standard UI
isn't prompting with multiple results?  We've made some attempts to
debug it but without deep knowledge of completion-at-point, we're
getting lost in the callbacks.

Thank you,
Thomas