Fix off-by-one jump to Org heading line

This wouid match the wrong heading if there were no spaces between the
headings. Thanks to kilesduli for bringing this matter to my attention
in issue 354: <https://github.com/protesilaos/denote/issues/354>.
This commit is contained in:
Protesilaos Stavrou 2024-05-18 09:30:39 +03:00
parent 7fe739fed0
commit be17fcb027
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -72,9 +72,10 @@ the current file."
"Return heading text and CUSTOM_ID from the given LINE in FILE."
(with-current-buffer (find-file-noselect file)
(save-excursion
(goto-char (point-min))
(forward-line line)
(cons (denote-link-ol-get-heading) (denote-link-ol-get-id)))))
(save-restriction
(goto-char (point-min))
(forward-line (1- line))
(cons (denote-link-ol-get-heading) (denote-link-ol-get-id))))))
(defun denote-org-extras-format-link-with-heading (file heading-id description)
"Prepare link to FILE with HEADING-ID using DESCRIPTION."