Skip to content

Commit dab22a3

Browse files
committed
feat(collapse): add global-dired-collapse-mode
1 parent fa5bd09 commit dab22a3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ collapsed directory they are immediately brought to the deepest
616616
directory with some actual content.
617617

618618
To enable or disable this functionality use `dired-collapse-mode` to
619-
toggle it for the current dired buffer.
619+
toggle it for the current dired buffer. To enable the mode globally
620+
in all dired buffers, use `global-dired-collapse-mode`.
620621

621622
If the deepest directory contains only a single file this file is
622623
displayed instead of the last directory. This way we can get

dired-collapse.el

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
;; directory with some actual content.
4343

4444
;; To enable or disable this functionality use `dired-collapse-mode'
45-
;; to toggle it for the current dired buffer.
45+
;; to toggle it for the current dired buffer. To enable the mode
46+
;; globally in all dired buffers, use `global-dired-collapse-mode'.
4647

4748
;; If the deepest directory contains only a single file this file is
4849
;; displayed instead of the last directory. This way we can get
@@ -107,6 +108,15 @@
107108
(remove-hook 'dired-omit-mode-hook 'dired-collapse 'local)
108109
(revert-buffer)))
109110

111+
(defun turn-on-dired-collapse-mode ()
112+
(when (derived-mode-p 'dired-mode)
113+
(dired-collapse-mode)))
114+
115+
(define-globalized-minor-mode global-dired-collapse-mode
116+
dired-collapse-mode
117+
turn-on-dired-collapse-mode
118+
:group 'dired-collapse)
119+
110120
(defun dired-collapse--replace-file (file)
111121
"Replace file on the current line with FILE."
112122
(delete-region (line-beginning-position) (1+ (line-end-position)))

0 commit comments

Comments
 (0)