summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim <emacs18@gmail.com>2014-11-15 10:37:39 -0800
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2014-11-16 00:14:29 +0100
commit96e1971f0fac6db1ac133faab0f7ed3bc38d96e7 (patch)
tree653b7a9d1c9055bb300b9fd51b653652e916f451
parent4670b0420cb1487d52ea9eb89a0a25ed48a09046 (diff)
downloadorg-mode-96e1971f0fac6db1ac133faab0f7ed3bc38d96e7.tar.gz
org-info: Try info index if info node is not found
* lisp/org-info.el (org-info-follow-link): Attempt index lookup if node lookup fails. * doc/org.texi (External links): Update info links. Info index is almost always finer grain than info nodes. For example with this change, [[info:libc#close]] brings up not only "(libc)Opening and Closing Files" info node, but also place the cursor on the line that documents "close" function within the node. This is done by looking up "close"in the index upon failing to find a node named "close". Hence one can now link function, variable and other names that are in the index rather than being limited to info node names. Typically there are far more index items than there are node names. For example libc manual has about 700 nodes, but over 4000 concept, type, function, and variables index items. More examples of new ways to create links are shown using org.info as example - [[info:org#org-clock-idle-time]] uses "Variable Index" - [[info:org#org-capture]] uses "Command and Function Index". - [[info:org#timestamp]] uses "Main Index" - [[info:org#C-c C-c]] uses "Key Index" TINYCHANGE
-rw-r--r--doc/org.texi2
-rw-r--r--lisp/org-info.el15
2 files changed, 12 insertions, 5 deletions
diff --git a/doc/org.texi b/doc/org.texi
index b01db2c..fcaee0c 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3575,7 +3575,7 @@ gnus:group @r{Gnus group link}
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}
+info:org#External links @r{Info node or 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..5734a58 100644
--- a/lisp/org-info.el
+++ b/lisp/org-info.el
@@ -67,11 +67,18 @@
"Follow an Info file and node link specified by NAME."
(if (or (string-match "\\(.*\\)[#:]:?\\(.*\\)" name)
(string-match "\\(.*\\)" name))
- (progn
+ (let ((filename (match-string 1 name))
+ (nodename-or-index (or (match-string 2 name) "Top")))
(require 'info)
- (if (match-string 2 name) ; If there isn't a node, choose "Top"
- (Info-find-node (match-string 1 name) (match-string 2 name))
- (Info-find-node (match-string 1 name) "Top")))
+ ;; If nodename-or-index is invalid node name, then look it up
+ ;; in the index.
+ (condition-case nil
+ (Info-find-node filename nodename-or-index)
+ (user-error (Info-find-node filename "Top")
+ (condition-case nil
+ (Info-index nodename-or-index)
+ (user-error "Could not find '%s' node or index entry"
+ nodename-or-index)))))
(message "Could not open: %s" name)))
(provide 'org-info)