Rewrite sxiv-insert-subdirs using loop; try to fix error (issue #1)

This commit is contained in:
contrapunctus 2020-08-03 19:58:38 +05:30
parent 086bc5ae97
commit 247cb7bdcb
2 changed files with 15 additions and 7 deletions

View File

@ -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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Fixed
* Error with selected files in a subdirectory (issue #1)
## [0.3.2] - 2020-05-08 ## [0.3.2] - 2020-05-08
### Fixed ### Fixed
* Workaround for crash in certain cases * Workaround for crash in certain cases

18
sxiv.el
View File

@ -56,13 +56,17 @@ With no marked files, or if not in a Dired buffer, return nil."
(defun sxiv-insert-subdirs (paths) (defun sxiv-insert-subdirs (paths)
"Insert subdirectories from PATHS into the current Dired buffer. "Insert subdirectories from PATHS into the current Dired buffer.
Return PATHS unchanged." Return PATHS unchanged."
(mapc (lambda (path) (cl-loop for path in paths
;; is the file a direct child? (i.e. exists in the current directory?) ;; If the file does not exist in the current directory...
(unless (and (file-exists-p (file-name-nondirectory path)) unless (and (file-exists-p (file-name-nondirectory path))
(file-directory-p path)) ;; ;; ...I don't understand why this is here!
(dired-insert-subdir (file-name-directory path)))) ;; ;; Why would there be a directory in the selected
paths) ;; ;; files, seeing as one can't mark directories in
paths) ;; ;; sxiv?
;; (file-directory-p path)
)
do (dired-insert-subdir (file-name-directory path))
finally return paths))
(defun sxiv-dired-mark-files (files) (defun sxiv-dired-mark-files (files)
"Mark FILES in the current (dired) buffer." "Mark FILES in the current (dired) buffer."