43

C-x C-f blah.info opens the file in fundametal mode. I used apropos and found Info-mode which I thought might change from fundamental mode into Info mode, but that throws a lisp error.

How can I open a external/thirdparty *.info file in emacs so that I get the same bells and whistles as when I'm looking at M-x info (n for next, u for up, hyperlinks, etc..)? I'm sure this is obvious, but I can't figure it out.

Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
Upgradingdave
  • 12,916
  • 10
  • 62
  • 72

7 Answers7

69

Try C-u C-h i (i.e., the usual info invocation with a prefix argument).

huaiyuan
  • 26,129
  • 5
  • 57
  • 63
18

Plain (info `file-name') opens file in info mode. (info) probably does something besides just setting Info-mode. So I would use something like this:

(defun info-mode ()
  (interactive)
  (let ((file-name (buffer-file-name)))
    (kill-buffer (current-buffer))
    (info file-name)))
(add-to-list 'auto-mode-alist '("\\.info\\'" . info-mode))
rzab
  • 1,657
  • 11
  • 7
  • 1
    It seems that `info` serves mostly as a springboard to `info-setup`. Here's a similar function albeit without the `interactive` sugar of the original `info` function: `(defun info-find-file (file) (interactive "f") (info-setup file (pop-to-buffer-same-window (format "*info*<%s>" (file-name-sans-extension (file-name-nondirectory file))))))` – Sean Champ Dec 24 '14 at 03:23
12

When your cursor is on the filename in the dired buffer, press I (shift and i). Requires dired-x, which is part of GNU Emacs.

I runs the command dired-info
  which is an interactive compiled Lisp function in `dired-x.el'.
It is bound to I.
(dired-info)

Run info on this file.
piyo
  • 784
  • 5
  • 14
5

You can use org mode. Type the following in a buffer already set using M-x org-mode:

info:path/to/blah

Then invoke info by placing the cursor over this and hitting C-c C-o. Alternatively, click on it with your mouse. You can also set the whole thing in double square brackets, if you path contains whitespace.

Robbie Morrison
  • 159
  • 2
  • 4
5
(add-to-list 'auto-mode-alist '("\\.info\\'" . Info-on-current-buffer))
josliber
  • 43,891
  • 12
  • 98
  • 133
Ben Hyde
  • 1,503
  • 12
  • 14
  • This answer is close, as OP specifically indicated they are looking to simply view the buffer in Info mode, not integrate it into the global Info system. But note that this `auto-mode-alist` config would typically be ignored in `.info` files since they have a file-local variable specification at the top of the file (like `-*-Text-*-`) which takes precedence over `auto-mode-alist` config (see https://www.emacswiki.org/emacs/SetAutoMode ). I haven't yet found an alternative to calling `Info-on-current-buffer` manually via a keybinding. – mindthief Mar 29 '23 at 01:08
1

Add the following to your .emacs initialization file:

(setq auto-mode-alist 
      (append '(("\\.info" . Info-mode)) auto-mode-alist))
pajato0
  • 3,628
  • 3
  • 31
  • 37
  • This sorta worked but when I open a info file, none of the links are "active" until I navigate over one and press `RET`. I think @rzab is correct, seems like info does other stuff than just starting Info-mode. Thanks for the suggestion. – Upgradingdave Dec 17 '09 at 12:15
-1
C-u C-h i

That will prompt you for the file to open. C-u tells the interactive command info to ask for an argument, which is the file name.