[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Get a command by its keybinding and also respecting key translation
From: |
Tassilo Horn |
Subject: |
Re: Get a command by its keybinding and also respecting key translation |
Date: |
Wed, 15 Dec 2010 09:21:21 +0100 |
User-agent: |
KMail/1.13.5 (Linux/2.6.37-rc5+; KDE/4.5.4; x86_64; ; ) |
On Tuesday 14 December 2010 20:50:43 Stefan Monnier wrote:
> > (define-context-key outline-minor-mode-map
> > (kbd "<tab>")
> > th-outline-context-p
> > org-cycle)
>
> You can do it this way:
>
> (define-key outline-minor-mode-map
> (kdb "<tab>")
> `(menu-item "dummy" org-cycle
> :filter ,(lambda (cmd)
> (if (th-outline-context-p) cmd))))
This is cool, but sadly not equivalent, because I cannot add multiple
binding for one key in the same keymap. That was the whole intention of
my macro: I hit TAB (or whatever), and it'll execute some command
depending on the context.
In my approach with multiple TAB bindings in one keymap, the last one
defined was the real binding, but if its predicate didn't match, it
delegated to the former binding of TAB (which it had stolen), and if all
predicates of all context keys failed, it would call the original
command.
So do I go to implement that behavior in a more standard way?
The docs state, that the :filter may also switch the REAL-BINDING to
some other command, so I could write a macro that expands according to
your definition with a (cond ((PRED1) (CMD1)) ((PRED2) (CMD2))) instead
of the if.
And is this approach not pretty slow? I mean, my approach did the
predicate checks only when that key was typed, but I think that your
approach does the checks on any redisplay, right?
Bye,
Tassilo
- Get a command by its keybinding and also respecting key translation, Tassilo Horn, 2010/12/13
- Re: Get a command by its keybinding and also respecting key translation, Stefan Monnier, 2010/12/14
- Re: Get a command by its keybinding and also respecting key translation, Tassilo Horn, 2010/12/14
- Re: Get a command by its keybinding and also respecting key translation, Stefan Monnier, 2010/12/18
- Re: Get a command by its keybinding and also respecting key translation, Tassilo Horn, 2010/12/20
- Re: Get a command by its keybinding and also respecting key translation, Andreas Schwab, 2010/12/20
- Re: Get a command by its keybinding and also respecting key translation, Tassilo Horn, 2010/12/20
- Re: Get a command by its keybinding and also respecting key translation, David Kastrup, 2010/12/20
- Re: Get a command by its keybinding and also respecting key translation, Tassilo Horn, 2010/12/20
- Re: Get a command by its keybinding and also respecting key translation, Andreas Schwab, 2010/12/20
- Re: Get a command by its keybinding and also respecting key translation,
Tassilo Horn <=
- Re: Get a command by its keybinding and also respecting key translation, Tassilo Horn, 2010/12/15
- Re: Get a command by its keybinding and also respecting key translation, Davis Herring, 2010/12/15
- Re: Get a command by its keybinding and also respecting key translation, Tassilo Horn, 2010/12/15
- RE: Get a command by its keybinding and also respecting keytranslation, Drew Adams, 2010/12/15
- Re: Get a command by its keybinding and also respecting keytranslation, Tassilo Horn, 2010/12/15
- RE: Get a command by its keybinding and also respecting keytranslation, Drew Adams, 2010/12/15
- Re: Get a command by its keybinding and also respecting keytranslation, Stefan Monnier, 2010/12/18
- Re: Get a command by its keybinding and also respecting key translation, Stefan Monnier, 2010/12/18