[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#13989: Make Info support footnotes
From: |
Juri Linkov |
Subject: |
bug#13989: Make Info support footnotes |
Date: |
Tue, 19 Mar 2013 00:35:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) |
> It would be nice if Info supports footnotes, just like
> `org-footnote-action' in Org:
> (1) When at a footnote reference, jump to the definition.
> (2) When at a definition, jump to the references if they exist, offer
> to create them otherwise.
>
> Or another choice: make footnote.el support Info.
Thanks for the suggestion. Footnotes like in Org and Wikipedia
would be nice to have. And it's pretty straightforward to implement:
=== modified file 'lisp/info.el'
--- lisp/info.el 2013-02-21 06:55:19 +0000
+++ lisp/info.el 2013-03-18 22:34:07 +0000
@@ -3840,7 +3861,21 @@ (defun Info-try-follow-nearest-node (&op
((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
(Info-goto-node "Top" fork))
((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
- (Info-goto-node node fork)))
+ (Info-goto-node node fork))
+ ;; footnote
+ ((setq node (Info-get-token (point) "(" "\\(([0-9]+)\\)"))
+ (let ((old-point (point)) new-point)
+ (save-excursion
+ (goto-char (point-min))
+ (when (re-search-forward "^[ \t]*-+ Footnotes -+$" nil t)
+ (setq new-point (if (< old-point (point))
+ ;; Go to footnote reference
+ (search-forward node nil t)
+ ;; Go to footnote definition
+ (search-backward node nil t)))))
+ (when new-point
+ (goto-char new-point)
+ (setq node t)))))
node))
(defun Info-mouse-follow-link (click)
@@ -4896,6 +4931,20 @@ (defun Info-fontify-node ()
mouse-face highlight
help-echo "mouse-2: go to this URL"))))
+ ;; Fontify footnotes
+ (goto-char (point-min))
+ (when (and not-fontified-p (re-search-forward "^[ \t]*-+ Footnotes -+$"
nil t))
+ (let ((limit (point)))
+ (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
+ 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))
(skip-chars-backward "\n")