pathname translation in Emacs for finding local source file path from remote (ssh compile) error filenames

StackOverflow https://stackoverflow.com/questions/1885205

Question

Is there some sort of general pathname-rewriting/normalizing facility I can exploit in Emacs to allow source files in compile-mode to be translated to local paths based on remote paths? I was hoping to use symbolic links, but that's not working for me in Windows.

I'm running GNU Emacs 23.1.1, and have tried cygwin-mount and w32-symlinks.el (with (customize-option 'w32-symlinks-handle-shortcuts)); I can't get open-file/dired/completions OR compile-mode next-error to follow either windows shortcuts or cygwin symlinks.

I'm remotely compiling (over ssh) and the warnings/errors give filenames where a prefix of the absolute pathnames (e.g. /nfs/topaz) on the remote host needs to be replaced with a different path (z:/, in fact), which I was hoping to do with symbolic links.

/ does go to (gets tab-expanded to in emacs) c:/cygwin and ~ to z:/ (my $HOME).

What I'm hoping for is either: a fix for symlink resolution (tab completion or opening a windows shortcut gets me the .lnk file and not what it points to), or the ability to supply a list of rewrites for prefixes of pathnames. Junctions aren't an option because the replacement path I want is on a different drive (it's also a Samba mount).

Was it helpful?

Solution

This is also useful in other complicated build environments: I use OpenWRT, and the build process copies (or extracts) source code to a separate build directory in which compilation occurs. So naively following file names in the emacs compilation buffer leads to edit the temporary copies, not the originals. Dangerous.

OTHER TIPS

Here's a partial solution:

(custom-set-variables '(compilation-search-path (quote (nil "z:/dir1" "~/dir2"))

etc. Of course, I have to add dozens of paths, but it's a huge improvement (next-error actually works now!)

After re-reading a few times, I still am not quite sure what your situation is - Are you compiling remotely and editing locally? If so, it seems like you should try doing both tasks on the same machine, or maybe try tramp mode in emacs. I just don't see an easy way to translate a remote path to a local one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top