Subject: bug#74410: 31.0.50; completion-at-point doesn't work in custom buffers

From: Stefan Monnier <[email-masked]>
Date: Thu, 21 Nov 2024 11:28:19 -0500

> Or to make the binding conditional with something like this:
>
> diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
> index ba99847f488..0701442447c 100644
> --- a/lisp/wid-edit.el
> +++ b/lisp/wid-edit.el
> @@ -1079,7 +1079,10 @@ widget-global-map
>  (defvar widget-field-keymap
>    (let ((map (copy-keymap widget-keymap)))
>      (define-key map "\C-k" #'widget-kill-line)
> -    (define-key map "\M-\t" #'widget-complete)
> +    (define-key map "\M-\t" `(menu-item "" 'widget-complete
> +                              :filter ,(lambda (cmd)
> +                                         (unless completion-at-point-functions
> +                                           cmd))))
>      (define-key map "\C-m" #'widget-field-activate)
>      ;; Since the widget code uses a `field' property to identify fields,
>      ;; ordinary beginning-of-line does the right thing.

Cute 🙂
I really like the fact that Emacs can do this, but we shouldn't abuse
it, because it makes it more difficult for users to figure out
what's going on.

        Stefan