unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Rob Giardina <rob@giardina.us>
To: Drew Adams <drew.adams@oracle.com>
Cc: Juanma Barranquero <lekktu@gmail.com>,
	Lars Magne Ingebrigtsen <larsi@gnus.org>,
	6799@debbugs.gnu.org
Subject: bug#6799: 24.0.50; Please add dired-details.el to Emacs [patch]
Date: Wed, 25 Apr 2012 11:46:46 -0400	[thread overview]
Message-ID: <CAL=ALH138Zask0Ct1PkYEivYsCMBugjBFgd89uUX88BfmjL6zA@mail.gmail.com> (raw)
In-Reply-To: <65D921448B0644988BE6445A2EF3E021@us.oracle.com>

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

Thanks for remembering this patch Drew. I did work with RMS a long way
back but it fell by the wayside in the last phases.

The patch is just elisp and doc, no C. The changes are pretty simple
and contain all the community enhancements added later
(dired-details+).

Basically, it adds some bindings to a few functions that will loop
over the dired file listing lines to add invisibile overlays to the
messiest parts of the lines. Pretty self-contained.

It would have to be re-tested at this point. I've attached the old
ones if it will help decide if you want the feature. I can test some
fresh patches on HEAD in the next few weeks when my biz/personal life
calms a bit.

Regards,
Rob

On Thu, Apr 12, 2012 at 4:05 PM, Drew Adams <drew.adams@oracle.com> wrote:
>
> As I have said several times now, ask Rob Giardina.  He made a whole set of
> changes to various Emacs files, including perhaps C code.  I am not aware of
> what changes he made.
>
> Rob has sent mail as recently as 2011/11/29 to emacs-orgmode@gnu.org.  His
> address for that was rob@giardina.us.  (No, I do not subscribe to that mailing
> list.  But I know how to use Google.)  Please contact Rob.
>
> > > Please contact Rob Giardina.  I believe that he patched the existing
> > > Dired code (and some C code? and some other Lisp code?), doing
> > > everything that was needed.
> >
> > If you want this code included in Emacs, please assemble the patch and
> > post it here.
>
> It is not a question of "if I want".  It was decided by RMS that this should be
> included in Emacs.  Long, long ago.  Rob did the work required for this to
> happen, but no one ever committed it, AFAIK.
>
> What I use, personally, is dired-details.el plus dired-details+.el, and they
> suffice.  But Rob went to the trouble of patching Emacs in various places,
> integrating the features cleanly at a more basic level etc.
>
> I have no idea what Rob's changes were, but if you search the mailing list
> perhaps you can find references to them.  Rob refers to a patch for 2005-07-07
> CVS, here:
> http://comments.gmane.org/gmane.emacs.devel/74172
>
> Here is the last mail from Rob on the subject, AFAIK:
> http://lists.gnu.org/archive/html/emacs-devel/2007-07/msg00215.html
>
> Here is my last mail on the subject, with relevant links:
>
> > From: Drew Adams Sent: Sunday, July 19, 2009 7:34 AM
> > > I discovered dired-details and dired-details+ and found them useful.
> > > Could they be added to emacs?
> > >
> > > http://www.emacswiki.org/emacs/DiredDetails
> >
> > They were supposed to be added. Rob Giardina submitted an
> > Emacs 23 patch two years ago that integrates the functionality
> > of both in a better way even than the separate libraries
> > dired-details[+].el.
> >
> > I don't think any reason was ever given for why the patch
> > wasn't incorporated (committed). RMS asked for comment on
> > the merged code, but no one ever answered his request
> > (on emacs-devel, at least). The last time I ping'ed the
> > list about this was 2008-07 - I never got an answer either.
> >
> > Last ping:
> > http://lists.gnu.org/archive/html/emacs-devel/2008-07/msg01152.html
> >
> > Rob's change log and RMS's call for comment:
> > http://lists.gnu.org/archive/html/emacs-devel/2007-07/msg01187.html
> >
> > Original thread:
> > http://lists.gnu.org/archive/html/emacs-devel/2007-07/msg00226.html
>

[-- Attachment #2: dired-x.el.patch --]
[-- Type: application/octet-stream, Size: 699 bytes --]

*** old/dired-x.el	Sun Jul 15 21:25:37 2007
--- new/dired-x.el	Sun Jul 15 22:00:23 2007
***************
*** 755,761 ****
    (set (make-local-variable 'dired-subdir-alist) nil)
    (dired-build-subdir-alist)
    (goto-char (point-min))
!   (dired-initial-position dirname))
  
  (defun dired-virtual-guess-dir ()
    "Guess and return appropriate working directory of this buffer.
--- 755,762 ----
    (set (make-local-variable 'dired-subdir-alist) nil)
    (dired-build-subdir-alist)
    (goto-char (point-min))
!   (dired-initial-position dirname)
!   (run-hooks 'dired-after-readin-hook))
  
  (defun dired-virtual-guess-dir ()
    "Guess and return appropriate working directory of this buffer.

[-- Attachment #3: dired.el.patch --]
[-- Type: application/octet-stream, Size: 8133 bytes --]

*** old/dired.el	Sun Jul 15 15:42:33 2007
--- new/dired.el	Sun Jul 15 21:19:44 2007
***************
*** 1042,1047 ****
--- 1042,1048 ----
      (goto-char (point-min))
      (setq mark-alist;; only after dired-remember-hidden since this unhides:
  	  (dired-remember-marks (point-min) (point-max)))
+     (dired-details-delete-overlays) ;;ditch the entire overlay cache
      ;; treat top level dir extra (it may contain wildcards)
      (dired-uncache
       (if (consp dired-directory) (car dired-directory) dired-directory))
***************
*** 1242,1247 ****
--- 1243,1251 ----
      (define-key map "\C-n" 'dired-next-line)
      (define-key map "\C-p" 'dired-previous-line)
      (define-key map [down] 'dired-next-line)
+     (define-key map "(" 'dired-details-hide)
+     (define-key map ")" 'dired-details-show)
+     (define-key map ";" 'dired-details-toggle)
      (define-key map [up] 'dired-previous-line)
      ;; hiding
      (define-key map "$" 'dired-hide-subdir)
***************
*** 3334,3339 ****
--- 3338,3508 ----
  	     '(dired-mode . dired-restore-desktop-buffer))
  
  \f
+ ;;; optionally hide file details and link targets
+ 
+ (defgroup dired-details nil
+   "Settings for to hide file details and symbolic link targets."
+   :group 'dired
+   :prefix "dired-details-")
+ 
+ (defcustom dired-details-hidden-string "[...]"
+   "*This string will be shown in place of file details and symbolic links."
+   :group 'dired-details
+   :type 'string)
+ 
+ (defcustom dired-details-hide-link-targets t
+   "*Hide symbolic link target paths."
+   :group 'dired-details
+   :type 'boolean)
+ 
+ (defcustom dired-details-initially-hide nil
+   "*Hide dired details on entry to dired buffers."
+   :group 'dired-details
+   :type 'boolean)
+ 
+ (defvar dired-details-internal-overlay-cache nil)
+ (make-variable-buffer-local 'dired-details-internal-overlay-cache)
+ 
+ (defvar dired-details-state nil
+   "Three possible values: nil (has not been set), 'hidden (details are
+ hidden), 'shown (details are visible).")
+ (make-variable-buffer-local 'dired-details-state)
+ 
+ (defun dired-details-activate()
+   "Set up dired-details in the current dired buffer. Called by
+ dired-after-readin-hook on initial display and when a dired
+ buffer is modified. If the state of detail display has been set
+ in this buffer then use that state, otherwise use the value of
+ `dired-details-initially-hide'."
+   (if (eq 'hidden dired-details-state)
+       (dired-details-hide)
+       (when dired-details-initially-hide
+         (dired-details-hide))))
+ (add-hook 'dired-after-readin-hook 'dired-details-activate)
+ 
+ (defun dired-details-delete-overlays()
+   (dolist (dir-and-overlays dired-details-internal-overlay-cache)
+     (dolist (overlay (cdr dir-and-overlays))
+       (delete-overlay overlay)))
+   (setq dired-details-internal-overlay-cache nil))
+ 
+ (defun dired-details-toggle (&optional arg default-too)
+   "Toggle visibility of dired details.
+ With positive prefix argument ARG hide the details, with negative
+ show them."
+   (interactive "P")
+   (let ((hide (if (null arg)
+                   (not (eq 'hidden dired-details-state))
+                 (> (prefix-numeric-value arg) 0))))
+     (if default-too
+         (setq dired-details-initially-hide hide))
+     (if hide (dired-details-hide)
+       (dired-details-show))))
+ 
+ (defun dired-details-hide()
+   "Make an invisible, evaporable overlay for each visible file
+ details in this dired buffer. This is called from
+ dired-after-readin-hook in different contexts: (1) narrowed to a
+ single file (after copy, move, symlink etc.)  (2) narrowed to a
+ single subdir (e.g. after dired-insert-subdir) (3) with multiple
+ visible subdirs and not narrowed (e.g. after dired-revert)"
+   (interactive)
+   (unless (memq major-mode '(dired-mode vc-dired-mode))
+     (error "dired-details-hide can only be called in dired mode"))
+ 
+   (save-excursion
+     (goto-char (point-min))
+     (if (not (looking-at dired-subdir-regexp))
+         ;;a single file or files -- just make an overlay for each
+         (let* ((parent (dired-current-directory))
+                (cached-parent-overlays
+                 (assoc parent dired-details-internal-overlay-cache)))
+           (unless cached-parent-overlays
+             (error "dired-details overlays not found for directory %s" parent))
+           (dired-goto-next-file)
+           (while (< (point) (point-max))
+             (dired-details-make-current-line-overlay cached-parent-overlays)
+             (dired-next-line 1)))
+ 
+         ;;hide each visible subdirectory (either of cases (2) or (3)
+         ;;mentioned above)
+         (dolist (dir-and-pos dired-subdir-alist)
+           (let* ((dir (car dir-and-pos))
+                  (pos (cdr dir-and-pos))
+                  (cached-overlays
+                   (assoc dir dired-details-internal-overlay-cache)))
+             ;;skip this directory if it's outside of a narrowed region
+             (when (and (>= pos (point-min)) (<= pos (point-max)))
+               (if cached-overlays
+                   (dired-details-frob-overlays t) ;;reuse existing
+                   (let ((cache (list dir)) ;;make new overlays
+                         (subdir-start (let ((rest pos))
+                                         ;;xemacs compat: in xemacs, this is a list
+                                         (if (atom rest) rest (car rest))))
+                         (subdir-end (1- (dired-get-subdir-max dir-and-pos))))
+                     (goto-char subdir-start)
+                     (dired-goto-next-file)
+                     (while (< (point) subdir-end)
+                       ;;nb: uses setcdr to update cache
+                       (dired-details-make-current-line-overlay cache)
+                       (dired-next-line 1))
+                     (setq dired-details-internal-overlay-cache
+                           (cons cache dired-details-internal-overlay-cache)))))))
+         (setq dired-details-state 'hidden))))
+     
+ (defun dired-details-show()
+   "Show whatever details a call to `dired-details-hide' may have
+ hidden in this buffer."
+   (interactive)
+   (dired-details-frob-overlays nil)
+   (setq dired-details-state 'shown))
+ 
+ (defun dired-details-make-current-line-overlay (cache)
+   (let ((detail-overlay ;hide the flags, size, owner, date, etc.
+          (make-overlay
+           (+ 2 (progn (beginning-of-line) (point)))
+           (progn (dired-move-to-filename)(point))))
+          
+         (ln-target ;hide the destination of a symbolic when
+          (when dired-details-hide-link-targets
+            (if (progn (beginning-of-line)
+                       (search-forward-regexp
+                        "-> \\(.*\\)"
+                        (save-excursion (end-of-line)(point)) t))
+                (make-overlay (match-beginning 1) (match-end 1))))))
+ 
+     ;;delete the overlay when the dired line goes away
+     (overlay-put detail-overlay 'evaporate t)
+     (dired-details-hide-overlay detail-overlay)
+ 
+     (when ln-target
+       (overlay-put ln-target 'evaporate t)
+       (dired-details-hide-overlay ln-target))
+ 
+     (setcdr cache (append (if ln-target
+                               (list ln-target detail-overlay)
+                             (list detail-overlay))
+                           (cdr cache)))
+     detail-overlay))
+ 
+ (defun dired-details-hide-overlay (o)
+   (overlay-put o 'invisible t)
+   (overlay-put o 'before-string dired-details-hidden-string))
+ 
+ (defun dired-details-show-overlay (o)
+   (overlay-put o 'invisible nil)
+   (overlay-put o 'before-string ""))
+ 
+ (defun dired-details-frob-overlays (hide)
+   (when dired-details-internal-overlay-cache
+     (let ((frobber (if hide 'dired-details-hide-overlay
+                             'dired-details-show-overlay)))
+       (dolist (dir-and-overlays dired-details-internal-overlay-cache)
+         (dolist (overlay (cdr dir-and-overlays))
+           (funcall frobber overlay))))))
+   
+ \f
+ 
  (if (eq system-type 'vax-vms)
      (load "dired-vms"))
  

[-- Attachment #4: dired.texi.patch --]
[-- Type: application/octet-stream, Size: 2171 bytes --]

*** old/dired.texi	Sun Jul 15 18:00:22 2007
--- new/dired.texi	Sun Jul 15 18:00:10 2007
***************
*** 41,46 ****
--- 41,47 ----
  @end ifnottex
  * Subdirectory Motion::	      Moving across subdirectories, and up and down.
  * Hiding Subdirectories::     Making subdirectories visible or invisible.
+ * Hiding File Details::       Making file attributes visible or invisible.
  * Updating: Dired Updating.   Discarding lines for files of no interest.
  * Find: Dired and Find.	      Using `find' to choose the files for Dired.
  * Wdired::                    Operating on files by editing the Dired buffer.
***************
*** 1011,1016 ****
--- 1012,1056 ----
  without having to remove the Dired marks on files in those
  subdirectories.
  
+ @node Hiding File Details
+ @section Hiding File Details
+ 
+ @cindex hiding in Dired (Dired)
+   @dfn{Hiding} file details means making file attributes and symbolic
+ link targets invisible using overlays (@pxref{Overlays,,, elisp, the
+ Emacs Lisp Reference Manual}). This converts the dired display to a
+ terse list of filenames while continuing to support all normal dired
+ commands.
+ 
+ @table @kbd
+ @item @kbd{;}
+ @findex dired-details-toggle
+ @kindex @kbd{;} @r{(Dired)}
+ Hide or reveal file details in the current Dired buffer.
+ 
+ @item @kbd{(}
+ @findex dired-details-hide
+ @kindex @kbd{(} @r{(Dired)}
+ Hide file details in the current Dired buffer.
+ 
+ @item @kbd{)}
+ @findex dired-details-hide
+ @kindex @kbd{)} @r{(Dired)}
+ Show file details in the current Dired buffer.
+ @end table
+ 
+    You can customize @code{dired-details-hidden-string} to display any
+ string in place of hidden details and link targets (the default is
+ "[...]").
+ 
+    The option @code{dired-details-hide-link-targets} can be set to
+ @code{nil} to show link targets when details are hidden. The default is to
+ hide link targets.
+ 
+    Currently, the dired-sort-* family of functions do not call
+ @code{dired-after-readin-hook} and thus will not hide details until
+ the next call to @code{dired-revert} (@kbd{g}).
+ 
  @node Dired Updating
  @section Updating the Dired Buffer
  @cindex updating Dired buffer

  reply	other threads:[~2012-04-25 15:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-05 14:20 bug#6799: 24.0.50; Please add dired-details.el to Emacs [patch] Drew Adams
2011-01-28 23:08 ` Drew Adams
2011-03-13  3:28   ` Juanma Barranquero
2011-03-13 16:58     ` Drew Adams
2012-04-12 19:10       ` Lars Magne Ingebrigtsen
2012-04-12 20:05         ` Drew Adams
2012-04-25 15:46           ` Rob Giardina [this message]
2012-07-21 20:12             ` Drew Adams
2012-12-15 21:15               ` Christopher Schmidt
2012-12-15 22:17                 ` Christopher Schmidt
2012-12-16 22:31                   ` Stefan Monnier
2012-12-17 13:24                     ` Christopher Schmidt
2013-02-10 15:02                       ` Christopher Schmidt
2013-02-10 15:08                         ` Christopher Schmidt
2013-02-11  3:37                         ` Stefan Monnier
2013-02-11  8:19                           ` Christopher Schmidt
2013-02-11 14:25                             ` Stefan Monnier
2013-02-11 16:08                               ` Christopher Schmidt
2013-02-11 17:58                                 ` Stefan Monnier
2013-02-11 18:07                                   ` Drew Adams
2013-02-11 19:52                                   ` Christopher Schmidt
2013-02-13  9:54                                     ` Christopher Schmidt
2013-02-15 15:25                                     ` Stefan Monnier
2013-02-15 18:44                                       ` Christopher Schmidt
2013-02-16 21:52                                         ` Juri Linkov
2013-02-16 22:58                                           ` Drew Adams
2013-02-17 10:05                                             ` Juri Linkov
2013-02-17 14:57                                           ` Christopher Schmidt
2013-02-18  9:49                                             ` Juri Linkov
2013-02-18 14:38                                               ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAL=ALH138Zask0Ct1PkYEivYsCMBugjBFgd89uUX88BfmjL6zA@mail.gmail.com' \
    --to=rob@giardina.us \
    --cc=6799@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=larsi@gnus.org \
    --cc=lekktu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).