Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Less verbose dired

  • Loading branch information...
commit 1ad461e7cae10ab96c14f6c178307a0c8c85c795 1 parent 432f121
Julien BLANCHARD authored December 31, 2012
18  elpa/dired-details-20120921.1032/dired-details-autoloads.el
... ...
@@ -0,0 +1,18 @@
  1
+;;; dired-details-autoloads.el --- automatically extracted autoloads
  2
+;;
  3
+;;; Code:
  4
+
  5
+
  6
+;;;### (autoloads nil nil ("dired-details-pkg.el" "dired-details.el")
  7
+;;;;;;  (20705 40354 407059 0))
  8
+
  9
+;;;***
  10
+
  11
+(provide 'dired-details-autoloads)
  12
+;; Local Variables:
  13
+;; version-control: never
  14
+;; no-byte-compile: t
  15
+;; no-update-autoloads: t
  16
+;; coding: utf-8
  17
+;; End:
  18
+;;; dired-details-autoloads.el ends here
1  elpa/dired-details-20120921.1032/dired-details-pkg.el
... ...
@@ -0,0 +1 @@
  1
+(define-package "dired-details" "20120921.1032" "Make file details hide-able in dired [source: wiki]" (quote nil))
BIN  elpa/dired-details-20120921.1032/dired-details-pkg.elc
Binary file not shown
274  elpa/dired-details-20120921.1032/dired-details.el
... ...
@@ -0,0 +1,274 @@
  1
+;;; dired-details.el --- Make file details hide-able in dired
  2
+
  3
+;; Copyright (C) 2003-2011 Rob Giardina
  4
+
  5
+;; Version: 1.3.2
  6
+;; Keywords: dired, hide
  7
+;; Author: Rob Giardina <rob.giardina.ohmmanepadmespam@oracle.com>
  8
+;; Maintainer: Rob Giardina
  9
+;; Last updated: Aug 17, 2012
  10
+;; Contributors: Harold Maier, Klaus Berndl
  11
+
  12
+;; This file is not part of GNU Emacs.
  13
+
  14
+;; This is free software; you can redistribute it and/or modify it
  15
+;; under the terms of the GNU General Public License as published by
  16
+;; the Free Software Foundation; either version 2, or (at your option)
  17
+;; any later version.
  18
+;;
  19
+;; This is distributed in the hope that it will be useful, but WITHOUT
  20
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  21
+;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
  22
+;; License for more details.
  23
+;;
  24
+;; You should have received a copy of the GNU General Public License
  25
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
  26
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  27
+;; Boston, MA 02111-1307, USA.
  28
+
  29
+;;; Commentary:
  30
+
  31
+;; `dired-details-hide' makes dired buffers that look like this:
  32
+;;
  33
+;;  /private/rgiardin/lispHome:
  34
+;;  used 1264 available files
  35
+;;
  36
+;;  drwxr-xr-x   5 rgiardin g632         512 Jan 19  2003 ..
  37
+;;  -rw-r--r--   1 rgiardin svrtech     4141 Aug 23 17:07 dired-details.el
  38
+;;  -rw-r--r--   1 rgiardin svrtech     4141 Aug 23 17:07 my-really-really-long-I-mean-really-long-filename.el
  39
+;;  -rw-r--r--   1 rgiardin svrtech       56 Aug 23 17:07 linked-file.el -> /var/tmp/checkouts/linked-file.el
  40
+;;
  41
+;; look like this:
  42
+;;
  43
+;;  /private/rgiardin/lispHome/emacs.config:
  44
+;;  used 1264 available files
  45
+;;
  46
+;;  [...] ..
  47
+;;  [...] dired-details.el
  48
+;;  [...] my-really-really-long-I-mean-really-long-filename.el
  49
+;;  [...] linked-file.el -> [...]
  50
+;;
  51
+;; The function `dired-details-toggle' will toggle details on and off.
  52
+;;
  53
+;;
  54
+;; INSTALLATION:
  55
+;;
  56
+;; To apply `dired-details-hide' to all new dired buffers, add the
  57
+;; following to your .emacs:
  58
+;;
  59
+;; (require 'dired-details)
  60
+;; (dired-details-install)
  61
+;;
  62
+;; This also binds the following keys in dired buffers:
  63
+;;
  64
+;;   ) - dired-details-show
  65
+;;   ( - dired-details-hide
  66
+;;
  67
+;; CHANGES:
  68
+;;
  69
+;; * 1.3.2: Added sr-mode to dired-details-hide function to make it word with
  70
+;;          Sunrise Commander
  71
+;; * 1.3.1: Allow "misc lines (total used, find-dired statuses, etc)" to be hidden;
  72
+;;          suggested by Chris Poole
  73
+;; * 1.3: dired-details-toggle and customization support added by Klaus Berndl
  74
+;; * 1.2.4: Setup hide and show keybindings earlier than the first hide.
  75
+;; * 1.2.3: add dired-details-initially-hide customization as suggested by Harold Maier
  76
+;; * 1.2.2: extensive change to support subdirs in dired buffers
  77
+;; * 1.2.1: respect current hidden state (not initial state) when inserting subdirs
  78
+;;
  79
+;; TODO:
  80
+;; * add a hook for dired-add-file to hide new entries as necessary
  81
+;;
  82
+
  83
+;;; customizable vars
  84
+
  85
+(defgroup dired-details nil
  86
+  "Settings for the dired-details package."
  87
+  :group 'dired
  88
+  :prefix "dired-details-")
  89
+
  90
+(defcustom dired-details-hidden-string "[...]"
  91
+  "*This string will be shown in place of file details and symbolic links."
  92
+  :group 'dired-details
  93
+  :type 'string)
  94
+
  95
+(defcustom dired-details-hide-link-targets t
  96
+  "*Hide symbolic link target paths."
  97
+  :group 'dired-details
  98
+  :type 'boolean)
  99
+
  100
+(defcustom dired-details-initially-hide t
  101
+  "*Hide dired details on entry to dired buffers."
  102
+  :group 'dired-details
  103
+  :type 'boolean)
  104
+
  105
+(defcustom dired-details-hide-extra-lines t
  106
+  "*Hides lines matching any regex in `dired-details-invisible-lines'.
  107
+Changing this variable will not affect existing dired buffers."
  108
+  :group 'dired-details
  109
+  :type 'boolean)
  110
+
  111
+(defcustom dired-details-invisible-lines
  112
+  '("total used in directory" "^\\s-*$" "find finished" "find \\." "  wildcard ")
  113
+  "*Hide dired details on entry to dired buffers."
  114
+  :group 'dired-details
  115
+  :type 'list)
  116
+
  117
+;;; implementation
  118
+
  119
+(defvar dired-details-debug nil)
  120
+
  121
+(defvar dired-details-internal-overlay-list nil)
  122
+(make-variable-buffer-local 'dired-details-internal-overlay-list)
  123
+
  124
+(defvar dired-details-state nil
  125
+  "Three possible values: nil (has not been set), 'hidden (details are
  126
+hidden), 'shown (details are visible).")
  127
+(make-variable-buffer-local 'dired-details-state)
  128
+
  129
+(defun dired-details-install ()
  130
+  (eval-after-load "dired"
  131
+    '(progn
  132
+       (add-hook 'dired-after-readin-hook 'dired-details-activate)
  133
+
  134
+       (define-key dired-mode-map "(" 'dired-details-hide)
  135
+       (define-key dired-mode-map ")" 'dired-details-show)
  136
+
  137
+       (defadvice dired-revert (before remember-the-details activate)
  138
+         (dired-details-delete-overlays)))))
  139
+
  140
+(defun dired-details-activate ()
  141
+  "Set up dired-details in the current dired buffer. Called by
  142
+dired-after-readin-hook on initial display and when a subdirectory is
  143
+inserted (with `i')."
  144
+  ;;if a state has been chosen in this buffer, respect it
  145
+  (if dired-details-state
  146
+    (when (eq 'hidden dired-details-state)
  147
+      (dired-details-hide))
  148
+    ;;otherwise, use the default state
  149
+    (when dired-details-initially-hide
  150
+      (dired-details-hide))))
  151
+
  152
+(defun dired-details-delete-overlays ()
  153
+  (mapc '(lambda (list) (mapc 'delete-overlay
  154
+                             (cdr list)))
  155
+        dired-details-internal-overlay-list)
  156
+  (setq dired-details-internal-overlay-list nil))
  157
+
  158
+(defun dired-details-toggle ( &optional arg default-too )
  159
+  "Toggle visibility of dired details.
  160
+With positive prefix argument ARG hide the details, with negative
  161
+show them."
  162
+  (interactive "P")
  163
+  (let ((hide (if (null arg)
  164
+                (not (eq 'hidden dired-details-state))
  165
+                (> (prefix-numeric-value arg) 0))))
  166
+    (if default-too
  167
+      (setq dired-details-initially-hide hide))
  168
+    (if hide (dired-details-hide)
  169
+        (dired-details-show))))
  170
+
  171
+(defun dired-details-hide ()
  172
+  "Make an invisible, evaporable overlay for each file-line's details
  173
+in this dired buffer."
  174
+  (interactive)
  175
+  (unless (memq major-mode '(dired-mode vc-dired-mode sr-mode))
  176
+    (error "dired-details-hide can only be called in dired mode"))
  177
+
  178
+  (when dired-details-debug
  179
+    (let ((b (get-buffer-create "dired-details-debug")))
  180
+      (append-to-buffer b (point) (point-max))))
  181
+
  182
+  ;;NOTE - we call this even if we're already hidden. There may be a
  183
+  ;;new subdirectory inserted that we have to deal with. Pre-existing
  184
+  ;;subdirectories will reuse their cached overlays.
  185
+  (save-excursion
  186
+    (save-restriction
  187
+      (widen)
  188
+      ;;hide each displayed subdirectory
  189
+      (mapc
  190
+       '(lambda (dir-and-pos)
  191
+          (let ((cached-overlays (assoc (car dir-and-pos)
  192
+                                        dired-details-internal-overlay-list)))
  193
+            (if cached-overlays
  194
+              ;;reuse the existing overlays
  195
+              (dired-details-frob-overlays t)
  196
+              ;;no existing overlays for this subdir, make 'em
  197
+              (let ((cache (list (car dir-and-pos)))
  198
+                    (subdir-start (cdr dir-and-pos))
  199
+                    (subdir-end (1- (dired-get-subdir-max dir-and-pos))))
  200
+                (goto-char subdir-start)
  201
+                (forward-line 1) ;;always skip the dir line
  202
+                ;;v1.3 (dired-goto-next-file)
  203
+                (while (< (point) subdir-end)
  204
+                  (dired-details-make-current-line-overlay cache)
  205
+                  (forward-line 1))
  206
+                  ;;v1.3 (dired-next-line 1))
  207
+                (setq dired-details-internal-overlay-list
  208
+                      (cons cache dired-details-internal-overlay-list))))))
  209
+       dired-subdir-alist)))
  210
+  (setq dired-details-state 'hidden))
  211
+
  212
+(defun dired-details-show ()
  213
+  "Show whatever details a call to `dired-details-hide' may have
  214
+hidden in this buffer."
  215
+  (interactive)
  216
+  (dired-details-frob-overlays nil)
  217
+  (setq dired-details-state 'shown))
  218
+
  219
+(defun dired-details-make-current-line-overlay ( cache )
  220
+  (let* ((bol (progn (beginning-of-line) (point)))
  221
+         (totally-hide nil)
  222
+         (details              ;hide flags, size, owner, date, etc.
  223
+          (cond ((ignore-errors (dired-move-to-filename t))
  224
+                 (make-overlay (+ 2 bol) (point)))
  225
+                ((and dired-details-hide-extra-lines
  226
+                      (let ((line (buffer-substring (point-at-bol) (point-at-eol))))
  227
+                        (when (delq nil (mapcar (lambda (x) (string-match x line))
  228
+                                                dired-details-invisible-lines))
  229
+                          (let ((o (make-overlay bol (1+ (point-at-eol)))))
  230
+                            ;;this is delayed so that the hide-link bit below doesn't bork
  231
+                            (overlay-put o 'make-intangible t)
  232
+                            (overlay-put o 'suppress-before t)
  233
+                            o)))))))
  234
+         (ln-target            ;hide symlink dest
  235
+          (when dired-details-hide-link-targets
  236
+            (if (progn (beginning-of-line)
  237
+                       (search-forward-regexp
  238
+                        "-> \\(.*\\)"
  239
+                        (save-excursion (end-of-line) (point)) t))
  240
+              (make-overlay (match-beginning 1) (match-end 1))))))
  241
+    
  242
+    (when details
  243
+      (overlay-put details 'evaporate t)
  244
+      (dired-details-hide-overlay details)
  245
+
  246
+      (when ln-target
  247
+        (overlay-put ln-target 'evaporate t)
  248
+        (dired-details-hide-overlay ln-target))
  249
+
  250
+      (setcdr cache (append (if ln-target
  251
+                              (list ln-target details)
  252
+                              (list details))
  253
+                            (cdr cache))))))
  254
+
  255
+(defun dired-details-hide-overlay (o)
  256
+  (overlay-put o 'invisible t)
  257
+  (if (overlay-get o 'make-intangible) (overlay-put o 'intangible t))
  258
+  (unless (overlay-get o 'suppress-before)
  259
+    (overlay-put o 'before-string dired-details-hidden-string)))
  260
+
  261
+(defun dired-details-show-overlay (o)
  262
+  (overlay-put o 'invisible nil)
  263
+  (overlay-put o 'before-string nil))
  264
+
  265
+(defun dired-details-frob-overlays ( hide )
  266
+  (if dired-details-internal-overlay-list
  267
+    (mapc '(lambda (list)
  268
+             (mapc (if hide 'dired-details-hide-overlay 'dired-details-show-overlay)
  269
+                   (cdr list)))
  270
+          dired-details-internal-overlay-list)))
  271
+
  272
+(provide 'dired-details)
  273
+
  274
+;;; dired-details.el ends here
BIN  elpa/dired-details-20120921.1032/dired-details.elc
Binary file not shown
5  packages.el
@@ -161,3 +161,8 @@
161 161
 (require 'saveplace)
162 162
 (setq-default save-place t)
163 163
 (setq save-place-file (expand-file-name ".places" user-emacs-directory))
  164
+
  165
+;; Make dired less verbose
  166
+(require 'dired-details)
  167
+(setq-default dired-details-hidden-string "--- ")
  168
+(dired-details-install)

0 notes on commit 1ad461e

Please sign in to comment.
Something went wrong with that request. Please try again.