emacs-devel
[Top][All Lists]
Advanced

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

bypassing defining prefix keys


From: Drew Adams
Subject: bypassing defining prefix keys
Date: Sun, 4 Feb 2007 11:58:33 -0800

Perhaps this is a bug report; perhaps it is a request for info. I see a
behavior that I don't much like, but I don't know if that behavior might be
desirable for some other reason.

I have code that binds `S-tab' in all keymaps to a command that completes
key sequences. Then, for instance, you can use `C-x S-tab' to complete `C-x'
to anything in keymap `ctl-x-map'. Or you can use `f1 S-tab' to do more or
less what `f1 f1' does: show the `f1' bindings and their commands, and let
you invoke one - you can think of my key-completion feature as generalizing
what `f1 f1' does for help.

You can also use `S-tab' at the top level, to "complete" to any key. So, for
instance, as an alternative to using `C-x S-tab', you can use `S-tab' and
then pick the completion candidate `C-x'. This shows the possible
completions of `C-x', just as `C-x S-tab' does.

This works fine, for all prefix keys. However, it does not work for, say, `*
S-tab' in Dired mode, because `*' is not actually defined as a prefix key
there. The same problem exists for `%'.

You can still use `S-tab' at the top level of Dired, then pick `*' from the
list of *Completions* (which, in turn, shows the possible completions of
`*'), and then pick, say, `/' to invoke `dired-mark-directories'. But if you
use `* S-tab' then you get the error message "* <backtab> is undefined".

Here's why. In dired.el, instead of defining `*' and `%' as prefix keys, a
shortcut is taken. `*' and `%' are each bound to nil, so that they are
undefined in `dired-mode-map', and then each of the `*-<whatever>' and
`%-<whatever> key sequences is bound directly in `dired-mode-map'. That is:

 (define-key dired-mode-map "*" nil)
 (define-key dired-mode-map "*/" 'dired-mark-directories)
 ...

This explains the behavior I get, but I wonder if `*' and `%' should be
defined this way. Is there a guideline or policy on this? Obviously, it
would be better for my key-completion code if `*' and `%' were defined as
real prefix keys.

This comment appears in dired.el as the rationale for the current
implementation of `%'. Presumably it is meant for `*' as well.

 ;; Make all regexp commands share a `%' prefix:
 ;; We used to get to the submap via a symbol dired-regexp-prefix,
 ;; but that seems to serve little purpose, and copy-keymap
 ;; does a better job without it.

I don't understand the part about `copy-keymap' (which is not used in
dired.el, in any case). What is the `copy-keymap' limitation that is hinted
at here? Is it important that the Dired code avoid defining prefix keys this
way?

Can someone speak to whether this is still the best way for dired.el to
define the `*' and `%' pseudo prefix keys? If it's not the best way, can we
please use real prefix keys? Thx.






reply via email to

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