Compress code a little
This commit is contained in:
parent
a23d1639f8
commit
086bc5ae97
67
sxiv.el
67
sxiv.el
|
@ -103,51 +103,46 @@ the files listed."
|
||||||
;; REVIEW - also check if file is an image?
|
;; REVIEW - also check if file is an image?
|
||||||
(file-regular-p path-at-point))
|
(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))
|
||||||
((derived-mode-p 'text-mode)
|
((derived-mode-p 'text-mode)
|
||||||
(--> (buffer-substring-no-properties (point-min)
|
(--> (buffer-substring-no-properties (point-min) (point-max))
|
||||||
(point-max))
|
(split-string it "\n")))
|
||||||
(split-string it "\n")))
|
(t (directory-files default-directory))))
|
||||||
(t (directory-files default-directory))))
|
(paths (--remove (or (equal it ".")
|
||||||
(paths (--remove (or (equal it ".")
|
(equal it "..")
|
||||||
(equal it "..")
|
;; Currently, this takes effect even
|
||||||
;; Currently, this takes effect even
|
;; when running from a text
|
||||||
;; when running from a text
|
;; file...should that be the case?
|
||||||
;; file...should that be the case?
|
(-find (lambda (exclude)
|
||||||
(-find (lambda (exclude)
|
(string-match-p exclude it))
|
||||||
(string-match-p exclude it))
|
sxiv-exclude-strings))
|
||||||
sxiv-exclude-strings))
|
paths))
|
||||||
paths))
|
|
||||||
;; 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
|
(recurse (or prefix (-every? #'file-directory-p paths)))
|
||||||
(-every? #'file-directory-p paths)))
|
|
||||||
;; remove directories if not running recursively
|
;; remove directories if not running recursively
|
||||||
(paths (if recurse
|
(paths (if recurse paths (seq-remove #'file-directory-p paths)))
|
||||||
paths
|
|
||||||
(seq-remove #'file-directory-p paths)))
|
|
||||||
(fn-at-point-index (when fn-at-point
|
(fn-at-point-index (when fn-at-point
|
||||||
(--find-index (equal fn-at-point it)
|
(--find-index (equal fn-at-point it)
|
||||||
paths)))
|
paths)))
|
||||||
(fn-at-point-index (when fn-at-point-index
|
(fn-at-point-index (when fn-at-point-index
|
||||||
(-> (1+ fn-at-point-index)
|
(-> (1+ fn-at-point-index)
|
||||||
(number-to-string))))
|
(number-to-string))))
|
||||||
(recurse (if recurse "-r" ""))
|
(recurse (if recurse "-r" "")))
|
||||||
(proc (progn
|
|
||||||
(message "Running sxiv...")
|
|
||||||
(make-process :name "sxiv"
|
|
||||||
:buffer "sxiv"
|
|
||||||
:command
|
|
||||||
(append '("sxiv")
|
|
||||||
sxiv-arguments
|
|
||||||
(when fn-at-point-index
|
|
||||||
(list "-n" fn-at-point-index))
|
|
||||||
(list recurse "--")
|
|
||||||
paths)
|
|
||||||
:connection-type 'pipe
|
|
||||||
:stderr "sxiv-errors"))))
|
|
||||||
(setq sxiv--directory default-directory)
|
(setq sxiv--directory default-directory)
|
||||||
(set-process-filter proc #'sxiv-filter)))
|
(message "Running sxiv...")
|
||||||
|
(make-process :name "sxiv"
|
||||||
|
:buffer "sxiv"
|
||||||
|
:command
|
||||||
|
(append '("sxiv")
|
||||||
|
sxiv-arguments
|
||||||
|
(when fn-at-point-index
|
||||||
|
(list "-n" fn-at-point-index))
|
||||||
|
(list recurse "--")
|
||||||
|
paths)
|
||||||
|
:connection-type 'pipe
|
||||||
|
:filter #'sxiv-filter
|
||||||
|
:stderr "sxiv-errors")))
|
||||||
|
|
||||||
;; Local Variables:
|
;; Local Variables:
|
||||||
;; nameless-current-name: "sxiv"
|
;; nameless-current-name: "sxiv"
|
||||||
|
|
Reference in New Issue