How to view man pages using emacs when invoking man command in command line?
Asked Answered
A

3

6

I would like to view man pages using emacs when invoking man command. I modified the pager parameter in /etc/man.conf PAGER to emacs.

But, it doesn't work. Is there anything I should modify ?

Apparently answered 17/5, 2012 at 22:6 Comment(1)
possible duplicate of Using Emacs for $PAGER?Catadromous
Y
5

Indeed, emacs cannot read STDIN into a buffer, meaning

cat foobar | emacs

does not work in any case. So setting your PAGER variable to 'emacs', or 'emacs -nw' does not do the job. Only way around I see is to write the man output into a tmp-file and then load that file into emacs:

man find > tmp-file; emacs tmp-file

You could alias this. For example, assuming a tc-shell, and a directory called 'tmp' in your home-path, you can put the following line into your ~/.tcshrc file:

alias man '/usr/bin/man \!* > ~/tmp/tmp-file; emacs ~/tmp/tmp-file; rm ~/tmp/tmp-file'

So next time you call man find, emacs will fire up.

Yuri answered 18/5, 2012 at 0:33 Comment(0)
C
4

Emacs has a "Man mode", which can be invoked by M-x man RET and then typing in your command.

Caesarean answered 24/7, 2013 at 7:45 Comment(0)
H
3

You can profit from emacs's function man. Just define a function in bash that will run emacs that will call it:

function man () {
    emacs -e '(man "'"$1"'")'
}

You might want to call emacs -nw or even emacsclient instead.

Halsey answered 18/5, 2012 at 0:38 Comment(6)
Also worth considering: emacs -eval "(woman \"$1\")", which uses emacs' elisp based man instead of the external man program.Hemispheroid
@Hemispheroid This opens the man buffer as a popup, how can I maximize it (in the script, of course)?Burdett
@YoujunHu: What do you mean by "does not work"? What error do you get? It works for me.Halsey
@Halsey : The error I got: symbol's function defintion is void: (man\ \"find")Caesarean
The version that works for me: emacs -nw --eval '(progn (man "'$1'") (delete-window))';Caesarean
another working version: emacs -nw --eval "(progn (man \"$1\") (delete-window))"Caesarean

© 2022 - 2024 — McMap. All rights reserved.