5

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 ?

Stefan
  • 27,908
  • 4
  • 53
  • 82
user832953
  • 51
  • 2
  • 1
    possible duplicate of [Using Emacs for $PAGER?](http://stackoverflow.com/questions/8406721/using-emacs-for-pager) – phils May 17 '12 at 22:39

3 Answers3

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.

Klaus
  • 805
  • 6
  • 7
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.

choroba
  • 231,213
  • 25
  • 204
  • 289
3

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

Stefan
  • 27,908
  • 4
  • 53
  • 82
Youjun Hu
  • 991
  • 6
  • 18