help-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [help-texinfo] Standalone info as a generic info processor?


From: Gavin Smith
Subject: Re: [help-texinfo] Standalone info as a generic info processor?
Date: Sat, 5 Nov 2016 20:52:53 +0000

On 5 November 2016 at 11:31, Alejandro Sanchez <address@hidden> wrote:
> Hello GNU,
>
> To give some context to my question, I want to have an info reader in Vim 
> (Neovim actually, but it should work in both), similar to Emacs’s info-mode. 
> I have looked at how Emacs does it and from the looks of it, it re-implements 
> the entire standalone reader in Emacs Lisp. That’s certainly a way to do it, 
> but it’s a lot of duplicate work when the standalone info reader already 
> knows everything about info files. Here is my plugin repository so far:
> https://gitlab.com/HiPhish/info.vim

There is alreadyhttp://www.vim.org/scripts/script.php?script_id=21
(although I've never used it so can't say how well it works).

> So I was planning on leveraging the standalone info as a sort of file 
> processor: you send it parameters of what you want and you receive the 
> formatted output back. Let’s say I want to read the introduction to Bash:
>
>         > info bash introduction --output - 2>/dev/null
>
> This works fine, I can read that into a buffer.

This command can do various things. To be on the safe side,

info --file bash --node introduction --output - 2>/dev/null

is better.

> I can also specify an entire path:
>
>         > info bash introduction 'what is bash?' --output - 2>/dev/null
>
> That’s half of the reader already. However, the other half is finding my way 
> around the file. References and menus are fairly simple to parse, but how do 
> I get what they point to? This is where the standalone info fails, I cannot 
> do something like this:
>
>         > info bash --x-ref 'foo bar'
>
> and get back the name of the node plus line number.

References contain the node name.  For example, in (bash)Definitions, there is

     A `control operator' or a `redirection operator'.  *Note
     Redirections::, for a list of redirection operators.  Operators
     contain at least one unquoted `metacharacter'.

To get the node "Redirections" the cross-reference refers to, you can do

info --file bash --node Redirections

> Similarly, if I want to search the index for something I would like to pass 
> this to the shell:
>
>         > info bash --index 'foo bar'

I don't think there is an (easy) way to do this from the command-line.
There is the "I" command from within Info which gives you a menu of
matching index entries, but as far as I know, there isn't a way to get
this from the command line. (For example, run "info bash" followed by
"Ifor", followed by Return.) Would that be useful?

> and get back a grep-like listing of where this occurs in the file. In my Vim 
> plugin I am using a URI for specifying locations in the info file (see the 
> HACKING in my repo for details):
>
>         info://file-name/node-1/node-2/
>
> I don’t expect info to return a URI like that back to me (although that would 
> be pretty cool), but I should have enough information to assemble it. A line 
> number can be given as a fragment or query within the URI. And of course if 
> someone has suggestions for a better URI I’m all ear.

The node names and line numbers are present in the "virtual index", so
it should be sufficient for your needs.

Also, I think you misunderstand the structure of an Info file. Nodes
are not nested within one another, so your location would just be

info://file-name/node-2/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]