unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14940: 24.3.50; [PATCH] enhancement for `dired-hide-details-mode'
@ 2013-07-23 16:28 Drew Adams
  2013-07-25 18:30 ` Stefan Monnier
  2013-11-04 15:33 ` Jambunathan K
  0 siblings, 2 replies; 9+ messages in thread
From: Drew Adams @ 2013-07-23 16:28 UTC (permalink / raw)
  To: 14940

[-- Attachment #1: Type: text/plain, Size: 3177 bytes --]

`dired-hide-details-mode' is essentially a reimplementation of
dired-details (by Rob Giardina).  The Emacs 24 implementation of
hiding details is better (more efficient) that that of dired-details,
which is a good thing.

But the behavior is not as good for users as that available with
dired-details+.  Attached is a patch that rectifies this.  It gives
users more control.

These are the enhancements:

1. Users can decide whether the initial hide/show state of new Dired
   buffers reflects the last chosen state for a Dired buffer.  This is
   decided by option `dired-hide-details-propagate'.  Non-nil means
   propagate the last chosen state as the initial state of a new Dired
   buffer.

2. If `dired-hide-details-propagate' is nil, or if the user has not
   yet explicitly changed any Dired hide/show state, then option
   `dired-hide-details-initially' defines the initial state of a new
   Dired buffer.  IOW, it specifies what the "last" state defaults to.

In the patch the default value of each option is t, but this is open
for discussion.  In my experience with dired-details+ most users
prefer to hide details by default and to let the last chosen state
update the default state.

But if we wanted to keep the traditional behavior by default then we
would just set both options to nil by default.  The main point is to
give users a choice.

Note that regardless of the option values, once a user has chosen a
state for a given Dired buffer it remains in effect until s?he hits
`(' to choose a different state for _that buffer_.  IOW, the options
affect only new Dired buffers, that is, buffers where the user has not
yet used `('.  A user display choice for a given buffer is never
overridden.

Initialization behavior applies also to `C-x C-v RET', that is,
accepting the same directory as the alternate one to visit.  This is
in keeping with `find-alternate-file' resetting other Dired settings
(markings, omissions, display order, switches, etc.).  Reverting using
`g', however, keeps the user's chosen display state; i.e., unlike `C-x
C-v RET', the state is not reinitialized with `g'.

Reasons to have non-nil default values for both options:

a. `dired-hide-details-propagate': Hide details by default.
   Simpler, screen-space conservative.  Show details on demand: `('.

b. `dired-hide-details-propagate': Propagate last view by default.
   This essentially tells Emacs, "Don't do anything I haven't told you
   to do.  Just keep doing what I last told you to do until I tell you
   otherwise."

For more explanation of why it is a good idea for
`dired-hide-details-propagate' ti be non-nil by default, see the thread
on emacs-devel:
http://lists.gnu.org/archive/html/emacs-devel/2013-07/msg00644.html


In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
 of 2013-07-14 on ODIEONE
Bzr revision: 113423 lekktu@gmail.com-20130715004922-i67tg2ois14h3fpm
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/binary --enable-checking=yes,glyphs
 CFLAGS='-O0 -g3' CPPFLAGS='-Ic:/Devel/emacs/include'
 LDFLAGS='-Lc:/Devel/emacs/lib''

[-- Attachment #2: dired-2013-07-20.patch --]
[-- Type: application/octet-stream, Size: 4142 bytes --]

diff -cw dired.el dired-patched-2013-07-20.el
*** dired.el	Sat Jul 20 12:10:57 2013
--- dired-patched-2013-07-20.el	Sat Jul 20 12:18:28 2013
***************
*** 249,254 ****
--- 249,266 ----
    :version "24.4"
    :group 'dired)
  
+ (defcustom dired-hide-details-initially t
+   "Non-nil means hide details in Dired from the outset."
+   :type 'boolean :version "24.4" :group 'dired)
+ 
+ (defcustom dired-hide-details-propagate t
+   "Non-nil means display the next Dired buffer the same way as the last.
+ The last `dired-hide-details-mode' value set is used by the next Dired
+ buffer created."
+   :type 'boolean :version "24.4" :group 'dired)
+ 
+ 
+ 
  ;; Internal variables
  
  (defvar dired-marker-char ?*		; the answer is 42
***************
*** 297,302 ****
--- 309,322 ----
  
  (put 'dired-actual-switches 'safe-local-variable 'dired-safe-switches-p)
  
+ (defvar dired-hide-details-last-state dired-hide-details-initially
+   "Last `dired-hide-details-mode' value.
+ Initialized to the value of option `dired-hide-details-initially'.")
+ 
+ (defvar dired-hide-details-toggled nil
+   "Non-nil means you have already toggled hiding details in this buffer.")
+ (make-variable-buffer-local 'dired-hide-details-toggled)
+ 
  (defvar dired-re-inode-size "[0-9 \t]*"
    "Regexp for optional initial inode and file size as made by `ls -i -s'.")
  
***************
*** 2265,2286 ****
        (substring file (match-end 0))
      file))
  \f
! ;;; Minor mode for hiding details
  ;;;###autoload
  (define-minor-mode dired-hide-details-mode
    "Hide details in Dired mode."
    :group 'dired
!   (unless (derived-mode-p 'dired-mode)
!     (error "Not a Dired buffer"))
    (dired-hide-details-update-invisibility-spec)
    (if dired-hide-details-mode
!       (add-hook 'wdired-mode-hook
! 		'dired-hide-details-update-invisibility-spec
! 		nil
! 		t)
!     (remove-hook 'wdired-mode-hook
! 		 'dired-hide-details-update-invisibility-spec
! 		 t)))
  
  (defun dired-hide-details-update-invisibility-spec ()
    (funcall (if dired-hide-details-mode
--- 2285,2309 ----
        (substring file (match-end 0))
      file))
  \f
! ;;; Minor modes for hiding details
! 
! ;;;###autoload
! (define-globalized-minor-mode global-dired-hide-details-mode dired-hide-details-mode
!   dired-hide-details-if-dired)
! 
  ;;;###autoload
  (define-minor-mode dired-hide-details-mode
      "Hide details in Dired mode."
+   (and dired-hide-details-propagate  dired-hide-details-last-state)
    :group 'dired
!   (unless (derived-mode-p 'dired-mode) (error "Not a Dired buffer"))
    (dired-hide-details-update-invisibility-spec)
+   (setq dired-hide-details-toggled  t)
+   (when dired-hide-details-propagate
+     (setq dired-hide-details-last-state  dired-hide-details-mode))
    (if dired-hide-details-mode
!       (add-hook 'wdired-mode-hook 'dired-hide-details-update-invisibility-spec nil t)
!     (remove-hook 'wdired-mode-hook 'dired-hide-details-update-invisibility-spec t)))
  
  (defun dired-hide-details-update-invisibility-spec ()
    (funcall (if dired-hide-details-mode
***************
*** 2299,2304 ****
--- 2322,2342 ----
  	     'remove-from-invisibility-spec)
  	   'dired-hide-details-link))
  
+ (defun dired-hide/show-details ()
+   "Hide/show details according to user options.
+ If `dired-hide-details-propagate' is non-nil and details have
+ never been hidden in the buffer, then hide/show according to your last
+ hide/show choice in any other Dired buffer or, if no last choice,
+ according to option `dired-hide-details-initially'."
+   (unless (or dired-hide-details-toggled ; No op if hide/show already set.
+               (buffer-narrowed-p)) ; No-op when showing just newly copied file etc.
+     (cond (dired-hide-details-propagate
+            (dired-hide-details-mode (if dired-hide-details-last-state 1 -1)))
+           (dired-hide-details-initially
+            (dired-hide-details-mode 1)))))
+ 
+ (add-hook 'dired-after-readin-hook #'dired-hide/show-details)
+ \f
  ;;; Functions for finding the file name in a dired buffer line.
  
  (defvar dired-permission-flags-regexp

Diff finished.  Sat Jul 20 12:20:35 2013

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

end of thread, other threads:[~2019-06-26 15:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-23 16:28 bug#14940: 24.3.50; [PATCH] enhancement for `dired-hide-details-mode' Drew Adams
2013-07-25 18:30 ` Stefan Monnier
2013-07-26  0:57   ` Drew Adams
2013-11-04 16:31     ` Stefan Monnier
2013-11-04 16:34       ` Jambunathan K
2013-11-04 17:35       ` Drew Adams
2013-11-04 15:33 ` Jambunathan K
2019-06-26 15:34   ` Lars Ingebrigtsen
2019-06-26 15:42     ` Drew Adams

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).