From: Toby Cubitt <tsc25@cantab.net>
To: emacs-devel@gnu.org
Subject: Re: Emacs completion matches selection UI
Date: Tue, 7 Jan 2014 03:57:40 +0000 [thread overview]
Message-ID: <20140107035740.GA3622@c3po> (raw)
In-Reply-To: <871u0kfzpe.fsf@flea.lifelogs.com>
On Mon, Jan 06, 2014 at 06:38:37PM -0500, Ted Zlatanov wrote:
> On Sat, 4 Jan 2014 00:48:53 +0000 Toby Cubitt <tsc25@cantab.net> wrote:
> TC> Since it's the completion UI that will have to interpret and make use of
> TC> the extras, one place to start is to think about what additional features
> TC> the UI might want to provide, beyond selecting from a list of possible
> TC> completions.
>
> TC> Luckily, we have many existing completion frameworks to draw on for
> TC> inspiration. At the moment, location data and various forms of
> TC> documentation (e.g. type information in code completion, docstrings,
> TC> etc.) are the only ones that spring to mind.
>
> Add: feedback from frontend to backend (Predictive use case we
> mentioned, needs API support through callbacks). Pluggable completion
> frontends (not in the API)
Or rather, requires a separate API. Both Completion-UI and Company
already have APIs for this (though the discussion's mostly focused on the
completion UI API so far).
> Dynamic limiting of completion candidates as characters are typed (not
> in the API).
All Completion-UI widgets already implement this(*), and the UI widget
API ensures that any third-part widgets will also automatically support
this too.
(*) The mouse-driven toolkit menus break it by stealing the keyboard
focus, but that's a technicality.
> The backend should be able to provide hints about the data. For
> instance, "this is a list of ELisp symbols" could look different from
> "this is a list of installable packages." Also icons are important IMO,
> based on the hints or the candidates.
>
> TC> The keyword arguments to `completion-ui-register-source' are one starting
> TC> point for seeing what additional properties might be needed, as are the
> TC> corresponding APIs in Company, auto-complete, etc.
>
> Can you or Dmitry compile a list?
Here are the important ones (copied from the docstring):
:activate FUNCTION
The function called to activate the user-interface.
:deactivate FUNCTION
The function called to deactivate the user-interface.
:update FUNCTION (optional)
A function to call to update the user-interface after a
change to the current completion. If it is not specified, the
interface is updated by calling the :deactivate function,
updating the completion, then calling the :activate function.
:auto-show FUNCTION (optional)
A function to call to activate a this user-interface as
an auto-show interface. The auto-show interface is chosen
by setting the `completion-auto-show' customization
option. Only one auto-show interface can be displayed at
any one time.
:auto-show-helper FUNCTION (optional)
A function to call whenever any auto-show interface is
activated for a completion.
In Completion-UI, all of these functions are passed a single argument: an
overlay which demarcates where in the buffer the completion is taking
place, and whose properties contain relevant data about the completion
process. I rather like passing the data in overlay properties, because it
keeps the data together with the location in the buffer where things are
happening. But one could pass the data through buffer-local variables if
preferred.
The following overlay properties store the standard completion-related
data:
prefix
The prefix or string being completed.
prefix-length
Length of the prefix or string currently being completed. (For
convenience, to avoid having to repeatedly call
(length (overlay-get completion-overlay prefix))
completions
A list of completion candidates.
completion-num
Index of currently selected completion candidate, or nil
if completions list is empty.
completion-overlay
Always t for a completion overlay.
completion-source
The completion source ("backend") used to obtain the completion
candidates.
completion-prefix-function
Function that was used to find the prefix or string to
complete.
non-prefix-completion
Nil if doing standard prefix completion, non-nil if doing
something other than prefix completion (such as pattern
matching).
prefix-replaced
Non-nil if buffer string being completed (stored in prefix
overlay property) has been replaced with new text in the
buffer. (Only relevant when doing non-prefix completion.)
common-substring
If set, an overlay marking the longest common substring of the
completion text currently inserted in the buffer, if any.
keymap
Keymap active within the completion overlay. Usually derived from
`completion-overlay-map' or `auto-completion-overlay-map'.
auto-show
Name of auto-show interface (symbol) currently being
displayed, or nil if no auto-show interface is active.
> TC> Also, if we want to allow users to optionally customize the completion UI
> TC> per-backend (a la Completion-UI), there has to be some way of identifying
> TC> backends in Customize. This seems necessary to me if the new API is to
> TC> become the standard way of implementing a completion UI in Emacs. Think
> TC> minibuffer completion, versus filename completion, versus predictive
> TC> completion, versus elisp code completion etc, all of which might want to
> TC> use slightly different UI options. Again, it might be enough to support a
> TC> :name property (or some such) in the `completion-at-point-functions'
> TC> PROPS plist.
>
> The frontend UI should depend (in my mind) on three things: 1) the
> invocation context as you showed; 2) the backend-provided hints about
> the data as a whole; and 3) the backend-provided hints about each
> completion candidate individually. Does that make sense?
Yes, it makes sense. I suspect most of the time the UI will only need to
depend on which backend is being used (and often not even on that). I
can't think of any situations in which it will need to depend on the
completions returned by the backend. But maybe there are some cases.
> Some frontends may ignore some or all of those things, but I think
> those are the principal axis. I don't know how those three things will
> be passed to the frontend though, and when.
Everything I've ever wanted to do with Completion-UI is covered by
allowing various configuration variables to take backend-specific
values. I've never needed the UI to depend on the return value of the
backend. Maybe Dmitry has examples from Company?
> >> - the frontend choices made by the user should be able to feed back into
> >> the data backend (the "predictive" use case)
>
> TC> A few optional hooks/call-backs would very likely be sufficient. Again,
> TC> the `completion-at-point-functions' PROPS plist would be the obvious
> TC> place to specify them.
>
> OK, this is your use case :)
I'm just bowing to the inevitable outcome that we'll end up extending
c-a-p-f rather than designing a new API for the completion sources.
> >> - we have enough interest and support in this work that it's worth
> >> undertaking in earnest after the code freeze. The discussion should
> >> remain on emacs-devel (based on the wide interest so far).
> ...
> TC> (Note that I'm unlikely to have time to code anything myself until
> TC> March/April, although the feature freeze will likely delay things until
> TC> about then anyway. I'm happy to help in a more limited way before then,
> TC> as time allows.)
>
> Cool. We seem to be moving towards a specific API, refining the current
> Emacs internals, which is good. I'd be OK with it looking like
> completion-ui as long as it was at least somewhat backwards compatible
> and could support the packages we mentioned.
By "looking like completion-UI", do you mean the API or what it actually
looks like?
I think the completion source API is likely to look exactly like
completion-at-point-functions, because that's already in Emacs and I'm
running out of compelling arguments for changing it, even though I don't
love it. But Dmitry may hold out longer than me on this ;-)
> To me, the clearest indication of a good approach would be if both the
> Emacs core and external packages were able to lose lines of code.
I'm hoping the Predictive package can lose 9 entire elisp files, for a
start (all the Completion-UI files ;-)
Toby
--
Dr T. S. Cubitt
Royal Society University Research Fellow
and Fellow of Churchill College, Cambridge
Centre for Quantum Information
DAMTP, University of Cambridge
email: tsc25@cantab.net
web: www.dr-qubit.org
next prev parent reply other threads:[~2014-01-07 3:57 UTC|newest]
Thread overview: 258+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-18 16:13 Emacs completion matches selection UI Ted Zlatanov
2013-11-18 20:00 ` Bozhidar Batsov
2013-11-18 20:54 ` Andreas Röhler
2013-11-18 21:15 ` Ted Zlatanov
2013-11-19 0:43 ` Stefan Monnier
2013-11-19 9:52 ` Dmitry Gutov
2013-11-19 13:41 ` Stefan Monnier
2013-11-19 14:00 ` Dmitry Gutov
2013-11-19 14:58 ` Ted Zlatanov
2013-11-19 17:50 ` Stefan Monnier
2013-11-19 21:07 ` Ted Zlatanov
2013-11-20 0:28 ` Stefan Monnier
2013-11-20 1:30 ` Ted Zlatanov
2013-11-20 3:22 ` Stefan Monnier
2013-11-20 17:52 ` Ted Zlatanov
2013-11-20 19:10 ` Stefan Monnier
2013-11-20 20:00 ` Ted Zlatanov
2013-11-20 15:57 ` Josh
2013-11-21 0:52 ` Juri Linkov
2013-11-21 3:48 ` Eli Zaretskii
2013-11-22 0:10 ` Juri Linkov
2013-11-22 7:36 ` Eli Zaretskii
2013-11-22 12:33 ` Ted Zlatanov
2013-11-25 13:28 ` Ted Zlatanov
2013-11-25 15:18 ` Stefan Monnier
2013-12-16 15:17 ` Ted Zlatanov
2013-12-16 18:35 ` Stefan Monnier
2013-12-16 22:15 ` Ted Zlatanov
2013-12-17 2:10 ` Stefan Monnier
2013-12-17 10:49 ` Ted Zlatanov
2013-12-17 18:29 ` Stefan Monnier
2013-12-17 20:59 ` Ted Zlatanov
2013-12-18 1:58 ` Stephen J. Turnbull
2013-12-18 3:09 ` Ted Zlatanov
2013-12-18 4:47 ` Stephen J. Turnbull
2013-12-18 14:43 ` Ted Zlatanov
2013-12-18 15:51 ` Eli Zaretskii
2013-12-18 16:38 ` Ted Zlatanov
2013-12-18 17:05 ` Eli Zaretskii
2013-12-18 17:18 ` Ted Zlatanov
2013-12-18 17:37 ` Stephen J. Turnbull
2013-12-18 19:05 ` Ted Zlatanov
2013-12-18 21:11 ` chad
2013-12-19 3:40 ` Stefan Monnier
2013-12-19 15:49 ` Ted Zlatanov
2013-12-19 17:30 ` Dmitry Gutov
2013-12-19 18:44 ` Ted Zlatanov
2013-12-19 21:44 ` Dmitry Gutov
2013-12-20 1:15 ` Ted Zlatanov
2013-12-20 3:06 ` Stephen J. Turnbull
2013-12-20 3:08 ` Dmitry Gutov
2013-12-20 11:49 ` Ted Zlatanov
2013-12-20 13:18 ` Dmitry Gutov
2013-12-20 14:59 ` Ted Zlatanov
2013-12-22 1:45 ` Stefan Monnier
2013-12-22 2:29 ` Dmitry Gutov
2013-12-22 11:07 ` Stefan Monnier
2013-12-22 16:07 ` Dmitry Gutov
2013-12-22 22:50 ` enabling company-capf support in cfengine.el (was: Emacs completion matches selection UI) Ted Zlatanov
2013-12-23 0:17 ` enabling company-capf support in cfengine.el Dmitry Gutov
2013-12-23 1:11 ` Ted Zlatanov
2013-12-23 1:32 ` Dmitry Gutov
2014-01-16 13:12 ` Dmitry Gutov
2014-01-16 16:06 ` Stefan Monnier
2014-01-16 17:39 ` Dmitry Gutov
2014-01-17 13:04 ` Stefan Monnier
2014-01-18 14:13 ` Dmitry Gutov
2014-01-19 2:37 ` Stefan Monnier
2014-01-19 16:44 ` Dmitry Gutov
2014-01-19 20:19 ` Stefan Monnier
2014-01-19 20:44 ` David Engster
2014-01-20 0:13 ` Dmitry Gutov
2014-01-20 2:14 ` Stephen J. Turnbull
2014-01-20 2:39 ` John Yates
2014-01-20 3:22 ` Stephen J. Turnbull
2014-01-20 7:10 ` David Kastrup
2014-01-20 14:22 ` John Yates
2014-01-20 14:55 ` David Kastrup
2014-01-20 15:09 ` clang vs free software (was: enabling company-capf support in cfengine.el) Stefan Monnier
2014-01-20 19:47 ` clang vs free software David Engster
2014-01-21 14:42 ` Richard Stallman
2014-01-21 15:02 ` David Kastrup
2014-01-21 15:20 ` Dmitry Gutov
2014-01-22 15:31 ` Richard Stallman
2014-01-22 17:24 ` Dmitry Gutov
2014-01-21 15:34 ` John Yates
2014-01-21 16:00 ` Rüdiger Sonderfeld
2014-01-21 16:25 ` joakim
2014-01-21 16:34 ` Rüdiger Sonderfeld
2014-01-21 16:38 ` joakim
2014-01-21 18:50 ` Rüdiger Sonderfeld
2014-01-21 18:00 ` Thien-Thi Nguyen
2014-01-21 18:44 ` Rüdiger Sonderfeld
2014-01-23 10:55 ` Richard Stallman
2014-01-23 11:01 ` David Kastrup
2014-01-23 14:26 ` Helmut Eller
2014-01-25 23:02 ` Richard Stallman
2014-01-25 23:28 ` Daniel Colascione
2014-01-26 1:35 ` Lennart Borgman
2014-01-26 6:45 ` David Kastrup
2014-01-26 12:13 ` Daniel Colascione
2014-01-26 12:35 ` Lennart Borgman
2014-01-26 14:45 ` David Kastrup
2014-01-26 20:06 ` Richard Stallman
2014-01-26 20:06 ` Richard Stallman
2014-01-26 10:22 ` Helmut Eller
2014-01-26 11:12 ` David Kastrup
2014-01-26 12:36 ` Helmut Eller
2014-01-26 14:54 ` David Kastrup
2014-01-26 20:06 ` Richard Stallman
2014-01-26 15:12 ` Stefan Monnier
2014-01-26 15:15 ` Lennart Borgman
2014-01-26 15:35 ` David Kastrup
2014-01-26 15:46 ` Lennart Borgman
2014-01-23 16:35 ` Rüdiger Sonderfeld
2014-01-23 18:04 ` David Engster
2014-01-22 2:06 ` unic0rn
2014-01-20 15:57 ` enabling company-capf support in cfengine.el Stephen J. Turnbull
2014-01-20 3:32 ` Óscar Fuentes
2014-01-20 13:59 ` John Yates
2014-01-20 14:30 ` David Kastrup
2014-01-20 17:01 ` John Yates
2014-01-20 2:17 ` Stefan Monnier
2014-01-19 16:54 ` Dmitry Gutov
2014-01-19 20:21 ` Stefan Monnier
2014-01-19 23:57 ` Dmitry Gutov
2014-01-20 2:20 ` Stefan Monnier
2014-01-20 2:33 ` Dmitry Gutov
2014-01-20 13:41 ` Stefan Monnier
2013-12-23 1:36 ` Emacs completion matches selection UI Stefan Monnier
2013-12-23 2:12 ` Dmitry Gutov
2013-12-23 13:33 ` Stefan Monnier
2013-12-20 1:19 ` Stephen J. Turnbull
2013-12-20 1:17 ` Stephen J. Turnbull
2013-12-20 14:32 ` Stefan Monnier
2013-12-20 15:54 ` Ted Zlatanov
2013-12-21 3:32 ` Stephen J. Turnbull
2013-12-21 4:58 ` Ted Zlatanov
2013-12-22 2:05 ` Stefan Monnier
2013-12-22 23:15 ` Ted Zlatanov
2013-12-23 1:59 ` Stefan Monnier
2013-12-23 12:28 ` Ted Zlatanov
2013-12-23 13:42 ` Stefan Monnier
2013-12-23 14:52 ` Ted Zlatanov
2013-12-30 20:47 ` Toby Cubitt
2013-12-31 0:20 ` Leo Liu
2013-12-31 7:48 ` joakim
2013-12-31 14:30 ` Dmitry Gutov
2013-12-31 15:52 ` Toby Cubitt
2013-12-31 17:45 ` joakim
2014-01-02 18:54 ` Dmitry Gutov
2014-01-02 18:10 ` Stefan Monnier
2014-01-03 17:49 ` Ted Zlatanov
2014-01-03 19:36 ` Stefan Monnier
2014-01-04 0:48 ` Toby Cubitt
2014-01-04 3:45 ` Stefan Monnier
2014-01-06 4:47 ` Toby Cubitt
2014-01-06 23:38 ` Ted Zlatanov
2014-01-07 3:57 ` Toby Cubitt [this message]
2014-01-04 9:21 ` João Távora
2014-01-06 23:21 ` Ted Zlatanov
2014-01-02 20:20 ` Dmitry Gutov
2014-01-02 22:58 ` Toby Cubitt
2014-01-03 2:40 ` Stefan Monnier
2014-01-03 14:30 ` Toby Cubitt
2014-01-03 16:23 ` Dmitry Gutov
2014-01-03 16:48 ` Toby Cubitt
2014-01-03 19:32 ` Stefan Monnier
2014-01-03 22:06 ` Toby Cubitt
2014-01-04 3:39 ` Stefan Monnier
2014-01-06 4:00 ` Toby Cubitt
2014-01-03 16:35 ` Toby Cubitt
2014-01-03 17:46 ` Thierry Volpiatto
2014-01-04 2:39 ` Dmitry Gutov
2014-01-04 3:54 ` Stefan Monnier
2014-01-05 4:08 ` Dmitry Gutov
2014-01-05 16:04 ` Stefan Monnier
2014-01-06 4:25 ` Dmitry Gutov
2014-01-06 5:25 ` Toby Cubitt
2014-01-06 2:39 ` Toby Cubitt
2014-01-06 4:03 ` Stefan Monnier
2014-01-06 5:35 ` Toby Cubitt
2014-01-06 5:55 ` Dmitry Gutov
2014-01-06 14:47 ` Stefan Monnier
2014-01-06 15:54 ` Toby Cubitt
2014-01-06 20:53 ` Stefan Monnier
2014-01-06 23:45 ` Ted Zlatanov
2014-01-06 7:36 ` Dmitry Gutov
2014-01-06 15:51 ` Toby Cubitt
2014-01-07 0:17 ` Dmitry Gutov
2014-01-07 3:32 ` Toby Cubitt
2014-01-07 23:23 ` Dmitry Gutov
2014-01-08 2:58 ` Toby Cubitt
2014-01-08 3:38 ` Bob Bobeck
2014-01-08 3:47 ` Toby Cubitt
2014-01-08 9:27 ` Richard Stallman
2014-01-08 15:37 ` Ted Zlatanov
2014-01-08 4:49 ` Stefan Monnier
2014-01-08 15:33 ` Ted Zlatanov
2014-01-08 16:11 ` Toby Cubitt
2014-01-09 7:12 ` Dmitry Gutov
2013-12-23 13:45 ` John Yates
2013-12-23 16:02 ` Stefan Monnier
2013-12-24 2:47 ` John Yates
2013-12-28 14:02 ` Stefan Monnier
2013-12-28 16:43 ` John Yates
2013-12-30 12:55 ` Stefan Monnier
2013-12-30 16:32 ` João Távora
2014-01-04 23:02 ` Stefan Monnier
2014-01-05 2:13 ` João Távora
2014-01-05 16:11 ` Stefan Monnier
2014-01-06 23:48 ` Ted Zlatanov
2014-01-07 3:15 ` Stefan Monnier
2014-01-07 16:13 ` Ted Zlatanov
2014-01-07 17:18 ` João Távora
2014-01-07 18:10 ` Josh
2014-01-07 19:42 ` David Kastrup
2014-01-08 3:54 ` Josh
2014-01-07 3:16 ` Stefan Monnier
2014-01-07 16:12 ` Ted Zlatanov
2013-12-28 15:59 ` João Távora
2013-12-28 17:00 ` John Yates
2013-12-28 17:40 ` Josh
2013-12-19 4:53 ` Stephen J. Turnbull
2013-12-19 5:45 ` chad
2013-12-19 7:03 ` Stephen J. Turnbull
2013-12-19 7:59 ` Aaron Ecay
2013-12-19 15:29 ` Stephen J. Turnbull
2013-12-19 17:41 ` Eli Zaretskii
2013-12-19 18:46 ` Ted Zlatanov
2013-12-20 0:53 ` Stephen J. Turnbull
2013-12-19 6:23 ` Stephen J. Turnbull
2013-11-19 16:24 ` Eli Zaretskii
2013-11-21 10:17 ` Dmitry Gutov
2013-11-21 16:30 ` Eli Zaretskii
2013-11-22 5:38 ` Stephen J. Turnbull
2013-11-22 15:19 ` Eli Zaretskii
2013-11-23 10:03 ` Stephen J. Turnbull
2013-11-19 13:48 ` Ted Zlatanov
2013-11-19 18:03 ` Stefan Monnier
2013-11-20 0:10 ` Gregor Zattler
2013-11-20 1:25 ` Ted Zlatanov
2013-11-20 17:59 ` John Yates
2013-11-19 0:47 ` Juri Linkov
2013-11-19 11:18 ` Tom
2013-11-19 14:00 ` Stefan Monnier
2013-11-20 0:45 ` Juri Linkov
2013-11-20 7:34 ` martin rudalics
2013-11-20 7:50 ` Tom
2013-11-21 0:45 ` Juri Linkov
2013-11-21 7:41 ` martin rudalics
2013-11-22 0:18 ` Juri Linkov
2013-11-22 10:26 ` martin rudalics
2013-11-19 19:44 ` Dmitry Gutov
2013-11-20 7:39 ` Eric Abrahamsen
2013-11-19 17:33 ` Sebastian Wiesner
-- strict thread matches above, loose matches on Subject: below --
2013-12-30 20:35 Barry OReilly
2014-01-01 18:12 ` Stefan Monnier
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=20140107035740.GA3622@c3po \
--to=tsc25@cantab.net \
--cc=emacs-devel@gnu.org \
--cc=toby-dated-1390276664.a329c7@dr-qubit.org \
/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).