From eef2f8bea926b5693acc7807735aab24d78aa6a5 Mon Sep 17 00:00:00 2001 From: contrapunctus Date: Tue, 14 Jan 2020 11:27:52 +0530 Subject: [PATCH] Fix error when point is on a directory The changes to fn-at-point-index weren't strictly necessary - the error was already fixed with the change to fn-at-point - but I thought it best to play it safe. --- sxiv.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sxiv.el b/sxiv.el index 49f397b..3b979ca 100644 --- a/sxiv.el +++ b/sxiv.el @@ -77,7 +77,9 @@ If run from a text file containing one file name per line, open the files listed." (interactive "P") (let* ((path-at-point (dired-file-name-at-point)) - (fn-at-point (when path-at-point + (fn-at-point (when (and path-at-point + ;; REVIEW - also check if file is an image? + (file-regular-p path-at-point)) (file-relative-name path-at-point))) (paths (cond ((sxiv-dired-marked-files-p) (dired-get-marked-files)) @@ -103,10 +105,11 @@ the files listed." paths (seq-remove #'file-directory-p paths))) (fn-at-point-index (when fn-at-point - (->> paths - (--find-index (equal fn-at-point it)) - (1+) - (number-to-string)))) + (--find-index (equal fn-at-point it) + paths))) + (fn-at-point-index (when fn-at-point-index + (-> (1+ fn-at-point-index) + (number-to-string)))) (recurse (if recurse "-r" "")) (proc (make-process :name "sxiv" :buffer "sxiv"