From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Kim Subject: patch to add new link type "infoi" that leverages Info-index command Date: Sat, 1 Nov 2014 11:23:06 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c1b38670eeb20506d034a4 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkdKO-0005oC-Re for Emacs-orgmode@gnu.org; Sat, 01 Nov 2014 14:23:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XkdKN-0005uo-Ej for Emacs-orgmode@gnu.org; Sat, 01 Nov 2014 14:23:08 -0400 Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:56733) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkdKN-0005uk-4X for Emacs-orgmode@gnu.org; Sat, 01 Nov 2014 14:23:07 -0400 Received: by mail-wg0-f53.google.com with SMTP id b13so8466185wgh.40 for ; Sat, 01 Nov 2014 11:23:06 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Emacs-orgmode@gnu.org --001a11c1b38670eeb20506d034a4 Content-Type: text/plain; charset=UTF-8 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 --001a11c1b38670eeb20506d034a4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
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?=C2=A0 Because info index is almost= always finer grain
than info nodes.=C2=A0 For example [[infoi:libc#clos= e]] brings up not only
"(libc)Opening and Closing Files" info = node, but also place the cursor
on the line that documents "open&qu= ot; function within the node.=C2=A0 Hence it
is more useful to link func= tion, variable and other names that are in
the index.=C2=A0 Most info do= cuments have very rich indexes.

I am not familiar with org coding st= yle, so I share this patch to
present the idea rather than as a finished= patch that can be checked
in.=C2=A0 I assume that name changes and othe= r 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&= quot; that looks up info file index.

* lisp/org-info.el (org-info-in= dex-open): New function to implement
new link type named "infoi&quo= t;.

----------------------------------------------------------------= ----------------

diff --git a/doc/org.texi b/doc/org.texi
index 3= fcf4b2..3aedefe 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3= 576,6 +3576,7 @@ gnus:group#id=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 @r{Gnus article link}
= =C2=A0bbdb:R.*Stallman=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 @r{BBDB link (with regexp)}
=C2=A0irc:/irc.com/#emacs/bob=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 @r{IRC link}
=C2=A0info:org#External links=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 @r{Info node link}
+infoi:org#topic=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 @r{Info ind= ex link}
=C2=A0shell:ls *.org=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 @r{A shell command}
=C2=A0= elisp:org-agenda=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 @r{Interactive Elisp command}
=C2=A0elisp:(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 @@
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (Info-find-nod= e (match-string 1 name) "Top")))
=C2=A0=C2=A0=C2=A0=C2=A0 (mes= sage "Could not open: %s" name)))
=C2=A0
+;;; info-index+
+(org-add-link-type "infoi" 'org-info-index-open)
+<= br>+(declare-function Info-index "info" (topic))
+
+(defun = org-info-index-open (name)
+=C2=A0 "Follow an Info file and look up= index item specified by NAME."
+=C2=A0 (if (or (string-match "= ;\\(.*\\)[#:]:?\\(.*\\)" name)
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (string-match "\\(.*\\)" name))
+=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 (let ((nodename (match-string 2 name)))
+=C2=A0= =C2=A0=C2=A0 (require 'info)
+=C2=A0=C2=A0=C2=A0 (Info-find-node (ma= tch-string 1 name) "Top")
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 (if nodename ; If there isn't a node, choose "Top"<= br>+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (Inf= o-index nodename)))
+=C2=A0=C2=A0=C2=A0 (message "Could not open: %= s" name)))
+
=C2=A0(provide 'org-info)
=C2=A0
=C2=A0;;= ; org-info.el ends here

--001a11c1b38670eeb20506d034a4--