emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Richard Kim <emacs18@gmail.com>
To: Emacs-orgmode@gnu.org
Subject: patch to add new link type "infoi" that leverages Info-index command
Date: Sat, 1 Nov 2014 11:23:06 -0700	[thread overview]
Message-ID: <CAFq8O8sVXx9hj_tPih9q_qQsEEMCYbH3tAziwtMRKHxL1yqOFQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2721 bytes --]

A patch is provided below which implements a new link type called "infoi"
as a complement to "info" type that exist already.

Why new link type?  Because info index is almost always finer grain
than info nodes.  For example [[infoi:libc#close]] brings up not only
"(libc)Opening and Closing Files" info node, but also place the cursor
on the line that documents "open" function within the node.  Hence it
is more useful to link function, variable and other names that are in
the index.  Most info documents have very rich indexes.

I am not familiar with org coding style, so I share this patch to
present the idea rather than as a finished patch that can be checked
in.  I assume that name changes and other changes will be needed prior
to being acceptable for check in assuming that the idea is ok.

ChangeLog entry is followed by the git diff of my change.

--------------------------------------------------------------------------------

org-info.el: Add new link type "infoi" that looks up info file index.

* lisp/org-info.el (org-info-index-open): New function to implement
new link type named "infoi".

--------------------------------------------------------------------------------

diff --git a/doc/org.texi b/doc/org.texi
index 3fcf4b2..3aedefe 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3576,6 +3576,7 @@ gnus:group#id                             @r{Gnus
article link}
 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
 irc:/irc.com/#emacs/bob                   @r{IRC link}
 info:org#External links                   @r{Info node link}
+infoi:org#topic                           @r{Info index link}
 shell:ls *.org                            @r{A shell command}
 elisp:org-agenda                          @r{Interactive Elisp command}
 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
diff --git a/lisp/org-info.el b/lisp/org-info.el
index 8a2d717..bb65347 100644
--- a/lisp/org-info.el
+++ b/lisp/org-info.el
@@ -74,6 +74,23 @@
           (Info-find-node (match-string 1 name) "Top")))
     (message "Could not open: %s" name)))

+;;; info-index
+
+(org-add-link-type "infoi" 'org-info-index-open)
+
+(declare-function Info-index "info" (topic))
+
+(defun org-info-index-open (name)
+  "Follow an Info file and look up index item specified by NAME."
+  (if (or (string-match "\\(.*\\)[#:]:?\\(.*\\)" name)
+          (string-match "\\(.*\\)" name))
+      (let ((nodename (match-string 2 name)))
+    (require 'info)
+    (Info-find-node (match-string 1 name) "Top")
+        (if nodename ; If there isn't a node, choose "Top"
+            (Info-index nodename)))
+    (message "Could not open: %s" name)))
+
 (provide 'org-info)

 ;;; org-info.el ends here

[-- Attachment #2: Type: text/html, Size: 3413 bytes --]

             reply	other threads:[~2014-11-01 18:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-01 18:23 Richard Kim [this message]
2014-11-06 18:41 ` patch to add new link type "infoi" that leverages Info-index command Nicolas Goaziou
2014-11-10  3:58   ` Richard Kim
2014-11-10  9:17     ` Nicolas Goaziou
2014-11-15 18:46       ` Richard Y. Kim
2014-11-15 23:21         ` Nicolas Goaziou

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.orgmode.org/

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

  git send-email \
    --in-reply-to=CAFq8O8sVXx9hj_tPih9q_qQsEEMCYbH3tAziwtMRKHxL1yqOFQ@mail.gmail.com \
    --to=emacs18@gmail.com \
    --cc=Emacs-orgmode@gnu.org \
    /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/org-mode.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).