aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Schmidt2013-02-13 10:42:31 +0100
committerChristopher Schmidt2013-02-13 10:42:31 +0100
commita2a538b15e483eddffb555352bc0316ec44ac806 (patch)
tree475f9490e882cc61ef66e71c98ab1c761858a90b
parent4e16ddf47e6060876d5c8b5a5a04f5b127c2d2bf (diff)
downloademacs-a2a538b15e483eddffb555352bc0316ec44ac806.tar.gz
emacs-a2a538b15e483eddffb555352bc0316ec44ac806.zip
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.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog24
-rw-r--r--lisp/dired.el114
-rw-r--r--lisp/find-dired.el15
-rw-r--r--lisp/locate.el1
5 files changed, 130 insertions, 28 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 05d2f7edb06..770ebc17ac0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -120,6 +120,10 @@ on the given date.
120 120
121*** Support for ISO 8601 dates. 121*** Support for ISO 8601 dates.
122 122
123** Dired
124
125*** New minor mode `dired-hide-details-mode' hides details.
126
123** ERC 127** ERC
124 128
125*** New option `erc-accidental-paste-threshold-seconds'. 129*** New option `erc-accidental-paste-threshold-seconds'.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d7c7ed7218f..fe5ac8803b9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,27 @@
12013-02-12 Christopher Schmidt <christopher@ch.ristopher.com>
2
3 Add dired-hide-details-mode. (Bug#6799)
4
5 * locate.el (locate-mode): Set parent mode property to dired-mode.
6
7 * find-dired.el (find-dired): Call dired-insert-set-properties on
8 initial information line. Set process mark on end of buffer.
9 (find-dired-sentinel):
10 Call dired-insert-set-properties on summary.
11
12 * dired.el (dired-hide-details-hide-symlink-targets)
13 (dired-hide-details-hide-information-lines): New options.
14 (dired-insert-directory):
15 Set properties after final treatment of output.
16 (dired-insert-set-properties):
17 Set dired-hide-details-* properties.
18 (dired-mode-map): Bind dired-hide-details-mode.
19 (dired-mode): Set buffer-invisibility-spec to a list.
20 (dired-next-line): Skip hidden lines.
21 (dired-previous-line): Use dired-next-line.
22 (dired-hide-details-mode): New minor mode.
23 (dired-hide-details-update-invisibility-spec): New function.
24
12013-02-13 Glenn Morris <rgm@gnu.org> 252013-02-13 Glenn Morris <rgm@gnu.org>
2 26
3 * play/yow.el: Move to obsolete/. (Bug#9384) 27 * play/yow.el: Move to obsolete/. (Bug#9384)
diff --git a/lisp/dired.el b/lisp/dired.el
index b5fc46eb78d..28045043c82 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -230,6 +230,18 @@ new dired buffers."
230 :version "22.1" 230 :version "22.1"
231 :group 'dired) 231 :group 'dired)
232 232
233(defcustom dired-hide-details-hide-symlink-targets t
234 "If non-nil, `dired-hide-details-mode' hides symbolic link targets."
235 :type 'boolean
236 :version "24.4"
237 :group 'dired)
238
239(defcustom dired-hide-details-hide-information-lines t
240 "Non-nil means hide lines other than header and file/dir lines."
241 :type 'boolean
242 :version "24.4"
243 :group 'dired)
244
233;; Internal variables 245;; Internal variables
234 246
235(defvar dired-marker-char ?* ; the answer is 42 247(defvar dired-marker-char ?* ; the answer is 42
@@ -1196,7 +1208,6 @@ see `dired-use-ls-dired' for more details.")
1196 ;; Note: adjust dired-build-subdir-alist if you change this. 1208 ;; Note: adjust dired-build-subdir-alist if you change this.
1197 (setq dir (replace-regexp-in-string "\\\\" "\\\\" dir nil t) 1209 (setq dir (replace-regexp-in-string "\\\\" "\\\\" dir nil t)
1198 dir (replace-regexp-in-string "\n" "\\n" dir nil t))) 1210 dir (replace-regexp-in-string "\n" "\\n" dir nil t)))
1199 (dired-insert-set-properties opoint (point))
1200 ;; If we used --dired and it worked, the lines are already indented. 1211 ;; If we used --dired and it worked, the lines are already indented.
1201 ;; Otherwise, indent them. 1212 ;; Otherwise, indent them.
1202 (unless (save-excursion 1213 (unless (save-excursion
@@ -1205,18 +1216,21 @@ see `dired-use-ls-dired' for more details.")
1205 (let ((indent-tabs-mode nil)) 1216 (let ((indent-tabs-mode nil))
1206 (indent-rigidly opoint (point) 2))) 1217 (indent-rigidly opoint (point) 2)))
1207 ;; Insert text at the beginning to standardize things. 1218 ;; Insert text at the beginning to standardize things.
1208 (save-excursion 1219 (let ((content-point opoint))
1209 (goto-char opoint) 1220 (save-excursion
1210 (if (and (or hdr wildcard) 1221 (goto-char opoint)
1211 (not (and (looking-at "^ \\(.*\\):$") 1222 (when (and (or hdr wildcard)
1212 (file-name-absolute-p (match-string 1))))) 1223 (not (and (looking-at "^ \\(.*\\):$")
1224 (file-name-absolute-p (match-string 1)))))
1213 ;; Note that dired-build-subdir-alist will replace the name 1225 ;; Note that dired-build-subdir-alist will replace the name
1214 ;; by its expansion, so it does not matter whether what we insert 1226 ;; by its expansion, so it does not matter whether what we insert
1215 ;; here is fully expanded, but it should be absolute. 1227 ;; here is fully expanded, but it should be absolute.
1216 (insert " " (directory-file-name (file-name-directory dir)) ":\n")) 1228 (insert " " (directory-file-name (file-name-directory dir)) ":\n")
1217 (when wildcard 1229 (setq content-point (point)))
1218 ;; Insert "wildcard" line where "total" line would be for a full dir. 1230 (when wildcard
1219 (insert " wildcard " (file-name-nondirectory dir) "\n"))))) 1231 ;; Insert "wildcard" line where "total" line would be for a full dir.
1232 (insert " wildcard " (file-name-nondirectory dir) "\n")))
1233 (dired-insert-set-properties content-point (point)))))
1220 1234
1221(defun dired-insert-set-properties (beg end) 1235(defun dired-insert-set-properties (beg end)
1222 "Add various text properties to the lines in the region." 1236 "Add various text properties to the lines in the region."
@@ -1224,15 +1238,24 @@ see `dired-use-ls-dired' for more details.")
1224 (goto-char beg) 1238 (goto-char beg)
1225 (while (< (point) end) 1239 (while (< (point) end)
1226 (condition-case nil 1240 (condition-case nil
1227 (if (dired-move-to-filename) 1241 (if (not (dired-move-to-filename))
1228 (add-text-properties 1242 (put-text-property (line-beginning-position)
1229 (point) 1243 (1+ (line-end-position))
1230 (save-excursion 1244 'invisible 'dired-hide-details-information)
1231 (dired-move-to-end-of-filename) 1245 (put-text-property (+ (line-beginning-position) 1) (1- (point))
1232 (point)) 1246 'invisible 'dired-hide-details-detail)
1233 '(mouse-face highlight 1247 (add-text-properties
1234 dired-filename t 1248 (point)
1235 help-echo "mouse-2: visit this file in other window"))) 1249 (progn
1250 (dired-move-to-end-of-filename)
1251 (point))
1252 '(mouse-face
1253 highlight
1254 dired-filename t
1255 help-echo "mouse-2: visit this file in other window"))
1256 (when (< (+ (point) 4) (line-end-position))
1257 (put-text-property (+ (point) 4) (line-end-position)
1258 'invisible 'dired-hide-details-link)))
1236 (error nil)) 1259 (error nil))
1237 (forward-line 1)))) 1260 (forward-line 1))))
1238 1261
@@ -1496,6 +1519,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
1496 ;; hiding 1519 ;; hiding
1497 (define-key map "$" 'dired-hide-subdir) 1520 (define-key map "$" 'dired-hide-subdir)
1498 (define-key map "\M-$" 'dired-hide-all) 1521 (define-key map "\M-$" 'dired-hide-all)
1522 (define-key map "(" 'dired-hide-details-mode)
1499 ;; isearch 1523 ;; isearch
1500 (define-key map (kbd "M-s a C-s") 'dired-do-isearch) 1524 (define-key map (kbd "M-s a C-s") 'dired-do-isearch)
1501 (define-key map (kbd "M-s a M-C-s") 'dired-do-isearch-regexp) 1525 (define-key map (kbd "M-s a M-C-s") 'dired-do-isearch-regexp)
@@ -1586,6 +1610,10 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
1586 '(menu-item "Toggle Image Thumbnails in This Buffer" image-dired-dired-toggle-marked-thumbs 1610 '(menu-item "Toggle Image Thumbnails in This Buffer" image-dired-dired-toggle-marked-thumbs
1587 :help "Add or remove image thumbnails in front of marked file names")) 1611 :help "Add or remove image thumbnails in front of marked file names"))
1588 1612
1613 (define-key map [menu-bar immediate hide-details]
1614 '(menu-item "Hide Details" dired-hide-details-mode
1615 :help "Hide details in buffer"
1616 :button (:toggle . dired-hide-details-mode)))
1589 (define-key map [menu-bar immediate revert-buffer] 1617 (define-key map [menu-bar immediate revert-buffer]
1590 '(menu-item "Refresh" revert-buffer 1618 '(menu-item "Refresh" revert-buffer
1591 :help "Update contents of shown directories")) 1619 :help "Update contents of shown directories"))
@@ -1914,6 +1942,9 @@ Keybindings:
1914 selective-display t ; for subdirectory hiding 1942 selective-display t ; for subdirectory hiding
1915 mode-line-buffer-identification 1943 mode-line-buffer-identification
1916 (propertized-buffer-identification "%17b")) 1944 (propertized-buffer-identification "%17b"))
1945 ;; Ignore dired-hide-details-* value of invisible text property by default.
1946 (when (eq buffer-invisibility-spec t)
1947 (setq buffer-invisibility-spec (list t)))
1917 (set (make-local-variable 'revert-buffer-function) 1948 (set (make-local-variable 'revert-buffer-function)
1918 (function dired-revert)) 1949 (function dired-revert))
1919 (set (make-local-variable 'buffer-stale-function) 1950 (set (make-local-variable 'buffer-stale-function)
@@ -1978,15 +2009,20 @@ Otherwise, call `toggle-read-only'."
1978 "Move down lines then position at filename. 2009 "Move down lines then position at filename.
1979Optional prefix ARG says how many lines to move; default is one line." 2010Optional prefix ARG says how many lines to move; default is one line."
1980 (interactive "p") 2011 (interactive "p")
1981 (forward-line arg) 2012 (let ((line-move-visual)
2013 (goal-column))
2014 (line-move arg t))
2015 ;; We never want to move point into an invisible line.
2016 (while (and (invisible-p (point))
2017 (not (if (and arg (< arg 0)) (bobp) (eobp))))
2018 (forward-char (if (and arg (< arg 0)) -1 1)))
1982 (dired-move-to-filename)) 2019 (dired-move-to-filename))
1983 2020
1984(defun dired-previous-line (arg) 2021(defun dired-previous-line (arg)
1985 "Move up lines then position at filename. 2022 "Move up lines then position at filename.
1986Optional prefix ARG says how many lines to move; default is one line." 2023Optional prefix ARG says how many lines to move; default is one line."
1987 (interactive "p") 2024 (interactive "p")
1988 (forward-line (- arg)) 2025 (dired-next-line (- (or arg 1))))
1989 (dired-move-to-filename))
1990 2026
1991(defun dired-next-dirline (arg &optional opoint) 2027(defun dired-next-dirline (arg &optional opoint)
1992 "Goto ARG'th next directory file line." 2028 "Goto ARG'th next directory file line."
@@ -2230,6 +2266,40 @@ unchanged."
2230 (substring file (match-end 0)) 2266 (substring file (match-end 0))
2231 file)) 2267 file))
2232 2268
2269;;; Minor mode for hiding details
2270;;;###autoload
2271(define-minor-mode dired-hide-details-mode
2272 "Hide details in `dired-mode'."
2273 :group 'dired
2274 (unless (derived-mode-p 'dired-mode)
2275 (error "Not a Dired buffer"))
2276 (dired-hide-details-update-invisibility-spec)
2277 (if dired-hide-details-mode
2278 (add-hook 'wdired-mode-hook
2279 'dired-hide-details-update-invisibility-spec
2280 nil
2281 t)
2282 (remove-hook 'wdired-mode-hook
2283 'dired-hide-details-update-invisibility-spec
2284 t)))
2285
2286(defun dired-hide-details-update-invisibility-spec ()
2287 (funcall (if dired-hide-details-mode
2288 'add-to-invisibility-spec
2289 'remove-from-invisibility-spec)
2290 'dired-hide-details-detail)
2291 (funcall (if (and dired-hide-details-mode
2292 dired-hide-details-hide-information-lines)
2293 'add-to-invisibility-spec
2294 'remove-from-invisibility-spec)
2295 'dired-hide-details-information)
2296 (funcall (if (and dired-hide-details-mode
2297 dired-hide-details-hide-symlink-targets
2298 (not (derived-mode-p 'wdired-mode)))
2299 'add-to-invisibility-spec
2300 'remove-from-invisibility-spec)
2301 'dired-hide-details-link))
2302
2233;;; Functions for finding the file name in a dired buffer line. 2303;;; Functions for finding the file name in a dired buffer line.
2234 2304
2235(defvar dired-permission-flags-regexp 2305(defvar dired-permission-flags-regexp
diff --git a/lisp/find-dired.el b/lisp/find-dired.el
index ae7cc1c8629..f9a0c015bf7 100644
--- a/lisp/find-dired.el
+++ b/lisp/find-dired.el
@@ -210,13 +210,15 @@ use in place of \"-ls\" as the final argument."
210 (insert " " dir ":\n") 210 (insert " " dir ":\n")
211 ;; Make second line a ``find'' line in analogy to the ``total'' or 211 ;; Make second line a ``find'' line in analogy to the ``total'' or
212 ;; ``wildcard'' line. 212 ;; ``wildcard'' line.
213 (insert " " args "\n") 213 (let ((point (point)))
214 (insert " " args "\n")
215 (dired-insert-set-properties point (point)))
214 (setq buffer-read-only t) 216 (setq buffer-read-only t)
215 (let ((proc (get-buffer-process (current-buffer)))) 217 (let ((proc (get-buffer-process (current-buffer))))
216 (set-process-filter proc (function find-dired-filter)) 218 (set-process-filter proc (function find-dired-filter))
217 (set-process-sentinel proc (function find-dired-sentinel)) 219 (set-process-sentinel proc (function find-dired-sentinel))
218 ;; Initialize the process marker; it is used by the filter. 220 ;; Initialize the process marker; it is used by the filter.
219 (move-marker (process-mark proc) 1 (current-buffer))) 221 (move-marker (process-mark proc) (point) (current-buffer)))
220 (setq mode-line-process '(":%s")))) 222 (setq mode-line-process '(":%s"))))
221 223
222(defun kill-find () 224(defun kill-find ()
@@ -337,10 +339,11 @@ use in place of \"-ls\" as the final argument."
337 (let ((buffer-read-only nil)) 339 (let ((buffer-read-only nil))
338 (save-excursion 340 (save-excursion
339 (goto-char (point-max)) 341 (goto-char (point-max))
340 (insert "\n find " state) 342 (let ((point (point)))
341 (forward-char -1) ;Back up before \n at end of STATE. 343 (insert "\n find " state)
342 (insert " at " (substring (current-time-string) 0 19)) 344 (forward-char -1) ;Back up before \n at end of STATE.
343 (forward-char 1) 345 (insert " at " (substring (current-time-string) 0 19))
346 (dired-insert-set-properties point (point)))
344 (setq mode-line-process 347 (setq mode-line-process
345 (concat ":" 348 (concat ":"
346 (symbol-name (process-status proc)))) 349 (symbol-name (process-status proc))))
diff --git a/lisp/locate.el b/lisp/locate.el
index 804260969ee..ab0417070e7 100644
--- a/lisp/locate.el
+++ b/lisp/locate.el
@@ -496,6 +496,7 @@ do not work in subdirectories.
496 (setq revert-buffer-function 'locate-update) 496 (setq revert-buffer-function 'locate-update)
497 (set (make-local-variable 'page-delimiter) "\n\n") 497 (set (make-local-variable 'page-delimiter) "\n\n")
498 (run-mode-hooks 'locate-mode-hook)) 498 (run-mode-hooks 'locate-mode-hook))
499(put 'locate-mode 'derived-mode-parent 'dired-mode)
499 500
500(defun locate-do-setup (search-string) 501(defun locate-do-setup (search-string)
501 (goto-char (point-min)) 502 (goto-char (point-min))