aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nov.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/nov.el b/nov.el
index 0080176..69b303d 100644
--- a/nov.el
+++ b/nov.el
@@ -660,14 +660,19 @@ 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))
+ (let ((shr-target-id target)) ; shr.el API for Emacs 27.1 and older
(nov-goto-document (or index nov-documents-index))))
(when target
- (let ((pos (next-single-property-change (point-min) 'shr-target-id)))
- (when (not pos)
- (error "Couldn't locate target"))
- (goto-char pos)
- (recenter (1- (max 1 scroll-margin))))))
+ (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)))
+ (when (not done)
+ (error "Couldn't locate target")))))
;; adapted from `shr-browse-url'
(defun nov-browse-url (&optional mouse-event)