mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 19:37:52 +00:00
org-footnote: Fix 5954f6aa25
* lisp/org-footnote.el (org-footnote-goto-definition): Better check for narrowed scope. * testing/lisp/test-org-footnote.el (test-org-footnote/goto-definition): Add test.
This commit is contained in:
parent
5954f6aa25
commit
510fc3761b
|
@ -360,14 +360,16 @@ If no footnote is found, return nil."
|
||||||
"Move point to the definition of the footnote LABEL.
|
"Move point to the definition of the footnote LABEL.
|
||||||
Return a non-nil value when a definition has been found."
|
Return a non-nil value when a definition has been found."
|
||||||
(interactive "sLabel: ")
|
(interactive "sLabel: ")
|
||||||
(let ((def (org-footnote-get-definition label)))
|
(let ((def-start (nth 1 (org-footnote-get-definition label))))
|
||||||
(cond
|
(cond
|
||||||
((not def) (user-error "Cannot find definition of footnote %s" label))
|
((not def-start)
|
||||||
((> (nth 1 def) (point-max))
|
(user-error "Cannot find definition of footnote %s" label))
|
||||||
|
((or (> def-start (point-max))
|
||||||
|
(< def-start (point-min)))
|
||||||
(user-error "Footnote definition outside of narrowed part of buffer"))
|
(user-error "Footnote definition outside of narrowed part of buffer"))
|
||||||
(t
|
(t
|
||||||
(org-mark-ring-push)
|
(org-mark-ring-push)
|
||||||
(goto-char (nth 1 def))
|
(goto-char def-start)
|
||||||
(looking-at (format "\\[%s[]:]" label))
|
(looking-at (format "\\[%s[]:]" label))
|
||||||
(goto-char (match-end 0))
|
(goto-char (match-end 0))
|
||||||
(org-show-context 'link-search)
|
(org-show-context 'link-search)
|
||||||
|
|
|
@ -164,6 +164,10 @@
|
||||||
(org-test-with-temp-text "Some text<point>\n[fn:1] Definition."
|
(org-test-with-temp-text "Some text<point>\n[fn:1] Definition."
|
||||||
(narrow-to-region (point-min) (point))
|
(narrow-to-region (point-min) (point))
|
||||||
(org-footnote-goto-definition "fn:1")))
|
(org-footnote-goto-definition "fn:1")))
|
||||||
|
(should-error
|
||||||
|
(org-test-with-temp-text "[fn:1] Definition.\n<point>Some text"
|
||||||
|
(narrow-to-region (point) (point-max))
|
||||||
|
(org-footnote-goto-definition "fn:1")))
|
||||||
;; Otherwise, move at the beginning of the definition, including
|
;; Otherwise, move at the beginning of the definition, including
|
||||||
;; anonymous footnotes.
|
;; anonymous footnotes.
|
||||||
(should
|
(should
|
||||||
|
|
Loading…
Reference in a new issue