When I'm logged in to a remote machine in eshell I can still do man ls. But it appears that this only work for my local man pages. If I try man yum I'll get a message that the yum man page is not found. However, if I log into the machine via a regular terminal and use man yum there the manual is shown. Is there a way to get remote man pages showing up when in TRAMP mode? I'd really like that because I'm running OS X locally but frequently log in to linux servers where the utilities have different options etc.

Update: To clarify, here's an example session:

Welcome to the Emacs shell
~ $ cd /ssh:example.com:/
/ssh:example.com:/ $ man yum
#<buffer *Man yum*>

Alright! That's expected. But, regretfully, no *Man yum* buffer is created an these messages appear in *Messages*:

Invoking man yum in the background
Please wait: formatting the yum man page...
yum man page formatted
error in process sentinel: user-error: Can't find the yum manpage
error in process sentinel: Can't find the yum manpage

Update 2: I found out (from a comment on this answer) that I can invoke the remote man by prefixing with *, so *man yum -- which is an OK work-around. But it just dumps the content in the eshell window, rather than open a new buffer like the man command does. I'd really like that behaviour.

  • Do you mean man as the emacs command, or as the shell command? – choroba Feb 23 '16 at 17:46
  • I mean when typing man yum in eshell, the emacs shell. Not M-x man. – Stig Brautaset Feb 23 '16 at 18:05
  • That's the same, because eshell runs in emacs. Try \man yum instead. – choroba Feb 23 '16 at 18:09
  • 1
    \man yum does not work, but *man yum kinda does -- I've added my "objection" to that to the question also. – Stig Brautaset Feb 23 '16 at 18:14
  • 1
    See also this question on Stack Overflow. – legoscia Feb 24 '16 at 18:49

I have found a work-around! Admittedly it is a bit hacky, and uses woman rather than man, but I think this might just work for me. Essentially, woman-find-file is tramp aware, so if we can pass it the path to the remote man page it will open it just fine.

Passing the --path flag to man will output the path of the manpage rather than open the manpage itself. Woman doesn't like pre-formatted man pages, so pass the -c flag to ignore those. Now we can execute the remote man command (by prefixing man with *) to find the path to the foo man page thus: *man -c --path foo.

The following function takes a path from the above and checks if it is a remote path. If it is, it prepends the tramp method, user & host to the local file name. Then it invokes the woman-find-file function on the result. Put it in your ~/.emacs.d/init.el.

(defun tramp-aware-woman (man-page-path)
  (let ((dir (eshell/pwd)))
     (if (file-remote-p dir)
         (let ((vec (tramp-dissect-file-name dir)))
            (tramp-file-name-method vec)
            (tramp-file-name-user vec)
            (tramp-file-name-host vec)

Now we can create an alias that invokes our function for a bit of ux sugar:

alias man 'tramp-aware-woman ${*man -c --path $1}'

The new command should work from eshell both locally and remote, though you will now get woman's rendering. You may want to choose a different name for the alias if you want to retain the existing behaviour of man for local man pages.

Your Answer

