unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Xue Fuqiao <xfq.free@gmail.com>
Cc: 13989@debbugs.gnu.org
Subject: bug#13989: Make Info support footnotes
Date: Tue, 19 Mar 2013 00:35:57 +0200	[thread overview]
Message-ID: <87k3p4fig2.fsf@mail.jurta.org> (raw)
In-Reply-To: <20130318182438.9ed088809ca67b7e4326335c@gmail.com> (Xue Fuqiao's message of "Mon, 18 Mar 2013 18:24:38 +0800")

> 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")






  reply	other threads:[~2013-03-18 22:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-18 10:24 bug#13989: Make Info support footnotes Xue Fuqiao
2013-03-18 22:35 ` Juri Linkov [this message]
2013-03-19 22:30   ` Juri Linkov
2013-03-20  3:50     ` Eli Zaretskii
2013-03-20 23:05       ` Juri Linkov
2013-03-21  8:09         ` Xue Fuqiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k3p4fig2.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=13989@debbugs.gnu.org \
    --cc=xfq.free@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).