diff --git a/CHANGELOG.md b/CHANGELOG.md index 008a8d6..6bbd031 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 +### Fixed +* Error with selected files in a subdirectory (issue #1) + ## [0.3.2] - 2020-05-08 ### Fixed * Workaround for crash in certain cases diff --git a/sxiv.el b/sxiv.el index 2b9643a..bedacc7 100644 --- a/sxiv.el +++ b/sxiv.el @@ -56,13 +56,17 @@ With no marked files, or if not in a Dired buffer, return 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 (and (file-exists-p (file-name-nondirectory path)) - (file-directory-p path)) - (dired-insert-subdir (file-name-directory path)))) - paths) - paths) + (cl-loop for path in paths + ;; If the file does not exist in the current directory... + unless (and (file-exists-p (file-name-nondirectory path)) + ;; ;; ...I don't understand why this is here! + ;; ;; Why would there be a directory in the selected + ;; ;; files, seeing as one can't mark directories in + ;; ;; sxiv? + ;; (file-directory-p path) + ) + do (dired-insert-subdir (file-name-directory path)) + finally return paths)) (defun sxiv-dired-mark-files (files) "Mark FILES in the current (dired) buffer."