From fce7b0b0506231626887f131ca38e968e4c7f9e8 Mon Sep 17 00:00:00 2001 From: Liam Hupfer Date: Thu, 28 Apr 2022 16:05:13 +0200 Subject: Add support for arbitrary decompression tools This allows users to use non-unzip decompression tools such as libarchive's `bsdtar`. --- nov.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'nov.el') 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 -- cgit v1.2.3