[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: |
Mon, 20 Dec 2010 09:19:59 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
Hi Stefan,
>>> (define-key outline-minor-mode-map
>>> (kdb "<tab>")
>>> `(menu-item "dummy" org-cycle
>>> :filter ,(lambda (cmd)
>>> (if (th-outline-context-p) cmd))))
>
>> Hm, just for educational purposes, could you please explain the
>> backquoting and the comma-substitution of the lambda? I mean, I know
>> that `,' in a backquote triggers evaluation, but since a lambda evals
>> to itself, what's the point in doing so?
>
> Without backquote and comma, the whole menu-item is just a piece of
> data which happens to contain something that looks like a function.
> With the backquote and comma, it turns into something that contains a
> function, so tools can handle this `lambda' knowing that it *is* a
> function (e.g. it can be byte-compiled, can cause warnings if it uses
> obsolete functions, can be macro-expanded, ...).
Thanks! So now the next question, how can I write a macro whose
expansion contains backticks and commas, and I'm still able to
comma-expand in the "inner" backquoted parts?
Or with an example:
(defmacro define-context-key (keymap key dispatch)
`(define-key ,keymap ,key
(backquote
(menu-item "context-key" ignore
:filter (lambda (&optional ignored)
,dispatch)))))
How do I smuggle a `,' before the lambda?
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 <=
- 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, 2010/12/15
RE: Get a command by its keybinding and also respecting keytranslation, Drew Adams, 2010/12/15