From: "Philip K." <philipk@posteo.net>
To: Jean Louis <bugs@gnu.support>
Cc: 43775@debbugs.gnu.org
Subject: bug#43775: 28.0.50; Feature request: to include EPUB reading into doc-view
Date: Sat, 03 Oct 2020 13:30:30 +0200 [thread overview]
Message-ID: <87eemfpmw9.fsf@posteo.net> (raw)
In-Reply-To: <courier.000000005F783E74.00000378@protected.rcdrun.com> (Jean Louis's message of "Sat, 03 Oct 2020 11:03:48 +0200")
[-- Attachment #1: Type: text/plain, Size: 928 bytes --]
Jean Louis <bugs@gnu.support> writes:
> Situation is that doc-view can read PDF files, and Libreoffice or Open
> Document files, and others, but EPUB files are not included. Many
> digital books are made in EPUB format.
>
> Vasilij Schneidermann <mail 📧 vasilij.de> have written the nov-mode
> which when aded to auto-mode-list, opens EPUB files
>
> (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
>
> I have asked him, he would be somehow willing to cooperate if this is
> also confirmed by more users, there are few problems with it, as it
> depends on dash.el and other packages.
I sent him a patch a few weeks ago to remove dash (attached below), so
that shouldn't be an issue if he's interested. It's not a radical
change, but at the time he wasn't interested.
The second dependency, esxml is practically part of nov-mode, and
wouldn't make sense to factor it out.
--
Philip K.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Drop-dash-dependency.patch --]
[-- Type: text/x-patch, Size: 9401 bytes --]
From a50b42281c8dfa4bb727f43f006cbaefa0d88640 Mon Sep 17 00:00:00 2001
From: Philip K <philipk@posteo.net>
Date: Fri, 28 Aug 2020 23:34:05 +0200
Subject: [PATCH] Drop dash dependency
---
nov.el | 96 +++++++++++++++++++++++++++++++---------------------------
1 file changed, 51 insertions(+), 45 deletions(-)
diff --git a/nov.el b/nov.el
index 0072ea1..43749de 100644
--- a/nov.el
+++ b/nov.el
@@ -5,7 +5,7 @@
;; Author: Vasilij Schneidermann <mail@vasilij.de>
;; URL: https://depp.brause.cc/nov.el
;; Version: 0.3.0
-;; Package-Requires: ((dash "2.12.0") (esxml "0.3.3") (emacs "24.4"))
+;; Package-Requires: ((esxml "0.3.3") (emacs "24.4"))
;; Keywords: hypermedia, multimedia, epub
;; This file is NOT part of GNU Emacs.
@@ -44,7 +44,7 @@
;;; Code:
(require 'cl-lib)
-(require 'dash)
+(require 'pcase)
(require 'esxml-query)
(require 'shr)
(require 'url-parse)
@@ -148,8 +148,9 @@ Each element of the stack is a list (NODEINDEX BUFFERPOS).")
(defun nov-directory-files (directory)
"Returns a list of files in DIRECTORY except for . and .."
- (--remove (string-match-p "/\\.\\(?:\\.\\)?\\'" it)
- (directory-files directory t)))
+ (cl-loop for file in (directory-files directory t)
+ unless (string-match-p "/\\.\\(?:\\.\\)?\\'" file)
+ collect file))
(defun nov-contains-nested-directory-p (directory)
"Non-nil if DIRECTORY contains exactly one directory."
@@ -167,9 +168,9 @@ Each element of the stack is a list (NODEINDEX BUFFERPOS).")
(delete-directory child))
(defun nov--fix-permissions (file-or-directory mode)
- (->> (file-modes file-or-directory)
- (file-modes-symbolic-to-number mode)
- (set-file-modes file-or-directory)))
+ (let* ((modes (file-modes file-or-directory))
+ (symbolic (file-modes-symbolic-to-number mode modes)))
+ (set-file-modes file-or-directory symbolic)))
(defun nov-fix-permissions (directory)
"Iterate recursively through DIRECTORY to fix its files."
@@ -306,7 +307,9 @@ Required keys are 'identifier and everything in
"Extract an alist of manifest files for CONTENT in DIRECTORY.
Each alist item consists of the identifier and full path."
(mapcar (lambda (node)
- (-let [(&alist 'id id 'href href) (esxml-node-attributes node)]
+ (let* ((attr (esxml-node-attributes node))
+ (id (cdr (assq 'id attr)))
+ (href (cdr (assq 'href attr))))
(cons (intern id)
(nov-make-path directory (nov-urldecode href)))))
(esxml-query-all "package>manifest>item" content)))
@@ -336,7 +339,7 @@ Each alist item consists of the identifier and full path."
(let ((toc-file (assq nov-toc-id manifest)))
(when (not toc-file)
(error "EPUB 3 <nav> file not found"))
- (setq files (--remove (eq (car it) nov-toc-id) files))
+ (setq files (cl-remove nov-toc-id files :key #'car))
(cons toc-file files))))
(defun nov-content-files (directory content)
@@ -351,8 +354,9 @@ Each alist item consists of the identifier and full path."
(defun nov--walk-ncx-node (node)
(let ((tag (esxml-node-tag node))
- (children (--filter (eq (esxml-node-tag it) 'navPoint)
- (esxml-node-children node))))
+ (children (cl-loop for node in (esxml-node-children node)
+ when (eq (esxml-node-tag node) 'navPoint)
+ collect node)))
(cond
((eq tag 'navMap)
(insert "<ol>\n")
@@ -449,17 +453,18 @@ This function honors `shr-max-image-proportion' if possible."
'imagemagick)))
(if (not (display-graphic-p))
(insert alt)
- (-let* (((x1 y1 x2 y2) (window-inside-pixel-edges
- (get-buffer-window (current-buffer))))
- (image
- ;; `create-image' errors out for unsupported image types
- (ignore-errors
- (create-image path type nil
- :ascent 100
- :max-width (truncate (* shr-max-image-proportion
- (- x2 x1)))
- :max-height (truncate (* shr-max-image-proportion
- (- y2 y1)))))))
+ (pcase-let* ((`(,x1 ,y1 ,x2 ,y2)
+ (window-inside-pixel-edges
+ (get-buffer-window (current-buffer))))
+ (image
+ ;; `create-image' errors out for unsupported image types
+ (ignore-errors
+ (create-image path type nil
+ :ascent 100
+ :max-width (truncate (* shr-max-image-proportion
+ (- x2 x1)))
+ :max-height (truncate (* shr-max-image-proportion
+ (- y2 y1)))))))
(if image
(insert-image image)
(insert alt))))))
@@ -524,13 +529,14 @@ If the document path refers to an image (as determined by
`image-type-file-name-regexps'), an image is inserted, otherwise
the HTML is rendered with `nov-render-html-function'."
(interactive)
- (-let* (((id . path) (aref nov-documents nov-documents-index))
- ;; HACK: this should be looked up in the manifest
- (imagep (--find (string-match-p (car it) path)
- image-type-file-name-regexps))
- ;; NOTE: allows resolving image references correctly
- (default-directory (file-name-directory path))
- (buffer-read-only nil))
+ (pcase-let* ((`(,id . ,path) (aref nov-documents nov-documents-index))
+ ;; HACK: this should be looked up in the manifest
+ (imagep (cl-find path image-type-file-name-regexps
+ :test (lambda (a b) (string-match-p b a))
+ :key #'car))
+ ;; NOTE: allows resolving image references correctly
+ (default-directory (file-name-directory path))
+ (buffer-read-only nil))
(erase-buffer)
(cond
@@ -602,7 +608,7 @@ the HTML is rendered with `nov-render-html-function'."
(erase-buffer)
(insert (format "EPUB Version: %s\n" version))
(dolist (item metadata)
- (-let [(key . value) item]
+ (pcase-let ((`(,key . ,value) item))
(insert (format "%s: " (capitalize (symbol-name key))))
(if value
(if (eq key 'description)
@@ -721,10 +727,10 @@ Saving is only done if `nov-save-place-file' is set."
(interactive)
(or nov-history
(user-error "This is the first document you looked at"))
- (-let ((history-forward
- (cons (list nov-documents-index (point))
- nov-history-forward))
- ((index opoint) (car nov-history)))
+ (pcase-let ((history-forward
+ (cons (list nov-documents-index (point))
+ nov-history-forward))
+ (`(,index ,opoint) (car nov-history)))
(setq nov-history (cdr nov-history))
(nov-goto-document index)
(setq nov-history (cdr nov-history))
@@ -737,8 +743,8 @@ Saving is only done if `nov-save-place-file' is set."
(interactive)
(or nov-history-forward
(user-error "This is the last document you looked at"))
- (-let ((history-forward (cdr nov-history-forward))
- ((index opoint) (car nov-history-forward)))
+ (pcase-let ((history-forward (cdr nov-history-forward))
+ (`(,index ,opoint) (car nov-history-forward)))
(nov-goto-document index)
(setq nov-history-forward history-forward)
(goto-char opoint)
@@ -764,15 +770,15 @@ Saving is only done if `nov-save-place-file' is set."
(nov-clean-up)
(error "Invalid EPUB file"))
(let* ((content (nov-slurp (nov-container-filename nov-temp-dir) t))
- (content-file (->> (nov-container-content-filename content)
- (nov-make-path nov-temp-dir)))
+ (content-file (nov-make-path
+ nov-temp-dir
+ (nov-container-content-filename content)))
(work-dir (file-name-directory content-file))
(content (nov-slurp content-file t)))
(setq nov-content-file content-file)
(setq nov-epub-version (nov-content-version content))
(setq nov-metadata (nov-content-metadata content))
- (setq nov-documents (->> (nov-content-files work-dir content)
- (apply 'vector)))
+ (setq nov-documents (apply 'vector (nov-content-files work-dir content)))
(setq nov-documents-index 0))
(setq buffer-undo-list t)
(setq nov-file-name (buffer-file-name))
@@ -880,11 +886,11 @@ See also `nov-bookmark-make-record'."
(libxml-parse-html-region (point-min) (point-max)))))
(mapcar
(lambda (node)
- (-let* ((href (esxml-node-attribute 'href node))
- (label (mapconcat 'string-trim-whitespace
- (esxml-find-descendants #'stringp node) " "))
- ((filename target) (nov-url-filename-and-target href)))
- (list label filename 'nov-imenu-goto-function target)))
+ (pcase-let* ((href (esxml-node-attribute 'href node))
+ (label (mapconcat 'string-trim-whitespace
+ (esxml-find-descendants #'stringp node) " "))
+ (`(,filename ,target) (nov-url-filename-and-target href)))
+ (list label filename 'nov-imenu-goto-function target)))
(esxml-query-all "a" toc))))
(defun nov-imenu-setup ()
--
2.26.2
next prev parent reply other threads:[~2020-10-03 11:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-03 9:03 bug#43775: 28.0.50; Feature request: to include EPUB reading into doc-view Jean Louis
[not found] ` <VI1PR06MB4526E1B8D23CC152E879499C960E0@VI1PR06MB4526.eurprd06.prod.outlook.com>
2020-10-03 10:26 ` bug#43775: Sv: " Jean Louis
2020-10-03 11:30 ` Philip K. [this message]
2020-10-04 3:44 ` Richard Stallman
2020-10-04 4:40 ` bug#43775: 28.0.50; Feature request: to include EPUB reading into main Emacs Jean Louis
2020-10-04 5:48 ` Vasilij Schneidermann
2020-10-05 3:15 ` Richard Stallman
2020-10-05 4:12 ` Jean Louis
2020-10-05 4:22 ` Vasilij Schneidermann
2020-10-05 5:17 ` Jean Louis
2020-10-06 2:30 ` Richard Stallman
[not found] ` <E1kPco3-000841-JM@fencepost.gnu.org>
2020-10-07 17:47 ` Vasilij Schneidermann
2020-10-05 7:53 ` Lars Ingebrigtsen
2020-10-05 8:52 ` Arthur Miller
2020-10-05 11:36 ` Vasilij Schneidermann
2020-10-05 11:32 ` Vasilij Schneidermann
2020-10-06 1:31 ` Lars Ingebrigtsen
2020-10-07 17:50 ` Vasilij Schneidermann
2020-10-09 4:16 ` Lars Ingebrigtsen
2020-10-12 6:36 ` Vasilij Schneidermann
2020-10-12 14:55 ` Eli Zaretskii
2020-10-04 7:22 ` bug#43775: 28.0.50; Feature request: to include EPUB reading into doc-view Eli Zaretskii
2022-04-23 14:50 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eemfpmw9.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=43775@debbugs.gnu.org \
--cc=bugs@gnu.support \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).