From mboxrd@z Thu Jan 1 00:00:00 1970 From: emacs18@gmail.com (Richard Y. Kim) Subject: Re: patch to add new link type "infoi" that leverages Info-index command Date: Sat, 15 Nov 2014 10:46:19 -0800 Message-ID: References: <87k338qii9.fsf@nicolasgoaziou.fr> <87y4rjqusd.fsf@nicolasgoaziou.fr> Reply-To: emacs18@gmail.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpiMi-0004JR-16 for Emacs-orgmode@gnu.org; Sat, 15 Nov 2014 13:46:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XpiMd-0004Ne-CN for Emacs-orgmode@gnu.org; Sat, 15 Nov 2014 13:46:31 -0500 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]:40795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpiMd-0004Na-08 for Emacs-orgmode@gnu.org; Sat, 15 Nov 2014 13:46:27 -0500 Received: by mail-pa0-f52.google.com with SMTP id fa1so19437720pad.25 for ; Sat, 15 Nov 2014 10:46:25 -0800 (PST) In-Reply-To: <87y4rjqusd.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Mon, 10 Nov 2014 10:17:22 +0100") 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 --=-=-= Content-Type: text/plain Hi Nicolas, Thanks for your feedback. Attached is new patch which incorporates all your suggestions except the following: > Not directly related to your patch, but shouldn't it be > > (user-error "Could not open: %s" name) I'm not sure what you mean by this. Do you mean that the verb "open" is more approrpriate than "find" in the error message, i.e., "Could not open" rather than "Could not find"? If so, then it seems like "find" is more appropriate since "open" seems like there was a problem with opening a file when the problem is that a particular node was not found after successfully opening a file. Please let me know if I misunderstood. Thanks again for your valuable feedbacks. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-org-info-try-info-index-if-info-node-is-not-found.patch >From 16c25b88043f6f84c6d3df14ca3018040a09fe25 Mon Sep 17 00:00:00 2001 From: Kim Date: Sat, 15 Nov 2014 10:37:39 -0800 Subject: [PATCH] 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 --- doc/org.texi | 2 +- lisp/org-info.el | 15 +++++++++++---- 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..7c828a6 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 (format "Could not find '%s' node or index entry" + nodename-or-index)))))) (message "Could not open: %s" name))) (provide 'org-info) -- 1.9.1 --=-=-=--