diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e3b716..e8d20d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Added +* Marking files now works recursively, too. + ## [0.3.0] - 2020-01-14 ### Added * Open sxiv at the image at point diff --git a/README.md b/README.md index a2fd22e..056ce22 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Run it from a text file containing one file name per line to open the listed fil 1. [x] Create user-customizable variable to hold default arguments 2. [x] Start sxiv on the file at point (using `-n ...`) 3. [x] Let user specify paths to be excluded. -4. [ ] Mark files in subdirectories if run recursively (by inserting the subdirectory into the current buffer) +4. [x] Mark files in subdirectories if run recursively (by inserting the subdirectory into the current buffer) 5. [ ] Let user edit options (ideally with transient.el) when called with null argument/two prefix arguments 6. [ ] When running with a lot of files, sxiv may take some time to start. Signal to the user that it is starting, and let them kill it if they want. 7. What should be the behavior when we open Dired-marked files, then mark files within sxiv? diff --git a/sxiv.el b/sxiv.el index 3b979ca..e03ba61 100644 --- a/sxiv.el +++ b/sxiv.el @@ -42,15 +42,25 @@ With no marked files, or if not in a Dired buffer, return nil." nil) nil)) +(defun sxiv-insert-subdirs (paths) + "Insert subdirectories from PATHS into the current Dired buffer. +Return PATHS unchanged." + (mapc (lambda (path) + ;; is the file a direct child? (i.e. exists in the current directory?) + (unless (file-exists-p (file-name-nondirectory path)) + (dired-insert-subdir (file-name-directory path)))) + paths) + paths) + (defun sxiv-filter (_process output) "Open a `dired' buffer and mark any files marked by the user in `sxiv'. Used as process filter for `sxiv'. OUTPUT is the output of the sxiv process as a string." (find-file sxiv--directory) - (--> output - (split-string it "\n") + (--> (split-string output "\n") (-drop-last 1 it) + (sxiv-insert-subdirs it) (sxiv-dired-mark-files it))) (defun sxiv-dired-mark-files (files)