Subject: bug#12311: 24.1.50; z in special-mode-map

From: "Drew Adams" <[email-masked]>
Date: Thu, 30 Aug 2012 08:40:36 -0700

> I just discovered why some of the Dired buffers I always keep
> occasionally disappear.  It is because the binding of z in
> special-mode-map makes it so easy to kill them.
> 
> I just got rid of that binding in my .emacs, but I think that binding
> is a bad idea.  Not all the buffers in special modes are things people
> don't mind deleting, and this key can cause annoyance if typed by
> accident.

+1

---

FWIW, I have long bound `z' to `diredp-compress-this-file', which is just a
this-file version of `Z' (`dired-do-compress').

(defun diredp-compress-this-file ()
  "In Dired, compress or uncompress the file on the cursor line."
  (interactive) (dired-do-compress 1))

---

Why do we even bother to have `dired-mode-map' inherit from `special-mode-map'?
These are the only keys from `special-mode-map' that Dired does not already
override:

- and 0-9	negative-argument and digit-argument
? and h	describe-mode
g		revert-buffer
q		quit-window
z		kill-this-buffer

(That and the fact that `s-m-m' uses `suppress-keymap'.)  And when you consider
that for `g' Dired defines its own `revert-function', there is not a lot that is
really taken from `s-m-m'.

Dired overrides `SPC', `DEL', `>', and `<'.  And `h' could also be overridden to
serve a Dired purpose in the future (`h' just duplicates `?').

We might as well just define the keys we want directly in `dired-mode-map' and
call `suppress-keymap' there.

Inheritance is useful if it really saves (factors out) something significant, or
if we want to be able to change something in one place and have that affect
other places.  The tradeoff is the extra coupling/dependency - someone changing
`s-m-m' needs to think carefully about how that change might affect each mode
that inherits from it.

In the case of Dired, inheritance of `s-m-m' doesn't offer much, IMHO.