diff options
author | Vasilij Schneidermann <mail@vasilij.de> | 2021-03-23 01:23:16 +0100 |
---|---|---|
committer | Vasilij Schneidermann <mail@vasilij.de> | 2021-03-23 01:29:59 +0100 |
commit | 159682d99cace7d5954bddeab4543afd58109f29 (patch) | |
tree | ef87e9a0d8cf0bd82bda17de8474eeba4a38be0b /nov.el | |
parent | b6138895ace3042ed78140b6f4859e544fbca27e (diff) |
Verify shr-target-id property values before visit
Diffstat (limited to 'nov.el')
-rw-r--r-- | nov.el | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -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) |