aboutsummaryrefslogtreecommitdiff
path: root/nov.el
diff options
context:
space:
mode:
authorVasilij Schneidermann <mail@vasilij.de>2022-02-18 13:30:26 +0100
committerVasilij Schneidermann <mail@vasilij.de>2022-02-18 13:30:26 +0100
commit0a166007f6430564360c31b5c68fca45a0c610d2 (patch)
treee798b3a9c88dc33e5d2bf9db700ef937fa766d5b /nov.el
parent2b4a7231aff6211a5a2f28719d830887aec6cc57 (diff)
Check for target or list of targets
Diffstat (limited to 'nov.el')
-rw-r--r--nov.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/nov.el b/nov.el
index fb48d87..055ad87 100644
--- a/nov.el
+++ b/nov.el
@@ -694,17 +694,22 @@ the HTML is rendered with `nov-render-html-function'."
(when (not match)
(error "Couldn't locate document"))
(setq index match)))
- (let ((shr-target-id target)) ; shr.el API for Emacs 27.1 and older
+ ;; HACK: this binding is only need for Emacs 27.1 and older, as of
+ ;; Emacs 28.1, shr.el always adds the shr-target-id property
+ (let ((shr-target-id target))
(nov-goto-document (or index nov-documents-index))))
(when target
(let ((pos (point-min))
done)
(while (and (not done)
(setq pos (next-single-property-change pos 'shr-target-id)))
- (when (equal (get-text-property pos 'shr-target-id) target)
- (goto-char pos)
- (recenter (1- (max 1 scroll-margin)))
- (setq done t)))
+ (let ((property (get-text-property pos 'shr-target-id)))
+ (when (or (equal property target)
+ ;; NOTE: as of Emacs 28.1 this may be a list of targets
+ (and (consp property) (member target property)))
+ (goto-char pos)
+ (recenter (1- (max 1 scroll-margin)))
+ (setq done t))))
(when (not done)
(error "Couldn't locate target")))))