From f1a030c538af6d47d32eef04ab6536eeef948268 Mon Sep 17 00:00:00 2001 From: contrapunctus Date: Fri, 8 May 2020 21:50:39 +0530 Subject: [PATCH] Prevent crashes in certain situations (todo #9) --- CHANGELOG.md | 4 ++++ README.md | 12 ++---------- TODO.md | 13 +++++++++++++ sxiv.el | 3 ++- 4 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 TODO.md diff --git a/CHANGELOG.md b/CHANGELOG.md index d558fe5..008a8d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [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. diff --git a/README.md b/README.md index d41e323..a4c7e8f 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,6 @@ 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. -## 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 -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? -8. [ ] 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, or take a long time. - ## Limitations * `sxiv-dired-marked-files-p` doesn't work as intended with non '*' markers (e.g. C or D) @@ -39,6 +29,8 @@ At a cursory glance, picpocket (v20180914) ## 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/)) diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..bade93f --- /dev/null +++ b/TODO.md @@ -0,0 +1,13 @@ +# 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). diff --git a/sxiv.el b/sxiv.el index 5c20659..a76433e 100644 --- a/sxiv.el +++ b/sxiv.el @@ -58,7 +58,8 @@ With no marked files, or if not in a Dired buffer, return nil." Return PATHS unchanged." (mapc (lambda (path) ;; is the file a direct child? (i.e. exists in the current directory?) - (unless (file-exists-p (file-name-nondirectory path)) + (unless (and (file-exists-p (file-name-nondirectory path)) + (file-directory-p path)) (dired-insert-subdir (file-name-directory path)))) paths) paths)