[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Suggestion: Simple way to make conditional key bindings.
From: |
Richard Stallman |
Subject: |
Re: Suggestion: Simple way to make conditional key bindings. |
Date: |
Sun, 25 Aug 2002 18:36:28 -0600 (MDT) |
(global-set-key [f11]
'(cond
(a delete-char)
(b find-file)
(c nil)
(t (keymap (?a . "abc") (?b . "bcd")))))
I agree that this is convenient. The question is, is it better to
make this a primitive facility, as you suggested, or to add a macro to
do the job using menu-item, as Stefan suggested?
Using menu-item has an advantage that we use a function rather than
a form. It also has the advantage of not adding any complexity
to the key binding data structures.
But those are not the only factors; others may be more important.
One advantage (IMO) is that C-h k C-y will report yank or
yank-with-properties depending on the actual function taken if
you hit C-y.
If we use menu-item, what will C-h c say?
One problem with your change is "what binding do we use when we don't want
to run code?". The `menu-item' syntax provides a binding (in the example
above it's "my-filter" which is not very useful indeed) for the case
where code should not be evalled (for example in `where-is').
I think we do want where-is to find this binding, though.
(define-key global-map "\C-y" 'yank-careful)
(defun yank-careful (...)
"Reinsert the last stretch of killed text, like `yank'.
Contrary to `yank' this function is careful to preserve some important
text properties when yanking tables."
...)
The advantage is that C-h k C-y doesn't just give you one of the two
bindings but a docstring that describes both.
I think that sometimes this will be better, but sometimes it will be
better for C-h k to give the doc string for the specific command
that will be executed.
- Suggestion: Simple way to make conditional key bindings., Kim F. Storm, 2002/08/23
- Re: Suggestion: Simple way to make conditional key bindings.,
Richard Stallman <=
- Re: Suggestion: Simple way to make conditional key bindings., David PONCE, 2002/08/23
- Re: Suggestion: Simple way to make conditional key bindings., Kim F. Storm, 2002/08/23
- Re: Suggestion: Simple way to make conditional key bindings., Stefan Monnier, 2002/08/23
- Re: Suggestion: Simple way to make conditional key bindings., Kim F. Storm, 2002/08/25
- Re: Suggestion: Simple way to make conditional key bindings., Stefan Monnier, 2002/08/26
- Re: Suggestion: Simple way to make conditional key bindings., Miles Bader, 2002/08/26
- Re: Suggestion: Simple way to make conditional key bindings., Richard Stallman, 2002/08/27
- Re: Suggestion: Simple way to make conditional key bindings., Kim F. Storm, 2002/08/27