unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* bypassing defining prefix keys
@ 2007-02-04 19:58 Drew Adams
  2007-02-04 21:19 ` Andreas Schwab
  2007-02-05 19:10 ` Richard Stallman
  0 siblings, 2 replies; 6+ messages in thread
From: Drew Adams @ 2007-02-04 19:58 UTC (permalink / raw)
  To: Emacs-Devel

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-02-05 19:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-04 19:58 bypassing defining prefix keys Drew Adams
2007-02-04 21:19 ` Andreas Schwab
2007-02-04 21:27   ` Drew Adams
2007-02-04 22:03     ` Andreas Schwab
2007-02-04 22:19       ` Drew Adams
2007-02-05 19:10 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).