[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs completion matches selection UI

From: João Távora
Subject: Re: Emacs completion matches selection UI
Date: Sun, 05 Jan 2014 02:13:42 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> (define-fallbackish-command maybe-foo (kbd "[somekey]") ()
> I don't understand what's the intended relation between [somekey] and
> `maybe-foo'.

Sorry, I should have provided some implementation, or made this more
clear. I

The generated part of the `maybe-foo' would do two things:

* register the association between maybe-foo and [somekey] in a some
  global variable, pushing in front of any existing ones also defined
  with the same macro. This keeps track of the "fallbackish commands"
  (horrible name, sorry) for [somekey]

* bind maybe-foo to [somekey] in the (global) keymap, maybe replacing
  someone else's binding.

When (if ever) `fallback' is called from a command's body, it looks up
the first variable. Its a list of commands that are still fallbacks to
the current. It removes the current command from the list, let-binds the
list and calls the next command.

Now, I haven't even attempted this, but it sounded good (in my head :))
and think it could resolve most problems. I'll try to implement it and
get back to you, unless someone immediately detects some big error.

One problem is that you more or less now have two bindings to
synchronize, and this may be quite bad. The map's binding and the other
global variable. I have no idea how it would work with multiple keymaps.

> binding otherwise.  But this is not very satisfactory:
> - no way to do something after the fallback command is run.

`fallback' could be called anywhere from `maybe-foo's body.

> - C-h k will only tell you about one of the possible commands.

yasnippet does this with

   (put 'yas-expand  'function-documentation
        '(yas--expand-from-trigger-key-doc t))

in which the latter function calls a `yas--keybinding-beyond-yasnippet'
function. I believe this could also be done with the above idea.

> - Can't have more than one such "conditional binding" for the same key
>   in the same keymap.

This is the main use case i'm trying to cover.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]