help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Opening an info page by command name, take 2


From: Stephen Berman
Subject: Re: Opening an info page by command name, take 2
Date: Thu, 13 Dec 2007 10:09:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

On Tue, 11 Dec 2007 21:49:59 +0100 (CET) <address@hidden> wrote:

> Hi all:
>
> I recently posted in this list about opening an Info page in emacs by
> command name, and I did get some replies, thanks a lot.
>
> Unfortunately, I'm still missing one piece of the equation: how do I
> know the Info page name beforehand?
>
> Say I want to get help about grep and also about gzip. With man I would
> just type "man grep" and "man gzip". From the command line I can type
> "info grep" and "info gzip" and get similar pages. With emacs, if I
> only now the words "grep" and "gzip", I cannot open those pages.
>
> For example, these are two suggestions I got on my last post:
>
>   emacs -Q --eval '(info "(bash3ref)Arrays")'
>
>   emacsclientw -e "(info \"(elisp) Lists\")"
>
> The question is, where did "(bash3ref)Arrays" and "(elisp) Lists" come
> from? You would have to browse the Info pages beforehand, wouldn't you?
> But that defeats the purpose. I would want to call some (info "bash")
> routine and get the same page as with "info bash" from the command
> line, but the info routine in emacs does not find the same page, it
> doesn't find anything under "bash" or "grep" or "gzip" alone.

Here's something that may help you.

(defun srb-info ()
  "Enter Info at the Info file the user chooses, tabbing for completion.
If you type parentheses around the Info file name and then type a
node name, e.g. `(emacs)Buffers', then Info enters the file at
that node (completion for nodes below the file level is not
provided)."
  (interactive)
  (require 'info)
  (let (files idx info-files info-file)
    (dolist (d Info-default-directory-list files)
      (when (file-readable-p d)
        (setq files (cons (directory-files d) files))))
    (setq files (append (car files) (cadr files)))
    (dolist (f files)
      (setq idx (string-match "\\." f))
      (setq info-files (cons (substring f 0 idx) info-files)))
    (dolist (f info-files)
      (when (string-match "-[1-9][0-9]?$" f)
        (setq info-files (delete f info-files))))
    (setq info-file (completing-read "Info file name: " info-files))
    (unless (string-match "^\([^ ]+\)" info-file)
      (setq info-file (concat "(" info-file ")")))
    (Info-goto-node info-file)))

Steve Berman





reply via email to

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