all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 74410@debbugs.gnu.org
Cc: monnier@iro.umontreal.ca
Subject: bug#74410: 31.0.50; completion-at-point doesn't work in custom buffers
Date: Sun, 17 Nov 2024 18:15:36 -0500	[thread overview]
Message-ID: <jwvplmtjwc8.fsf-monnier+@gnu.org> (raw)

Package: Emacs
Version: 31.0.50


For example:

    src/emacs -Q --eval '(customize-face `fixed-pitch)'
    ... move point to the font family field ...
    ... delete the "space" from "Monospace" then do:
    M-x completion-at-point RET

This will presumably do nothing at all.
`widget-complete` completes it back to "Monospace" (at least on
`master` where I installed a patch for that).

The problem is that cus-edit doesn't setup
`completion-at-point-functions`.  Instead it sets up a special keymap to
remap M-TAB to `widget-complete` instead of relying on the
global binding.

It works OK for a default config, but it doesn't interact well with
setups that use different keybindings or different completion UIs based
on `completion-at-point-functions`.  E.g. `corfu-mode` partly works but
not fully (e.g. `corfu-auto` doesn't have any effect).

The patch below leaves the key remapping for now, but adds an
appropriate function to `completion-at-point-functions` so that
other UIs such as `completion-at-point` can do their job properly.

Comments/objection?


        Stefan


diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index e0668d4ba86..02e0b541f05 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -5503,7 +5503,8 @@ Custom-mode
   (make-local-variable 'custom-options)
   (make-local-variable 'custom-local-buffer)
   (custom--initialize-widget-variables)
-  (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t))
+  (add-hook 'completion-at-point-functions #'widget-completions-at-point nil t)
+  (add-hook 'widget-edit-functions #'custom-state-buffer-message nil t))
 
 (defun custom--revert-buffer (_ignore-auto _noconfirm)
   (unless custom--invocation-options
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 58a36820ac7..1538720adef 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1399,7 +1399,7 @@ widget-complete
   "Complete content of editable field from point.
 When not inside a field, signal an error."
   (interactive)
-  (let ((data (widget-completions-at-point)))
+  (let ((data (widget-completions-at-point 'error)))
     (cond
      ((functionp data) (funcall data))
      ((consp data)
@@ -1414,11 +1414,11 @@ widget-complete
 ;; so it's not really obsolete (yet).
 ;; (make-obsolete 'widget-complete 'completion-at-point "24.1")
 
-(defun widget-completions-at-point ()
+(defun widget-completions-at-point (&optional error)
   (let ((field (widget-field-find (point))))
     (if field
         (widget-apply field :completions-function)
-      (error "Not in an editable field"))))
+      (if error (error "Not in an editable field")))))
 
 ;;; Setting up the buffer.
 






             reply	other threads:[~2024-11-17 23:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-17 23:15 Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-11-20  7:57 ` bug#74410: 31.0.50; completion-at-point doesn't work in custom buffers Juri Linkov
2024-11-20 23:31   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-21  7:54     ` Juri Linkov
2024-11-21 16:28       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-24 17:35         ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvplmtjwc8.fsf-monnier+@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=74410@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.