unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 74410@debbugs.gnu.org
Subject: bug#74410: 31.0.50; completion-at-point doesn't work in custom buffers
Date: Thu, 21 Nov 2024 09:54:18 +0200	[thread overview]
Message-ID: <87ttc181jp.fsf@mail.linkov.net> (raw)
In-Reply-To: <jwv7c8xcwq5.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 20 Nov 2024 18:31:07 -0500")

>> Currently this works only when typing 'M-x completion-at-point RET',
>> not by 'M-C-i' that is bound to 'widget-complete'.  Maybe
>> 'M-C-i' should be rebound to 'completion-at-point' in widgets?
>
> Maybe it would make even more sense to just remove the `widget-complete`
> binding since M-TAB should already be bound appropriately, but the
> problem is that we don't know that the code which inserts the widget
> into a buffer has properly setup the `completion-at-point-functions`
> hook for `completion-at-point` to work.
>
> Maybe we should try and detect when that is not the case and emit
> a warning if so (with the hope to be able to obsolete `widget-complete`
> in some future version).

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.





  reply	other threads:[~2024-11-21  7:54 UTC|newest]

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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87ttc181jp.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).