Start at the image at point
This commit is contained in:
parent
cddff79c47
commit
8802975498
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
### Added
|
||||||
|
* Open sxiv at the image at point
|
||||||
|
|
||||||
## [0.2.0] - 2020-01-13
|
## [0.2.0] - 2020-01-13
|
||||||
### Added
|
### Added
|
||||||
* `sxiv-arguments` to hold argument list
|
* `sxiv-arguments` to hold argument list
|
||||||
|
|
|
@ -17,11 +17,11 @@ Run it from a text file containing one file name per line to open the listed fil
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
1. [x] Create user-customizable variable to hold default arguments
|
1. [x] Create user-customizable variable to hold default arguments
|
||||||
2. Start sxiv on the file at point (using `-n ...`)
|
2. [x] Start sxiv on the file at point (using `-n ...`)
|
||||||
3. [x] Let user specify paths to be excluded.
|
3. [x] Let user specify paths to be excluded.
|
||||||
4. Mark files in subdirectories if run recursively (by inserting the subdirectory into the current buffer)
|
4. [ ] Mark files in subdirectories if run recursively (by inserting the subdirectory into the current buffer)
|
||||||
5. Let user edit options (ideally with transient.el) when called with null argument/two prefix arguments
|
5. [ ] Let user edit options (ideally with transient.el) when called with null argument/two prefix arguments
|
||||||
6. When running with a lot of files, sxiv may take some time to start. Signal to the user that it is starting, and let them kill it if they want.
|
6. [ ] When running with a lot of files, sxiv may take some time to start. Signal to the user that it is starting, and let them kill it if they want.
|
||||||
7. What should be the behavior when we open Dired-marked files, then mark files within sxiv?
|
7. What should be the behavior when we open Dired-marked files, then mark files within sxiv?
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
69
sxiv.el
69
sxiv.el
|
@ -76,36 +76,49 @@ run recursively (-r).
|
||||||
If run from a text file containing one file name per line, open
|
If run from a text file containing one file name per line, open
|
||||||
the files listed."
|
the files listed."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let* ((paths (cond ((sxiv-dired-marked-files-p)
|
(let* ((path-at-point (dired-file-name-at-point))
|
||||||
(dired-get-marked-files))
|
(fn-at-point (when path-at-point
|
||||||
((derived-mode-p 'text-mode)
|
(file-relative-name path-at-point)))
|
||||||
(--> (buffer-substring-no-properties (point-min)
|
(paths (cond ((sxiv-dired-marked-files-p)
|
||||||
(point-max))
|
(dired-get-marked-files))
|
||||||
(split-string it "\n")))
|
((derived-mode-p 'text-mode)
|
||||||
(t (directory-files default-directory))))
|
(--> (buffer-substring-no-properties (point-min)
|
||||||
(paths (--remove (or (equal it ".")
|
(point-max))
|
||||||
(equal it "..")
|
(split-string it "\n")))
|
||||||
(-find (lambda (exclude)
|
(t (directory-files default-directory))))
|
||||||
(string-match-p exclude it))
|
(paths (--remove (or (equal it ".")
|
||||||
sxiv-exclude-strings))
|
(equal it "..")
|
||||||
paths))
|
;; Currently, this takes effect even
|
||||||
|
;; when running from a text
|
||||||
|
;; file...should that be the case?
|
||||||
|
(-find (lambda (exclude)
|
||||||
|
(string-match-p exclude it))
|
||||||
|
sxiv-exclude-strings))
|
||||||
|
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
|
paths
|
||||||
(seq-remove #'file-directory-p paths)))
|
(seq-remove #'file-directory-p paths)))
|
||||||
(recurse (if recurse "-r" ""))
|
(fn-at-point-index (when fn-at-point
|
||||||
(proc (make-process :name "sxiv"
|
(->> paths
|
||||||
:buffer "sxiv"
|
(--find-index (equal fn-at-point it))
|
||||||
:command
|
(1+)
|
||||||
(append '("sxiv")
|
(number-to-string))))
|
||||||
sxiv-arguments
|
(recurse (if recurse "-r" ""))
|
||||||
`(,recurse "--")
|
(proc (make-process :name "sxiv"
|
||||||
paths)
|
:buffer "sxiv"
|
||||||
:connection-type 'pipe
|
:command
|
||||||
:stderr "sxiv-errors")))
|
(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)))
|
(set-process-filter proc #'sxiv-filter)))
|
||||||
|
|
||||||
|
|
Reference in New Issue