emacs-devel
[Top][All Lists]
Advanced

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

M-g in dired


From: Juri Linkov
Subject: M-g in dired
Date: Sat, 15 Oct 2005 14:27:27 +0300
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

`M-g M-n' is a nice key binding for `next-error' (easy to type and
mnemonic), but has one problem.  Just imagine a quite likely scenario:
the user switches to the dired buffer, invokes `compile' or `grep', and
types `M-g M-n' to go to the first error displayed in the output buffer
in another window.  Now instead of going to the first error, the message
"End of history; no default available" is displayed in the echo area.
That's because `M-g' is bound to `dired-goto-file' in the dired buffer,
which activates the minibuffer, and the second key `M-n' typed by the
user is bound in the minibuffer to `next-history-element' (which signals
an error for no default value).

It seems `M-g' in dired buffers should be rebound for `dired-goto-file'
to a key sequence with the `M-g' prefix.  I see at least two variants:

1. Rebind `dired-goto-file' to `M-g g' (and `M-g M-g').  The global
   binding for `M-g g' is `goto-line' which doesn't seem to be useful
   in dired buffers.  So dired buffers could have a local binding
   `M-g g' for `dired-goto-file'.

2. Rebind `dired-goto-file' to `M-g f' (and `M-g M-f').  This key
   sequence could serve as a global key binding.  Typing it in any
   buffer could create a dired buffer and move point to the file
   specified in the minibuffer (with the default value being the
   current buffer's file name).

It is not unreasonable to have both bindings.

BTW, there is a bug related to key suggestions: `M-x next-error RET'
typed in a dired buffer suggests the key binding `M-g n' even though
`M-g' is not a prefix key in dired buffers.  Sometimes it may suggest
`C-x `' when `where-is-internal' returns the first keybindings.  Since
it's not possible to control which keybinding `where-is-internal'
returns, to reproduce this bug `C-x `' should be unbound globally,
e.g. by (define-key ctl-x-map "`" nil).  After that

(key-description (where-is-internal 'next-error overriding-local-map t))

evaluates in a dired buffer to "M-g n", but currently it is not
possible to use this key in dired buffers.

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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