4

I have a question regarding the use of M-x man in Emacs. I'm working with Tramp all the time and often the installed program base on the remote server differs significantly from my local setup. I see that invoking M-x man involves looking for the relevant manpages on the local machine. Is there a way to instruct it to use the environment on the other side of Tramp?

I know there's an Elisp variable tramp-remote-process-environment and I've tried adding an entry for MANPATH to it, but it doesn't seem to work (I'm afraid it's because I put it in the form /usr/share/man instead of /scpc:user@host:/usr/share/man but what I want is a generic solution to work on all remote hosts). Any ideas?

legoscia
  • 39,593
  • 22
  • 116
  • 167
Wojciech Gac
  • 1,538
  • 1
  • 16
  • 30
  • `woman-find-file` handles remote man pages, if given a full path. My answer [here](http://emacs.stackexchange.com/a/20996/10625) shows a hack to get this working if you use eshell; you may be able to take some inspiration from it. – Stig Brautaset Mar 16 '16 at 16:51

2 Answers2

2

From the Man-start-calling macro in man.el:

(let (...
    (default-directory
      (if (and (file-directory-p default-directory)
               (not (find-file-name-handler default-directory
                                            'file-directory-p)))
          default-directory
        "/"))

That is, if there is a special file name handler for the current default directory, such as Tramp, it will use the root directory as the directory to start man from, and thus it will see man pages from the system that Emacs is running on.

There doesn't seem to be a way to disable this apart from changing man.el. Note that this is a macro, so you need to reload the macro and all the functions that use the macro.

legoscia
  • 39,593
  • 22
  • 116
  • 167
  • 2
    Thanks @legoscia, it's interesting though. I would think that it's only natural to expect Emacs to interact with remote manpages. – Wojciech Gac Apr 09 '14 at 12:23
  • Wojciech Gac: I can also imagine it being highly confusing (albeit less so if the buffer name incorporated the hostname or tramp path), but it would certainly seem reasonable for it to be a configurable option so that people who want the behaviour can get it. I'd suggest `M-x report-emacs-bug` – phils Feb 02 '15 at 19:43
  • 1
    FYI the above code now lives `Man-getpage-in-background` and is not in a macro, but commenting out that `default-directory` binding does *not* enable remote man pages. – phils Feb 02 '15 at 20:02
0

From docstring of command man would expect it's able to read remote pages:

An explicit filename can be given too. Use -l if it might otherwise look like a page name.

/my/file/name.1.gz
-l somefile.1

You may write a caller, which reads the environment and composes the needed argument.

Andreas Röhler
  • 4,804
  • 14
  • 18