diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-02-16 11:25:45 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-02-16 11:32:28 +0000 |
commit | b54e149999a8bf17c966a8735d044e6c7d47d32a (patch) | |
tree | 22740b4740017cc2b9c72d639c128f39b18e3457 /Emacs/.config/emacs | |
parent | 8262e1dc4e7188bc61bbb596ddff37ffcc060f39 (diff) | |
download | dotfiles-b54e149999a8bf17c966a8735d044e6c7d47d32a.tar.gz dotfiles-b54e149999a8bf17c966a8735d044e6c7d47d32a.tar.bz2 dotfiles-b54e149999a8bf17c966a8735d044e6c7d47d32a.zip |
Rework +dired/insert-all-subdirectories
If argument is provided (C-u), +dired/insert-all-subdirectories
recursively inserts subdirectories until there are no subdirectories
left. Otherwise, perform the same behaviour as before i.e. only
insert subdirectories currently present in the buffer.
This allows dired to have a "treelike" view without having to use an
external library.
Diffstat (limited to 'Emacs/.config/emacs')
-rw-r--r-- | Emacs/.config/emacs/config.org | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org index 1ada090..117c91c 100644 --- a/Emacs/.config/emacs/config.org +++ b/Emacs/.config/emacs/config.org @@ -3236,12 +3236,27 @@ Here I setup dired with a few niceties '("\\.webm\\'" "mpv") '("\\.mp[34]\\'" "mpv") '("\\.mkv\\'" "mpv")) - (defun +dired/insert-all-subdirectories () - "Insert all subdirectories currently viewable." - (interactive) + + (defun +dired/--subdirs-not-inserted () + (dired-unmark-all-marks) (dired-mark-directories nil) - (mapc #'dired-insert-subdir (dired-get-marked-files)) - (dired-unmark-all-marks))) + (let* ((subdirs-present (mapcar #'car dired-subdir-alist)) + (subdirs-left (thread-last + (dired-get-marked-files) + (mapcar #'(lambda (x) (concat x "/"))) + (cl-remove-if #'(lambda (f) (member f subdirs-present)))))) + (dired-unmark-all-marks) + subdirs-left)) + + (defun +dired/insert-all-subdirectories (&optional arg) + "Insert all subdirectories recursively." + (interactive "P") + (let ((subdirs-left (+dired/--subdirs-not-inserted))) + (if (null arg) + (mapc #'dired-insert-subdir subdirs-left) + (while subdirs-left + (mapc #'dired-insert-subdir subdirs-left) + (setq subdirs-left (+dired/--subdirs-not-inserted))))))) #+end_src *** image-dired Image dired is a little cherry on top for Dired: the ability to look |