summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-04-25 11:09:05 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-04-25 11:09:05 +0200
commit510fc3761b31b0429be9bba4bad79786f5648698 (patch)
tree10b465be65186eded46a8fa43fb640fc8f9d627a
parent5954f6aa25b51a3a9a8f258fb0f15ef51be31366 (diff)
downloadorg-mode-510fc3761b31b0429be9bba4bad79786f5648698.tar.gz
org-footnote: Fix 5954f6aa25b51a3a9a8f258fb0f15ef51be31366
* 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.
-rw-r--r--lisp/org-footnote.el10
-rw-r--r--testing/lisp/test-org-footnote.el4
2 files changed, 10 insertions, 4 deletions
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index f40f36f..679b47f 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -360,14 +360,16 @@ If no footnote is found, return nil."
"Move point to the definition of the footnote LABEL.
Return a non-nil value when a definition has been found."
(interactive "sLabel: ")
- (let ((def (org-footnote-get-definition label)))
+ (let ((def-start (nth 1 (org-footnote-get-definition label))))
(cond
- ((not def) (user-error "Cannot find definition of footnote %s" label))
- ((> (nth 1 def) (point-max))
+ ((not def-start)
+ (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"))
(t
(org-mark-ring-push)
- (goto-char (nth 1 def))
+ (goto-char def-start)
(looking-at (format "\\[%s[]:]" label))
(goto-char (match-end 0))
(org-show-context 'link-search)
diff --git a/testing/lisp/test-org-footnote.el b/testing/lisp/test-org-footnote.el
index b778c2e..4e43fe1 100644
--- a/testing/lisp/test-org-footnote.el
+++ b/testing/lisp/test-org-footnote.el
@@ -164,6 +164,10 @@
(org-test-with-temp-text "Some text<point>\n[fn:1] Definition."
(narrow-to-region (point-min) (point))
(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
;; anonymous footnotes.
(should