unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Christopher Schmidt <christopher@ch.ristopher.com>
To: 6799@debbugs.gnu.org
Cc: Michael Heerdegen <michael_heerdegen@web.de>
Subject: bug#6799: 24.0.50; Please add dired-details.el to Emacs [patch]
Date: Mon, 17 Dec 2012 13:24:31 +0000 (GMT)	[thread overview]
Message-ID: <87mwxcx149@ch.ristopher.com> (raw)
In-Reply-To: <jwvobht7i02.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 16 Dec 2012 17:31:39 -0500")

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

Stefan Monnier <monnier@iro.umontreal.ca> writes:

Hi Stefan,

thanks for your input.  Here is a preliminary patch for the trunk.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dired-dired-hide-details-mode.diff --]
[-- Type: text/x-diff, Size: 3479 bytes --]

--- lisp/dired.el
+++ lisp/dired.el
@@ -230,6 +230,12 @@
   :version "22.1"
   :group 'dired)
 
+(defcustom dired-hide-details-hide-symlink-targets t
+  "If non-nil, `dired-hide-details-mode' hides symbolic link targets."
+  :type 'boolean
+  :version "24.4"
+  :group 'dired)
+
 ;; Internal variables
 
 (defvar dired-marker-char ?*		; the answer is 42
@@ -1222,15 +1228,22 @@
     (goto-char beg)
     (while (< (point) end)
       (condition-case nil
-	  (if (dired-move-to-filename)
-	      (add-text-properties
-	       (point)
-	       (save-excursion
-		 (dired-move-to-end-of-filename)
-		 (point))
-	       '(mouse-face highlight
-		 dired-filename t
-		 help-echo "mouse-2: visit this file in other window")))
+	  (when (dired-move-to-filename)
+	    (put-text-property (+ (line-beginning-position) 2) (point)
+			       'invisible 'dired-detail)
+	    (add-text-properties
+	     (point)
+	     (progn
+	       (dired-move-to-end-of-filename)
+	       (point))
+	     '(mouse-face
+	       highlight
+	       dired-filename t
+	       help-echo "mouse-2: visit this file in other window"))
+	    (when (and dired-hide-details-hide-symlink-targets
+		       (< (+ (point) 4) (line-end-position)))
+	      (put-text-property (+ (point) 4) (line-end-position)
+				 'invisible 'dired-detail)))
 	(error nil))
       (forward-line 1))))
 \f
@@ -1494,6 +1507,7 @@
     ;; hiding
     (define-key map "$" 'dired-hide-subdir)
     (define-key map "\M-$" 'dired-hide-all)
+    (define-key map "(" 'dired-hide-details-mode)
     ;; isearch
     (define-key map (kbd "M-s a C-s")   'dired-do-isearch)
     (define-key map (kbd "M-s a M-C-s") 'dired-do-isearch-regexp)
@@ -1584,6 +1598,14 @@
       '(menu-item "Toggle Image Thumbnails in This Buffer" image-dired-dired-toggle-marked-thumbs
                   :help "Add or remove image thumbnails in front of marked file names"))
 
+    (define-key map [menu-bar immediate unhide-details]
+      '(menu-item "UnHide Details" dired-hide-details-mode
+		  :help "Unhide details in buffer"
+		  :visible dired-hide-details-mode))
+    (define-key map [menu-bar immediate hide-details]
+      '(menu-item "Hide Details" dired-hide-details-mode
+		  :help "Hide details in buffer"
+		  :visible (not dired-hide-details-mode)))
     (define-key map [menu-bar immediate revert-buffer]
       '(menu-item "Refresh" revert-buffer
 		  :help "Update contents of shown directories"))
@@ -1912,6 +1934,9 @@
 	selective-display t		; for subdirectory hiding
 	mode-line-buffer-identification
 	(propertized-buffer-identification "%17b"))
+  ;; ignore dired-detail value of invisible text property by default
+  (when (eq buffer-invisibility-spec t)
+    (setq buffer-invisibility-spec (list t)))
   (set (make-local-variable 'revert-buffer-function)
        (function dired-revert))
   (set (make-local-variable 'buffer-stale-function)
@@ -2228,6 +2253,20 @@
       (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"))
+  (funcall (if dired-hide-details-mode
+	       'add-to-invisibility-spec
+	     'remove-from-invisibility-spec)
+	   'dired-detail))
+
+(put 'dired-hide-details-mode 'safe-local-variable 'booleanp)
+\f
 ;;; Functions for finding the file name in a dired buffer line.
 
 (defvar dired-permission-flags-regexp

[-- Attachment #3: Type: text/plain, Size: 2680 bytes --]


I would love to hear your feedback.

>>   (save-restriction
>>     (widen)
>
> Please add a comment explaining why widening should be used here.

Widening is not necessary any more.

>>               do (let ((buffer-read-only))
>>                    (put-text-property (point) end
>>                                       'invisible my-dired-hide-details-mode))
>
> Better bind inhibit-read-only to t.  Or better yet, use
> with-silent-modifications (but move it outside the loop).
>
> Also, rather than set the invisible property to nil or t, better set
> it to another symbol (e.g. `dired-details'), whose meaning is then
> controlled by add-to-invisibility-spec.

Right.  Obviously this simplifies the implementation.

>> (defadvice dired-insert-set-properties
>>   (after my-add-hide-props (beg end) activate)
>
> Obviously, this would have to be turned into a patch, and since it's
> not small, it would need to be moved to its own function (which would
> be called from dired-insert-set-properties).

Check the new patch.  Altogether 7 new lines are added to
dired-insert-set-properties.

>> (defadvice find-dired (after my-fix-move-process-mark-to-arg activate)
>>   (move-marker (process-mark (get-buffer-process (current-buffer)))
>>             (save-excursion
>>               (goto-char (point-min))
>>               (forward-line 1)
>>               (point))))
>
> How is that related to dired-details?

This is not necessary any more.

My former implementation hid every non-file line that
dired-insert-set-properties is called upon.  Vanilla dired calls
dired-insert-set-properties on every line except the directory
headerline so my-dired-hide-details-mode hid the information line.

    total used in directory RMS available VI

Initially find-dired inserts the directory headerline, newline and the
find arguments and set the process mark is set to 1.

In the process filter of find find-dired evals

    (dired-insert-set-properties (process-mark proc)
                                 (1+ (point)))
    (move-marker (process-mark proc) (1+ (point)))

with (point) being right before the end of the last complete line added
by find.

That is dired-insert-set-properties is called on the first and second
line so my former code added the invisible property to the directory
headerline as well.  This is why I added that advice - just move the
process mark to the second line so dired-insert-set-properties is not
called on the directory headerline.

I removed the hiding of non-file lines.  Hiding full lines via text
properties might cause confusion when it comes to interactive line
movement.  There are no changed to find-dired.el now.

        Christopher

  reply	other threads:[~2012-12-17 13:24 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
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 [this message]
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=87mwxcx149@ch.ristopher.com \
    --to=christopher@ch.ristopher.com \
    --cc=6799@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    /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).