emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111768: Add dired-hide-details-mode.


From: Christopher Schmidt
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111768: Add dired-hide-details-mode. (Bug#6799)
Date: Wed, 13 Feb 2013 10:42:31 +0100
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111768
fixes bug: http://debbugs.gnu.org/6799
committer: Christopher Schmidt <address@hidden>
branch nick: trunk
timestamp: Wed 2013-02-13 10:42:31 +0100
message:
  Add dired-hide-details-mode.  (Bug#6799)
  
  * locate.el (locate-mode): Set parent mode property to dired-mode.
  
  * find-dired.el (find-dired): Call dired-insert-set-properties on
  initial information line.  Set process mark on end of buffer.
  (find-dired-sentinel):
  Call dired-insert-set-properties on summary.
  
  * dired.el (dired-hide-details-hide-symlink-targets)
  (dired-hide-details-hide-information-lines): New options.
  (dired-insert-directory):
  Set properties after final treatment of output.
  (dired-insert-set-properties):
  Set dired-hide-details-* properties.
  (dired-mode-map): Bind dired-hide-details-mode.
  (dired-mode): Set buffer-invisibility-spec to a list.
  (dired-next-line): Skip hidden lines.
  (dired-previous-line): Use dired-next-line.
  (dired-hide-details-mode): New minor mode.
  (dired-hide-details-update-invisibility-spec): New function.
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/dired.el
  lisp/find-dired.el
  lisp/locate.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2013-02-13 08:50:44 +0000
+++ b/etc/NEWS  2013-02-13 09:42:31 +0000
@@ -120,6 +120,10 @@
 
 *** Support for ISO 8601 dates.
 
+** Dired
+
+*** New minor mode `dired-hide-details-mode' hides details.
+
 ** ERC
 
 *** New option `erc-accidental-paste-threshold-seconds'.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-02-13 08:50:44 +0000
+++ b/lisp/ChangeLog    2013-02-13 09:42:31 +0000
@@ -1,3 +1,27 @@
+2013-02-12  Christopher Schmidt  <address@hidden>
+
+       Add dired-hide-details-mode.  (Bug#6799)
+
+       * locate.el (locate-mode): Set parent mode property to dired-mode.
+
+       * find-dired.el (find-dired): Call dired-insert-set-properties on
+       initial information line.  Set process mark on end of buffer.
+       (find-dired-sentinel):
+       Call dired-insert-set-properties on summary.
+
+       * dired.el (dired-hide-details-hide-symlink-targets)
+       (dired-hide-details-hide-information-lines): New options.
+       (dired-insert-directory):
+       Set properties after final treatment of output.
+       (dired-insert-set-properties):
+       Set dired-hide-details-* properties.
+       (dired-mode-map): Bind dired-hide-details-mode.
+       (dired-mode): Set buffer-invisibility-spec to a list.
+       (dired-next-line): Skip hidden lines.
+       (dired-previous-line): Use dired-next-line.
+       (dired-hide-details-mode): New minor mode.
+       (dired-hide-details-update-invisibility-spec): New function.
+
 2013-02-13  Glenn Morris  <address@hidden>
 
        * play/yow.el: Move to obsolete/.  (Bug#9384)

=== modified file 'lisp/dired.el'
--- a/lisp/dired.el     2013-02-09 05:09:02 +0000
+++ b/lisp/dired.el     2013-02-13 09:42:31 +0000
@@ -230,6 +230,18 @@
   :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)
+
+(defcustom dired-hide-details-hide-information-lines t
+  "Non-nil means hide lines other than header and file/dir lines."
+  :type 'boolean
+  :version "24.4"
+  :group 'dired)
+
 ;; Internal variables
 
 (defvar dired-marker-char ?*           ; the answer is 42
@@ -1196,7 +1208,6 @@
       ;; Note: adjust dired-build-subdir-alist if you change this.
       (setq dir (replace-regexp-in-string "\\\\" "\\\\" dir nil t)
             dir (replace-regexp-in-string "\n" "\\n" dir nil t)))
-    (dired-insert-set-properties opoint (point))
     ;; If we used --dired and it worked, the lines are already indented.
     ;; Otherwise, indent them.
     (unless (save-excursion
@@ -1205,18 +1216,21 @@
       (let ((indent-tabs-mode nil))
        (indent-rigidly opoint (point) 2)))
     ;; Insert text at the beginning to standardize things.
-    (save-excursion
-      (goto-char opoint)
-      (if (and (or hdr wildcard)
-               (not (and (looking-at "^  \\(.*\\):$")
-                         (file-name-absolute-p (match-string 1)))))
+    (let ((content-point opoint))
+      (save-excursion
+       (goto-char opoint)
+       (when (and (or hdr wildcard)
+                  (not (and (looking-at "^  \\(.*\\):$")
+                            (file-name-absolute-p (match-string 1)))))
          ;; Note that dired-build-subdir-alist will replace the name
          ;; by its expansion, so it does not matter whether what we insert
          ;; here is fully expanded, but it should be absolute.
-         (insert "  " (directory-file-name (file-name-directory dir)) ":\n"))
-      (when wildcard
-       ;; Insert "wildcard" line where "total" line would be for a full dir.
-       (insert "  wildcard " (file-name-nondirectory dir) "\n")))))
+         (insert "  " (directory-file-name (file-name-directory dir)) ":\n")
+         (setq content-point (point)))
+       (when wildcard
+         ;; Insert "wildcard" line where "total" line would be for a full dir.
+         (insert "  wildcard " (file-name-nondirectory dir) "\n")))
+      (dired-insert-set-properties content-point (point)))))
 
 (defun dired-insert-set-properties (beg end)
   "Add various text properties to the lines in the region."
@@ -1224,15 +1238,24 @@
     (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")))
+         (if (not (dired-move-to-filename))
+             (put-text-property (line-beginning-position)
+                                (1+ (line-end-position))
+                                'invisible 'dired-hide-details-information)
+           (put-text-property (+ (line-beginning-position) 1) (1- (point))
+                              'invisible 'dired-hide-details-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 (< (+ (point) 4) (line-end-position))
+             (put-text-property (+ (point) 4) (line-end-position)
+                                'invisible 'dired-hide-details-link)))
        (error nil))
       (forward-line 1))))
 
@@ -1496,6 +1519,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)
@@ -1586,6 +1610,10 @@
       '(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 hide-details]
+      '(menu-item "Hide Details" dired-hide-details-mode
+                 :help "Hide details in buffer"
+                 :button (:toggle . dired-hide-details-mode)))
     (define-key map [menu-bar immediate revert-buffer]
       '(menu-item "Refresh" revert-buffer
                  :help "Update contents of shown directories"))
@@ -1914,6 +1942,9 @@
        selective-display t             ; for subdirectory hiding
        mode-line-buffer-identification
        (propertized-buffer-identification "%17b"))
+  ;; Ignore dired-hide-details-* 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)
@@ -1978,15 +2009,20 @@
   "Move down lines then position at filename.
 Optional prefix ARG says how many lines to move; default is one line."
   (interactive "p")
-  (forward-line arg)
+  (let ((line-move-visual)
+       (goal-column))
+    (line-move arg t))
+  ;; We never want to move point into an invisible line.
+  (while (and (invisible-p (point))
+             (not (if (and arg (< arg 0)) (bobp) (eobp))))
+    (forward-char (if (and arg (< arg 0)) -1 1)))
   (dired-move-to-filename))
 
 (defun dired-previous-line (arg)
   "Move up lines then position at filename.
 Optional prefix ARG says how many lines to move; default is one line."
   (interactive "p")
-  (forward-line (- arg))
-  (dired-move-to-filename))
+  (dired-next-line (- (or arg 1))))
 
 (defun dired-next-dirline (arg &optional opoint)
   "Goto ARG'th next directory file line."
@@ -2230,6 +2266,40 @@
       (substring file (match-end 0))
     file))
 
+;;; 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
+              'add-to-invisibility-spec
+            'remove-from-invisibility-spec)
+          'dired-hide-details-detail)
+  (funcall (if (and dired-hide-details-mode
+                   dired-hide-details-hide-information-lines)
+              'add-to-invisibility-spec
+            'remove-from-invisibility-spec)
+          'dired-hide-details-information)
+  (funcall (if (and dired-hide-details-mode
+                   dired-hide-details-hide-symlink-targets
+                   (not (derived-mode-p 'wdired-mode)))
+              'add-to-invisibility-spec
+            'remove-from-invisibility-spec)
+          'dired-hide-details-link))
+
 ;;; Functions for finding the file name in a dired buffer line.
 
 (defvar dired-permission-flags-regexp

=== modified file 'lisp/find-dired.el'
--- a/lisp/find-dired.el        2013-01-01 09:11:05 +0000
+++ b/lisp/find-dired.el        2013-02-13 09:42:31 +0000
@@ -210,13 +210,15 @@
     (insert "  " dir ":\n")
     ;; Make second line a ``find'' line in analogy to the ``total'' or
     ;; ``wildcard'' line.
-    (insert "  " args "\n")
+    (let ((point (point)))
+      (insert "  " args "\n")
+      (dired-insert-set-properties point (point)))
     (setq buffer-read-only t)
     (let ((proc (get-buffer-process (current-buffer))))
       (set-process-filter proc (function find-dired-filter))
       (set-process-sentinel proc (function find-dired-sentinel))
       ;; Initialize the process marker; it is used by the filter.
-      (move-marker (process-mark proc) 1 (current-buffer)))
+      (move-marker (process-mark proc) (point) (current-buffer)))
     (setq mode-line-process '(":%s"))))
 
 (defun kill-find ()
@@ -337,10 +339,11 @@
          (let ((buffer-read-only nil))
            (save-excursion
              (goto-char (point-max))
-             (insert "\n  find " state)
-             (forward-char -1)         ;Back up before \n at end of STATE.
-             (insert " at " (substring (current-time-string) 0 19))
-             (forward-char 1)
+             (let ((point (point)))
+               (insert "\n  find " state)
+               (forward-char -1)               ;Back up before \n at end of 
STATE.
+               (insert " at " (substring (current-time-string) 0 19))
+               (dired-insert-set-properties point (point)))
              (setq mode-line-process
                    (concat ":"
                            (symbol-name (process-status proc))))

=== modified file 'lisp/locate.el'
--- a/lisp/locate.el    2013-01-01 09:11:05 +0000
+++ b/lisp/locate.el    2013-02-13 09:42:31 +0000
@@ -496,6 +496,7 @@
   (setq revert-buffer-function 'locate-update)
   (set (make-local-variable 'page-delimiter) "\n\n")
   (run-mode-hooks 'locate-mode-hook))
+(put 'locate-mode 'derived-mode-parent 'dired-mode)
 
 (defun locate-do-setup (search-string)
   (goto-char (point-min))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]