all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eshel Yaron <me@eshelyaron.com>
To: Spencer Baugh <sbaugh@janestreet.com>
Cc: emacs-devel@gnu.org
Subject: Re: Allowing completion sources to customize completion display
Date: Thu, 23 Nov 2023 09:25:19 +0100	[thread overview]
Message-ID: <m1ttpcc1w0.fsf@dazzs-mbp.home> (raw)
In-Reply-To: <ierfs0xl78f.fsf@janestreet.com> (Spencer Baugh's message of "Wed, 22 Nov 2023 18:05:04 -0500")

Spencer Baugh <sbaugh@janestreet.com> writes:

> If I have multiple sources for completion active at once, I might prefer
> different completion sources to be displayed differently.
>
> ...
>
> But the same completion-in-region-function and UI has to be used
> regardless of whether I'm getting symbol-completion or block-completion
> - I don't see a way to change completion-in-region-function based on the
> source.
>
> Maybe we should add one?

FWIW I had similar thoughts just the other day.  Allowing capfs to
request a certain selection UI makes sense in some situations, because
sometimes the most appropriate UI may depend on the results of a
specific capf.  For example, say we have a legacy completion command,
e.g. `ispell-complete-word`, that we want to port to a capf.  But the
legacy completion command comes with its bespoke completion selection
UI, so it might be desirable to have the new capf mimic the legacy UI
during the transition phase, without affecting other capfs, so other
capfs still use the regular UI when they take effect.

OTOH, IMO it's better to keep the UI as consistent and predictable as
possible, so I would avoid using such a capability too liberally.

> Some possibilities:
> - Maybe completion table metadata could just include a
>   completion-in-region-function to use?
>
> - Maybe completion-category-overrides could change
>   completion-in-region-function based on the category?
>
> - Maybe something else entirely?

How about something like the following?  That seems simple enough and
gives individual capfs full discretion to specify their selection UI.

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 5c12d9fc914..ff5472040d3 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2823,7 +2823,10 @@ completion-at-point
                (lambda ()
                  ;; We're still in the same completion field.
                  (let ((newstart (car-safe (funcall hookfun))))
-                   (and newstart (= newstart start))))))
+                   (and newstart (= newstart start)))))
+              (completion-in-region-function
+               (or (plist-get plist :completion-in-region-function)
+                   completion-in-region-function)))
          (completion-in-region start end collection
                                (plist-get plist :predicate))))
       ;; Maybe completion already happened and the function returned t.




  reply	other threads:[~2023-11-23  8:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22 23:05 Allowing completion sources to customize completion display Spencer Baugh
2023-11-23  8:25 ` Eshel Yaron [this message]
2023-11-23  8:47   ` Eli Zaretskii
2023-11-23 12:38     ` sbaugh
2023-11-23 13:48       ` Eli Zaretskii
2023-11-23 14:03         ` sbaugh
2023-11-23 14:35           ` Eli Zaretskii
2023-11-23 21:20     ` Jim Porter
2023-11-24  7:15       ` Eli Zaretskii
2023-11-24 17:28         ` Spencer Baugh
2023-11-24 20:52           ` [External] : " Drew Adams
2023-11-25  0:25           ` Dmitry Gutov
2023-11-25 17:36             ` sbaugh
2023-11-25 18:27               ` Dmitry Gutov
2023-11-25 19:07                 ` Eli Zaretskii
2023-11-25 19:08                   ` Dmitry Gutov
2023-11-25 20:04                     ` Eli Zaretskii
2023-11-25  6:59           ` Eli Zaretskii
2023-11-23 14:44 ` Dmitry Gutov

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=m1ttpcc1w0.fsf@dazzs-mbp.home \
    --to=me@eshelyaron.com \
    --cc=emacs-devel@gnu.org \
    --cc=sbaugh@janestreet.com \
    /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.