Subject: bug#15799: 24.3.50; dired-hide-details-mode: Provide default key binding

From: Drew Adams <[email-masked]>
Date: Mon, 4 Nov 2013 09:35:50 -0800 (PST)

> Thanks.  For #14914, there's no doubt for me that we should use
> a "[✓] Hide details" menu entry.

Sounds good to me (except it should be title case: `Hide Details').

> >> Also, wouldn't it make sense to try and bring hide-details
> >> "closer" to the dired-omit facilities?
> >
> > Definitely not.  No relation.  Completely different uses.
> 
> Of course, they're different, but I assume the @ was chosen because
> it's also used for things like outline-minor-mode, i.e. for other
> features that hide parts of the buffer.

`@' was proposed by Jambunathan, not I.  I have no special objection
to `@' instead of `(', however.

But I'm not convinced that it is good to confuse hiding stuff in
Dired with outline-minor-mode hiding.

> So, maybe @ should be a prefix key for "hiding stuff", in which we
> can place key bindings for "omit" and for "details".

I don't object to that.  As long as the two, hiding columns and
hiding rows, are kept clear and separate, no problem.

But there is really more to it than that.  There are at least these
hide/show commands in Dired:

$    (`dired-hide-subdir')
M-$  (`dired-hide-all')
(    (`dired-hide-details-mode')
M-o  (`dired-omit-mode')

It is good that each of these is quick, but yes, we could put them
all on a prefix key.  In that case, `M-o', `M-$', and `$' are also
good candidates for the prefix key.

We could have, for example:

M-o s  (`dired-hide-subdir')       - `s' for subdi
M-o S  (`dired-hide-all')          - `S' for subdirs
M-o c  (`dired-hide-details-mode') - `c' for columns
M-o r  (`dired-omit-mode')         - `r' for rows

No Shift key needed for them, except for the one that boosts `s'.

FWIW, Dired+ adds these commands, which could also be added to the
list, perhaps with these bindings:

M-o m  (`diredp-omit-marked')      - `m' for marked
M-o u  (`diredp-omit-unmarked')    - `u' for unmarked

Here are their (trivial) definitions:

(defun diredp-omit-marked ()
  "Omit lines of marked files.  Return the number of lines omitted."
  (interactive)
  (let ((old-modified-p  (buffer-modified-p))
        count)
    (when (interactive-p) (message "Omitting marked lines..."))
    (setq count  (dired-do-kill-lines nil "Omitted %d line%s."))
    (set-buffer-modified-p old-modified-p) ; So no `%*' appear in mode-line.
    count))

(defun diredp-omit-unmarked ()
  "Omit lines of unmarked files.  Return the number of lines omitted."
  (interactive)
  (let ((old-modified-p  (buffer-modified-p))
        count)
    (dired-toggle-marks)
    (message "Omitting unmarked lines...")
    (setq count  (diredp-omit-marked))
    (dired-toggle-marks)                ; Marks all except `.', `..'
    (set-buffer-modified-p old-modified-p) ; So no `%*' appear in mode-line.
    count))