Try to match the order of files as displayed in the Dired buffer
This commit is contained in:
parent
14057b156d
commit
9ff8f6d8e9
26
sxiv.el
26
sxiv.el
|
@ -103,13 +103,20 @@ OUTPUT is the output of the sxiv process as a string."
|
||||||
(run-hook-with-args 'sxiv-after-exit-functions process output))
|
(run-hook-with-args 'sxiv-after-exit-functions process output))
|
||||||
|
|
||||||
(defun sxiv-paths-raw ()
|
(defun sxiv-paths-raw ()
|
||||||
(cond ((sxiv-dired-marked-files-p)
|
"Return a list of strings containing absolute paths to files."
|
||||||
(dired-get-marked-files))
|
(cond ((derived-mode-p 'dired-mode)
|
||||||
|
(if (sxiv-dired-marked-files-p)
|
||||||
|
(dired-get-marked-files)
|
||||||
|
(let (list)
|
||||||
|
(dired-map-dired-file-lines
|
||||||
|
(lambda (name)
|
||||||
|
(setq list (cons name list))))
|
||||||
|
(reverse list))))
|
||||||
((derived-mode-p 'text-mode)
|
((derived-mode-p 'text-mode)
|
||||||
(split-string
|
(split-string
|
||||||
(buffer-substring-no-properties (point-min) (point-max))
|
(buffer-substring-no-properties (point-min) (point-max))
|
||||||
"\n"))
|
"\n"))
|
||||||
(t (directory-files default-directory))))
|
(t (user-error "sxiv: this is not a dired or text buffer"))))
|
||||||
|
|
||||||
(defun sxiv-file-at-point-index (&optional paths)
|
(defun sxiv-file-at-point-index (&optional paths)
|
||||||
"Return index of file at point.
|
"Return index of file at point.
|
||||||
|
@ -129,10 +136,10 @@ required for `dired-mode' buffers."
|
||||||
|
|
||||||
(defun sxiv (&optional prefix)
|
(defun sxiv (&optional prefix)
|
||||||
"Run sxiv(1), the Simple X Image Viewer.
|
"Run sxiv(1), the Simple X Image Viewer.
|
||||||
By default, when run in a Dired buffer, open all files in the
|
When run in a Dired buffer, open all files in the current
|
||||||
current directory. Files marked in sxiv will be marked in Dired.
|
directory. Files marked in sxiv will be marked in Dired.
|
||||||
|
|
||||||
If run from a Dired buffer with marked files, open only those
|
When run from a Dired buffer with marked files, open only those
|
||||||
files.
|
files.
|
||||||
|
|
||||||
With prefix argument PREFIX, or when only provided directories,
|
With prefix argument PREFIX, or when only provided directories,
|
||||||
|
@ -150,9 +157,12 @@ the files listed."
|
||||||
sxiv-exclude-strings))
|
sxiv-exclude-strings))
|
||||||
(sxiv-paths-raw)))
|
(sxiv-paths-raw)))
|
||||||
;; recurse with prefix arg, or if every path is a directory
|
;; recurse with prefix arg, or if every path is a directory
|
||||||
(recurse (or prefix (-every? #'file-directory-p paths)))
|
(recurse (or prefix
|
||||||
|
(-every? #'file-directory-p paths)))
|
||||||
;; remove directories if not running recursively
|
;; remove directories if not running recursively
|
||||||
(paths (if recurse paths (seq-remove #'file-directory-p paths)))
|
(paths (if recurse
|
||||||
|
paths
|
||||||
|
(seq-remove #'file-directory-p paths)))
|
||||||
(index (sxiv-file-at-point-index paths))
|
(index (sxiv-file-at-point-index paths))
|
||||||
(index (when index (number-to-string index)))
|
(index (when index (number-to-string index)))
|
||||||
(recurse (if recurse "-r" "")))
|
(recurse (if recurse "-r" "")))
|
||||||
|
|
Reference in New Issue