forked from mirrors/org-mode
Adjust fontification of footnotes
* lisp/org-footnote.el (org-footnote-next-reference-or-definition): new function. * lisp/org.el (org-activate-footnote-links): activate the whole footnote, but only fontify its label.
This commit is contained in:
parent
460d093da8
commit
1eac25a438
|
@ -221,17 +221,36 @@ the buffer position bounding the search.
|
||||||
Return value is a list like those provided by `org-footnote-at-reference-p'.
|
Return value is a list like those provided by `org-footnote-at-reference-p'.
|
||||||
If no footnote is found, return nil."
|
If no footnote is found, return nil."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let* ((label-fmt (if label
|
(let* ((label-fmt (if label (format "\\[%s[]:]" label) org-footnote-re)))
|
||||||
(format "\\[%s[]:]" label)
|
|
||||||
(org-re "\\[[-_[:word:]]+[]:]"))))
|
|
||||||
(catch 'exit
|
(catch 'exit
|
||||||
(while t
|
(while t
|
||||||
(unless (funcall (if backward #'re-search-backward #'re-search-forward)
|
(unless (funcall (if backward #'re-search-backward #'re-search-forward)
|
||||||
label-fmt limit t)
|
label-fmt limit t)
|
||||||
(throw 'exit nil))
|
(throw 'exit nil))
|
||||||
(unless backward (backward-char))
|
(unless backward (backward-char))
|
||||||
(when (setq ref (org-footnote-at-reference-p))
|
(let ((ref (org-footnote-at-reference-p)))
|
||||||
(throw 'exit ref)))))))
|
(when ref (throw 'exit ref))))))))
|
||||||
|
|
||||||
|
(defun org-footnote-next-reference-or-definition (limit)
|
||||||
|
"Move point to next footnote reference or definition.
|
||||||
|
|
||||||
|
LIMIT is the buffer position bounding the search.
|
||||||
|
|
||||||
|
Return value is a list like those provided by
|
||||||
|
`org-footnote-at-reference-p' or `org-footnote-at-definition-p'.
|
||||||
|
If no footnote is found, return nil."
|
||||||
|
(let* (ref)
|
||||||
|
(catch 'exit
|
||||||
|
(while t
|
||||||
|
(unless (re-search-forward org-footnote-re limit t)
|
||||||
|
(throw 'exit nil))
|
||||||
|
(cond
|
||||||
|
((setq ref (org-footnote-at-reference-p))
|
||||||
|
(throw 'exit ref))
|
||||||
|
;; Definition: also grab the last square bracket, not matched
|
||||||
|
;; in `org-footnote-re'
|
||||||
|
((= (point-at-bol) (match-beginning 0))
|
||||||
|
(throw 'exit (list nil (match-beginning 0) (1+ (match-end 0))))))))))
|
||||||
|
|
||||||
(defun org-footnote-get-definition (label)
|
(defun org-footnote-get-definition (label)
|
||||||
"Return label, boundaries and definition of the footnote LABEL."
|
"Return label, boundaries and definition of the footnote LABEL."
|
||||||
|
|
22
lisp/org.el
22
lisp/org.el
|
@ -5272,20 +5272,20 @@ will be prompted for."
|
||||||
|
|
||||||
(defun org-activate-footnote-links (limit)
|
(defun org-activate-footnote-links (limit)
|
||||||
"Run through the buffer and add overlays to links."
|
"Run through the buffer and add overlays to links."
|
||||||
(if (re-search-forward "\\(^\\|[^][]\\)\\(\\[\\([0-9]+\\]\\|fn:[^ \t\r\n:]+?[]:]\\)\\)"
|
(let ((fn (org-footnote-next-reference-or-definition limit)))
|
||||||
limit t)
|
(when fn
|
||||||
(progn
|
(let ((beg (nth 1 fn)) (end (nth 2 fn)))
|
||||||
(org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
|
(org-remove-flyspell-overlays-in beg end)
|
||||||
(add-text-properties (match-beginning 2) (match-end 2)
|
(add-text-properties beg end
|
||||||
(list 'mouse-face 'highlight
|
(list 'mouse-face 'highlight
|
||||||
'keymap org-mouse-map
|
'keymap org-mouse-map
|
||||||
'help-echo
|
'help-echo
|
||||||
(if (= (point-at-bol) (match-beginning 2))
|
(if (= (point-at-bol) beg)
|
||||||
"Footnote definition"
|
"Footnote definition"
|
||||||
"Footnote reference")
|
"Footnote reference")))
|
||||||
))
|
(save-excursion
|
||||||
(org-rear-nonsticky-at (match-end 2))
|
(goto-char beg)
|
||||||
t)))
|
(looking-at (regexp-quote (buffer-substring beg end))))))))
|
||||||
|
|
||||||
(defun org-activate-bracket-links (limit)
|
(defun org-activate-bracket-links (limit)
|
||||||
"Run through the buffer and add overlays to bracketed links."
|
"Run through the buffer and add overlays to bracketed links."
|
||||||
|
@ -5581,7 +5581,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
|
||||||
(if (memq 'radio lk) '(org-activate-target-links (0 'org-link t)))
|
(if (memq 'radio lk) '(org-activate-target-links (0 'org-link t)))
|
||||||
(if (memq 'date lk) '(org-activate-dates (0 'org-date t)))
|
(if (memq 'date lk) '(org-activate-dates (0 'org-date t)))
|
||||||
(if (memq 'footnote lk) '(org-activate-footnote-links
|
(if (memq 'footnote lk) '(org-activate-footnote-links
|
||||||
(2 'org-footnote t)))
|
(0 'org-footnote t)))
|
||||||
'("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
|
'("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
|
||||||
'(org-hide-wide-columns (0 nil append))
|
'(org-hide-wide-columns (0 nil append))
|
||||||
;; TODO lines
|
;; TODO lines
|
||||||
|
|
Loading…
Reference in a new issue