aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUtkarsh Singh <utkarsh190601@gmail.com>2022-07-21 16:11:02 +0530
committerVasilij Schneidermann <mail@vasilij.de>2022-08-05 22:24:17 +0200
commit71fbc18911ec5e981d201b3174c4fcb23d444dab (patch)
tree1ac19bc34aa3027f3696e8da8a44d74698e9abaf
parent8f5b42e9d9f304b422c1a7918b43ee323a7d3532 (diff)
Add customization to tweak header
-rw-r--r--nov.el33
1 files changed, 23 insertions, 10 deletions
diff --git a/nov.el b/nov.el
index b47723d..41297ee 100644
--- a/nov.el
+++ b/nov.el
@@ -121,6 +121,13 @@ If set to `nil', no saving and restoring is performed."
(const :tag "Don't save last reading places" nil))
:group 'nov)
+(defcustom nov-header-line-format "%t: %c"
+ "Header line format.
+- %t is replaced by the title.
+- %u is replaced by the chapter title."
+ :type 'string
+ :group 'nov)
+
(defvar-local nov-file-name nil
"Path to the EPUB file backing this buffer.")
@@ -535,16 +542,22 @@ internal ones."
(defun nov-render-title (dom)
"Custom <title> rendering function for DOM.
-Sets `header-line-format' to a combination of the EPUB title and
-chapter title."
- (let ((title (cdr (assq 'title nov-metadata)))
- (chapter-title (car (dom-children dom))))
- (when (not chapter-title)
- (setq chapter-title '(:propertize "No title" face italic)))
- ;; this shouldn't happen for properly authored EPUBs
- (when (not title)
- (setq title '(:propertize "No title" face italic)))
- (setq header-line-format (list title ": " chapter-title))))
+Sets `header-line-format' according to `nov-header-line-format'."
+ (setq header-line-format
+ (and nov-header-line-format
+ (let ((title (cdr (assq 'title nov-metadata)))
+ (chapter-title (car (dom-children dom))))
+ (when (not chapter-title)
+ (setq chapter-title (propertize "No title" 'face 'italic)))
+ ;; this shouldn't happen for properly authored EPUBs
+ (when (not title)
+ (setq title (propertize "No title" 'face 'italic)))
+ (string-replace
+ "%" "%%"
+ (format-spec
+ nov-header-line-format
+ `((?c . ,chapter-title)
+ (?t . ,title))))))))
(defvar nov-shr-rendering-functions
'(;; default function uses url-retrieve and fails on local images