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:
parent
2c8d631189
commit
eef2f8bea9
13
sxiv.el
13
sxiv.el
|
@ -77,7 +77,9 @@ If run from a text file containing one file name per line, open
|
||||||
the files listed."
|
the files listed."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let* ((path-at-point (dired-file-name-at-point))
|
(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)))
|
(file-relative-name path-at-point)))
|
||||||
(paths (cond ((sxiv-dired-marked-files-p)
|
(paths (cond ((sxiv-dired-marked-files-p)
|
||||||
(dired-get-marked-files))
|
(dired-get-marked-files))
|
||||||
|
@ -103,10 +105,11 @@ the files listed."
|
||||||
paths
|
paths
|
||||||
(seq-remove #'file-directory-p paths)))
|
(seq-remove #'file-directory-p paths)))
|
||||||
(fn-at-point-index (when fn-at-point
|
(fn-at-point-index (when fn-at-point
|
||||||
(->> paths
|
(--find-index (equal fn-at-point it)
|
||||||
(--find-index (equal fn-at-point it))
|
paths)))
|
||||||
(1+)
|
(fn-at-point-index (when fn-at-point-index
|
||||||
(number-to-string))))
|
(-> (1+ fn-at-point-index)
|
||||||
|
(number-to-string))))
|
||||||
(recurse (if recurse "-r" ""))
|
(recurse (if recurse "-r" ""))
|
||||||
(proc (make-process :name "sxiv"
|
(proc (make-process :name "sxiv"
|
||||||
:buffer "sxiv"
|
:buffer "sxiv"
|
||||||
|
|
Reference in New Issue