aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Hupfer <liam@hpfr.net>2022-04-28 16:05:13 +0200
committerVasilij Schneidermann <mail@vasilij.de>2022-04-28 16:07:00 +0200
commitfce7b0b0506231626887f131ca38e968e4c7f9e8 (patch)
tree995ac9e47e3d0bda1d7d75d1b8d152dbd7f6ff54
parent12faf16fbbaf09aadec26dfbda5809d886248c02 (diff)
Add support for arbitrary decompression tools
This allows users to use non-unzip decompression tools such as libarchive's `bsdtar`.
-rw-r--r--README.md16
-rw-r--r--nov.el18
2 files changed, 25 insertions, 9 deletions
diff --git a/README.md b/README.md
index 52f7eea..f643795 100644
--- a/README.md
+++ b/README.md
@@ -29,11 +29,17 @@ and install with `M-x package-install RET nov RET`.
## Setup
-Make sure you have an `unzip` executable on `PATH`, otherwise the
-extraction of EPUB files will fail. If you for some reason have
-`unzip` in a non-standard location, customize `nov-unzip-program` to
-its path. You'll also need an Emacs compiled with `libxml2` support,
-otherwise rendering will fail.
+By default, `nov.el` uses `unzip` on `PATH` to extract EPUB files. You
+can customize `nov-unzip-program` if it is located elsewhere. You can
+also customize `nov-unzip-args` if you use a different decompression
+tool like `bsdtar`. It must accept a target `directory` where nov
+unzips the EPUB `filename`.
+
+ (setq nov-unzip-program (executable-find "bsdtar")
+ nov-unzip-args '("-xC" directory "-f" filename))
+
+You'll also need an Emacs compiled with `libxml2` support, otherwise
+rendering will fail.
Put the following in your init file:
diff --git a/nov.el b/nov.el
index 73e8591..d53e5d0 100644
--- a/nov.el
+++ b/nov.el
@@ -69,10 +69,18 @@
:group 'multimedia)
(defcustom nov-unzip-program (executable-find "unzip")
- "Path to `unzip` executable."
+ "Path to decompression executable."
:type '(file :must-match t)
:group 'nov)
+(defcustom nov-unzip-args '("-o" directory filename)
+ "Arguments to decompression executable.
+This variable expects a list of strings, except for `directory'
+and `filename' symbols, which will be replaced accordingly when
+opening an EPUB file."
+ :type 'list
+ :group 'nov)
+
(defcustom nov-variable-pitch t
"Non-nil if a variable pitch face should be used.
Otherwise the default face is used."
@@ -186,9 +194,11 @@ Each element of the stack is a list (NODEINDEX BUFFERPOS).")
(defun nov-unzip-epub (directory filename)
"Extract FILENAME into DIRECTORY.
Unnecessary nesting is removed with `nov-unnest-directory'."
- (let ((status (call-process nov-unzip-program nil "*nov unzip*" t
- "-od" directory filename))
- child)
+ (let* ((status (apply #'call-process nov-unzip-program nil "*nov unzip*" t
+ (mapcar (lambda (e) (cond ((eq e 'directory) directory)
+ ((eq e 'filename) filename)
+ (t e))) nov-unzip-args)))
+ child)
(while (setq child (nov-contains-nested-directory-p directory))
(nov-unnest-directory directory child))
;; HACK: unzip preserves file permissions, no matter how silly they