sxiv.el-v0.3.3/0000755000175000017500000000000013712017674013135 5ustar dogslegdogslegsxiv.el-v0.3.3/WTFPL0000644000175000017500000000073713712017674013763 0ustar dogslegdogsleg DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO. sxiv.el-v0.3.3/TODO.md0000644000175000017500000000243113712017674014224 0ustar dogslegdogsleg# TODO 1. [x] Create user-customizable variable to hold default arguments 2. [x] Start sxiv on the file at point (using `-n ...`) 3. [x] Let user specify paths to be excluded. 4. [x] 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. * When files are marked in Dired - only display marked files, or ignore marks and run as usual * When files are marked in Dired and we mark files in sxiv - replace the selection, or unmark the files marked this time * Other options like running recursively, modifying arguments, etc 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. [ ] sxiv-exclude-strings does not work recursively, because only the directories are passed to the process. Adding all files to the path might cause it to fail (bash length limit), or take a long time. 8. [ ] Make it work in find-dired buffers too 9. [ ] Bug - sometimes, if a lot of files (e.g. >50) are marked in sxiv, the input received by `sxiv-insert-subdirs` is incomplete (i.e. the first file name is a trailing segment of an actual existing filename). sxiv.el-v0.3.3/CHANGELOG.md0000644000175000017500000000150713712017674014751 0ustar dogslegdogsleg# Changelog 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/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.3.3] - 2020-08-03 ### Fixed * Error with selected files in a subdirectory (issue #1) ## [0.3.2] - 2020-05-08 ### Fixed * Workaround for crash in certain cases ## [0.3.1] - 2020-03-25 ### Added * Marking files now works recursively, too. * Show message when starting sxiv ## [0.3.0] - 2020-01-14 ### Added * Open sxiv at the image at point ## [0.2.0] - 2020-01-13 ### Added * `sxiv-arguments` to hold argument list * `sxiv-exclude-strings` to exclude files by matching paths ### Fixed * Slow startup/freezing on large directories * `package-lint` fixes ## [0.1.0] - 2020-01-12 sxiv.el-v0.3.3/UNLICENSE0000644000175000017500000000227313712017674014411 0ustar dogslegdogslegThis is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to sxiv.el-v0.3.3/Cask0000644000175000017500000000017213712017674013741 0ustar dogslegdogsleg(source gnu) (source melpa) (package "sxiv.el" "0.3.3" "Run the Simple X Image Viewer") (depends-on "dash" "2.16.0") sxiv.el-v0.3.3/README.md0000644000175000017500000000430413712017674014415 0ustar dogslegdogsleg# sxiv.el Launch [sxiv](https://github.com/muennich/sxiv) (Simple X Image Viewer) from Emacs, with Dired integration. ## Installation You can get `sxiv.el` from `sxiv.el` requires [dash.el](https://github.com/magnars/dash.el) and an installed [sxiv](https://github.com/muennich/sxiv) in your $PATH ## Usage The main command is `M-x sxiv`. Run it in a Dired buffer containing images. Files marked in sxiv (mark/unmark with `m`) will be marked in Dired. If the Dired buffer has marked files, open only those files. With prefix argument, or when only provided directories, run recursively. Run it from a text file containing one file name per line to open the listed files. ## Limitations * `sxiv-dired-marked-files-p` doesn't work as intended with non '*' markers (e.g. C or D) ## Comparison with [picpocket](https://github.com/johanclaesson/picpocket) At a cursory glance, picpocket (v20180914) * ✔️ does not depend on an external program * ✔️ has better key customizability (to change the keys for sxiv itself, you need to modify its C source) * ✔️ supports tagging images * ✖️ has no way to mark files for batch operations * ✖️ does not seem to center images in fullscreen mode ## Contributions and contact Feedback and MRs very welcome. 🙂 You may be interested in the [TODO.md](TODO.md) Contact the creator and other Emacs users in the Emacs room on the Jabber network - [xmpp:emacs@salas.suchat.org?join](xmpp:emacs@salas.suchat.org?join) ([web chat](https://inverse.chat/#converse/room?jid=emacs@salas.suchat.org)) (For help in getting started with Jabber, [click here](https://xmpp.org/getting-started/)) ## License I dream of a world where all software is liberated - transparent, trustable, and accessible for anyone to use or improve. But I don't want to make demands or threats (e.g. via legal conditions) to get there. I'd rather make a request - please do everything you can to help that dream come true. Please Unlicense as much software as you can. sxiv.el is released under your choice of [Unlicense](https://unlicense.org/) or the [WTFPL](http://www.wtfpl.net/). (See files [UNLICENSE](UNLICENSE) and [WTFPL](WTFPL)). ## Thanks wasamasa, bpalmer and #emacs for all their help and support sxiv.el-v0.3.3/sxiv.el0000644000175000017500000001355713712017674014463 0ustar dogslegdogsleg;;; sxiv.el --- Run the sxiv image viewer -*- lexical-binding: t; -*- ;; Author: contrapunctus ;; Maintainer: contrapunctus ;; Keywords: multimedia ;; Homepage: https://gitlab.com/contrapunctus/sxiv.el ;; Package-Requires: ((dash "2.16.0") (emacs "25.1")) ;; Version: 0.3.3 ;; This is free and unencumbered software released into the public domain. ;; ;; Anyone is free to copy, modify, publish, use, compile, sell, or ;; distribute this software, either in source code form or as a compiled ;; binary, for any purpose, commercial or non-commercial, and by any ;; means. ;; ;; For more information, please refer to ;;; Commentary: ;; The sole command and primary entry point is `sxiv'. ;; ;; `sxiv-filter' is the process filter, to insert subdirectories (via ;; `sxiv-insert-subdirs') and mark files marked in sxiv (via ;; `sxiv-dired-mark-files'). (require 'dired) (require 'dash) ;;; Code: (defgroup sxiv nil "Run the Simple X Image Viewer." :group 'multimedia) (defcustom sxiv-arguments '("-a" "-f" "-o") "Arguments to be passed to the sxiv process. It must contain \"-o\" for marking in Dired buffers to function." :type '(repeat string)) (defcustom sxiv-exclude-strings '() "Exclude files whose paths match these strings." :type '(repeat string)) (defvar sxiv--directory nil "Directory `sxiv' was called from. Used by `sxiv-filter' to know where to mark files.") (defun sxiv-dired-marked-files-p () "Return t if there are marked files in the current Dired buffer. With no marked files, or if not in a Dired buffer, return nil." (and (derived-mode-p 'dired-mode) (save-excursion (goto-char (point-min)) (re-search-forward dired-re-mark nil t)))) (defun sxiv-insert-subdirs (paths) "Insert subdirectories from PATHS into the current Dired buffer. Return PATHS unchanged." (cl-loop for path in paths ;; If the file does not exist in the current directory... unless (and (file-exists-p (file-name-nondirectory path)) ;; ;; ...I don't understand why this is here! ;; ;; Why would there be a directory in the selected ;; ;; files, seeing as one can't mark directories in ;; ;; sxiv? ;; (file-directory-p path) ) do (dired-insert-subdir (file-name-directory path)) finally return paths)) (defun sxiv-dired-mark-files (files) "Mark FILES in the current (dired) buffer." (dired-mark-if (and (not (looking-at-p dired-re-dot)) (not (eolp)) (let ((fn (dired-get-filename t t))) (and fn (--find (equal fn it) files)))) "file")) (defun sxiv-filter (_process output) "Open a `dired' buffer and mark any files marked by the user in `sxiv'. Used as process filter for `sxiv'. OUTPUT is the output of the sxiv process as a string." (find-file sxiv--directory) (--> (split-string output "\n") (-drop-last 1 it) (sxiv-insert-subdirs it) (sxiv-dired-mark-files it))) (defun sxiv (&optional prefix) "Run sxiv(1), the Simple X Image Viewer. By default, when run in a Dired buffer, open all files in the current directory. Files marked in sxiv will be marked in Dired. If run from a Dired buffer with marked files, open only those files. With prefix argument PREFIX, or when only provided directories, run recursively (-r). 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 (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)) ((derived-mode-p 'text-mode) (--> (buffer-substring-no-properties (point-min) (point-max)) (split-string it "\n"))) (t (directory-files default-directory)))) (paths (--remove (or (equal it ".") (equal it "..") ;; 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 (or prefix (-every? #'file-directory-p paths))) ;; remove directories if not running recursively (paths (if recurse paths (seq-remove #'file-directory-p paths))) (fn-at-point-index (when fn-at-point (--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" ""))) (setq sxiv--directory default-directory) (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: ;; nameless-current-name: "sxiv" ;; End: (provide 'sxiv) ;;; sxiv.el ends here