summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2011-07-05 13:28:03 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2011-07-05 14:01:44 +0200
commitde0fcdffa48da8baf57a612f2ce032d8737e6525 (patch)
treebad40735bcd4eef1897cbbc2f418efcd60354d98
parent43c08a1fbd3ca7381531c147037e4d67ecea4994 (diff)
downloadorg-mode-de0fcdffa48da8baf57a612f2ce032d8737e6525.tar.gz
org-footnote: distinguish footnotes from links
* lisp/org-footnote.el (org-footnote-at-reference-p): verify that what looks like a footnote doesn't belong to a link. (org-footnote-next-reference-or-definition): check more strictly footnote definitions.
-rw-r--r--lisp/org-footnote.el22
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 7e4cb06..41ac50e 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -176,14 +176,20 @@ positions, and the definition, if local."
;; get fooled by unrelated closing square brackets.
(end (ignore-errors (scan-sexps beg 1))))
;; Point is really at a reference if it's located before true
- ;; ending of the footnote and isn't within a LaTeX macro. About
- ;; that case, some special attention should be paid. Indeed,
- ;; when two footnotes are side by side, once the first one is
- ;; changed into LaTeX, the second one might then be considered
- ;; as an optional argument of the command. To prevent that, we
- ;; have a look at the `org-protected' property of that LaTeX
- ;; command.
+ ;; ending of the footnote and isn't within a link or a LaTeX
+ ;; macro. About that case, some special attention should be
+ ;; paid. Indeed, when two footnotes are side by side, once the
+ ;; first one is changed into LaTeX, the second one might then be
+ ;; considered as an optional argument of the command. To
+ ;; prevent that, we have a look at the `org-protected' property
+ ;; of that LaTeX command.
(when (and end (< (point) end)
+ (not (save-excursion
+ (goto-char beg)
+ (let ((linkp
+ (save-match-data
+ (org-in-regexp org-bracket-link-regexp))))
+ (and linkp (< (point) (cdr linkp))))))
(or (not (org-inside-latex-macro-p))
(and (get-text-property (1- beg) 'org-protected)
(not (get-text-property beg 'org-protected)))))
@@ -257,7 +263,7 @@ If no footnote is found, return nil."
(throw 'exit ref))
;; Definition: also grab the last square bracket, only
;; matched in `org-footnote-re' for [1]-like footnotes.
- ((= (point-at-bol) (match-beginning 0))
+ ((save-match-data (org-footnote-at-definition-p))
(let ((end (match-end 0)))
(throw 'exit
(list nil (match-beginning 0)