unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lluis <xscript@gmx.net>
Cc: emacs-devel@gnu.org, eric@siege-engine.com
Subject: Re: Completions in Semantic
Date: Sat, 31 Oct 2009 16:18:17 -0400	[thread overview]
Message-ID: <jwveiok8lla.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20091029143811.GB25239@ginnungagap.pc.ac.upc.edu> (Lluis's message of "Thu, 29 Oct 2009 15:38:11 +0100")

>> > Are you looking for examples of hooks that would be needed, or examples
>> > of behaviors that need hooks to be designed?
>> Examples of hooks that could make such things possible.

> Ok, so here's a high-level shot on a possible completion infrastructure.
> Note that much of what I describe is oriented towards programming.

Yes, this discussion is difficult because my main interest is in reusing
the current standard completion code (used for most minibuffer
completions) for most/all other "in-buffer" completions.  OTOH you're
only interested in completion of variables and method/function
identifiers, which is itself just a special case of
"in-buffer" completion.

> * Completion candidates
> ** Information Contains whatever information the system could gather
>    about the symbol. When programming with semantic activated, this could
>    be the semantic tag structure.

If you don't know what that info is going to be, then it is useless in
the generic API since anybody using the generic API will expect to work
for any kind of candidate and so can't use this value since it has no
idea what it might be.

> ** Actions
>    Various actions that can be applied on a candidate.
>    This is basically the interface to view the candidate information.

In the generic completion code, we currently have 4 actions:
test-completion, try-completion, all-completions, and the new
completion-boundaries (which in the case of function-name completion is
always trivial).

For reasons of backward compatibility, it's difficult to add new actions
in the generic code (the new completion-boundaries is the first time we
add an action since ... before 1993), but one could easily imagine
adding actions for specific kinds of completions, which could then only
be used for completion tables that support those extra actions.

> **** get-return
>      Return type of the candidate (only meaningful on programming candidates)
> **** get-arguments
>      Arguments of the candidate (idem)

This is very specialized.  It doesn't even apply to all programming
languages (e.g. Prolog).  Also even in functional programming languages,
we usually keep the two together, i.e. we'd rather see that + has type
"int * int -> int" than that it has args of types "int, int" and return
type "int", and there's a good reason for that: sometimes it's not so
clear where's the boundary between args and return values: the function
"map" (aka "mapcar" in Elisp) has typically type "(a -> b) -> List a ->
List b" (with an implicit "∀ a,b" around it), but that can be read as
"map take a function argument of type (a -> b) and returns a new
function of type (List a -> List b)", or it can be read equivalently as
"map takes a function argument of type (a -> b) and a list of type List
a and returns a list of type List b".

All this to say: if you conflate "get-return" and "get-arguments"
together, you'll get a system that will fit many more languages.

> **** get-short-help
>      Short version of candidate help
> **** get-long-help
>      Long version of candidate help
> *** show
>     Shows an arbitrary composition of get-*.
>     E.g., (concat (get-signature candidate) "\n" (get-long-help candidate))
>     Where that sould be shown, must be user selectable (see below

Isn't this "show" redundant with get-short-help or get-long-help?

> *** insert-*
>     Insert "something" at point (cannot think of use-cases where insertion takes
>     place in other places other than point).

I think side-effects have no business being here.  Let the client code
do the insertion, and limit the candidate object to returning the
info necessary to figure out what to insert.

> * UI
> ** Types
>    The completion-ui package has implementations for some (if not all) of them.
>    The UI
> *** buffer
>     Is the current *Completions* buffer.
> *** minibuffer
>     The completion system used by, e.g., predictive-mode.
> *** overlay
>     That's the one I prefer, see company-mode as an example.
> *** others
>     There are many others, like menus, etc.

Or icomplete-mode, yes.  These seem to only affect
minibuffer-completion-help (the standard function that displays the list
of possible completions, usually in *Completions*).  When I use
completion, I generally try to avoid getting to that point, tho.

This points to a more important aspect: when is this list displayed,
when is it updated, and when is it brought down.  For each kind of
completion-list, those choices are not always the same
(e.g. icomplete-mode brings is up right away and updates it after each
keystroke, whereas what you call "buffer" only brings it up on a few
specific operations and only updates it on those same operations).
This behavior-variation depending on the display-style is something that
makes it trickier to write the generic code.

> *** start
>     Start the completion process. E.g.:
>         (show current-ui get-return get-name get-arguments)
>     would show the full signature of a function.

I don't understand it: when I start completion, I don't have any
function chosen yet (that's the whole reason for me to try to complete
it, usually), so there's no signature to show yet.

> *** focus
>     Let's the user "highlight" an entry of the possible candidates. It's the
>     good old next/prev in an overlay UI.
>     Focusing an element can trigger other actions. This will mainly be
>         (show <where> ...)
>     The <where> could be any of minibuffer, another buffer, tooltip, etc.

Oh, so "show" is not a method that returns a string, it's a method that
has some side-effect that hopefully "shows" the candidate?  That makes
more sense now.

> *** completion-map
>     Extra actions the user can trigger through keyboard when the completion UI
>     is "active".
>     E.g., i can focus to an interesting symbol and trigger
>         (show some-buffer get-long-help)

That might be tricky to support in a generic way, since depending on the
UI, it's not necessarily clear where the completion-map should be active
and with which other keybindings it might collide.


        Stefan




  reply	other threads:[~2009-10-31 20:18 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-18 23:00 Completions in Semantic Chong Yidong
2009-10-18 23:55 ` Miles Bader
2009-10-19  3:50 ` Eric M. Ludlam
2009-10-19 13:48   ` Stefan Monnier
2009-10-19 16:26     ` Eric M. Ludlam
2009-10-19 18:29       ` Stefan Monnier
2009-10-19 19:33         ` Eric M. Ludlam
2009-10-19 20:06           ` Stefan Monnier
2009-10-19 22:17             ` Eric M. Ludlam
2009-10-20  0:07               ` Lennart Borgman
2009-10-30 21:17                 ` Toby Cubitt
2009-10-30 21:37                   ` Lennart Borgman
2009-10-20  0:14               ` Stefan Monnier
2009-10-20 20:20                 ` Eric M. Ludlam
2009-10-21 10:58                   ` Lluis
2009-10-21 12:35                     ` Eric M. Ludlam
2009-10-21 13:28                       ` Lluis
2009-10-21 17:35                         ` Eric M. Ludlam
2009-10-22 20:12                     ` Stefan Monnier
2009-10-27 21:21                       ` Lluis
2009-10-28  0:56                         ` Stefan Monnier
2009-10-28  2:25                           ` Eric M. Ludlam
2009-10-28  3:23                             ` Stefan Monnier
2009-10-29 14:38                               ` Lluis
2009-10-31 20:18                                 ` Stefan Monnier [this message]
2009-11-01 16:01                                   ` Lluís
2009-11-02  6:12                                     ` Stefan Monnier
2009-11-02 12:13                                       ` Eric M. Ludlam
2009-10-22 20:00                   ` Stefan Monnier
2009-10-19 23:52   ` Eric M. Ludlam
2009-10-21 14:07     ` Chong Yidong
2009-10-21 16:10       ` Eric M. Ludlam
2009-10-23  1:01         ` Chong Yidong
2009-10-23  1:28           ` Eric M. Ludlam

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=jwveiok8lla.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=eric@siege-engine.com \
    --cc=xscript@gmx.net \
    /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).