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.
This commit is contained in:
contrapunctus 2020-01-14 11:27:52 +05:30
parent 2c8d631189
commit eef2f8bea9
1 changed files with 8 additions and 5 deletions

13
sxiv.el
View File

@ -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"