diff options
author | Eli Zaretskii <eliz@gnu.org> | 2016-10-21 12:59:58 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2016-10-21 12:59:58 +0300 |
commit | 0929e061fb544c0f4c10ff0412a41cf7e8148270 (patch) | |
tree | 6d5cd7dd393926ad46a8ef2e51a930c7af7e80c5 /lisp/info.el | |
parent | 56f8384bb3f20d55693a3a1db8aa2cf490e6d18e (diff) | |
download | emacs-0929e061fb544c0f4c10ff0412a41cf7e8148270.tar.gz |
Improve fontification of footnote references in Info buffers
* lisp/info.el (Info-fontify-node): Don't fontify random numbers
in parentheses as if they were footnote references. See
https://lists.gnu.org/archive/html/bug-texinfo/2016-10/msg00007.html
for the details.
Diffstat (limited to 'lisp/info.el')
-rw-r--r-- | lisp/info.el | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/lisp/info.el b/lisp/info.el index bb259bd59eb..6b8b3698ea0 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -5001,17 +5001,29 @@ first line or header line, and for breadcrumb links.") ;; Fontify footnotes (goto-char (point-min)) (when (and not-fontified-p (re-search-forward "^[ \t]*-+ Footnotes -+$" nil t)) - (let ((limit (point))) + (let ((limit (point)) + (fncount 0)) + ;; How many footnotes do we have in this node? + (while (re-search-forward "^ [ \t]*([0-9]+) " nil t) + (setq fncount (1+ fncount))) (goto-char (point-min)) - (while (re-search-forward "\\(([0-9]+)\\)" nil t) - (add-text-properties (match-beginning 0) (match-end 0) - `(font-lock-face info-xref - link t - mouse-face highlight - help-echo - ,(if (< (point) limit) - "mouse-2: go to footnote definition" - "mouse-2: go to footnote reference")))))) + (while (re-search-forward "\\((\\([0-9]+\\))\\)" nil t) + (let ((footnote-num (string-to-number (match-string 2)))) + ;; Don't fontify parenthesized numbers that cannot + ;; possibly be one of this node's footnotes. This still + ;; doesn't catch unrelated numbers that happen to be + ;; small enough, but in that case they should use + ;; "@footnotestyle separate" in the Texinfo sources. + (when (and (> footnote-num 0) + (<= footnote-num fncount)) + (add-text-properties (match-beginning 0) (match-end 0) + `(font-lock-face info-xref + link t + mouse-face highlight + help-echo + ,(if (< (point) limit) + "mouse-2: go to footnote definition" + "mouse-2: go to footnote reference")))))))) ;; Hide empty lines at the end of the node. (goto-char (point-max)) |