views:

183

answers:

3

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).

A: 

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.

zdav
The remote host has as some local canonical absolute path prefix what is locally a samba mount, namely `z:/`. As I said, they really are the same files. I did use tramp a long time ago.
wrang-wrang
I use emacs on my windows machine because my cygwin xserver doesn't support subpixel fonts (cleartype).
wrang-wrang
+1  A: 

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!)

wrang-wrang
+1  A: 

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.

Eric Anderson
Coming back to this, I've found that abusing the `directory-abbrev-alist` variable [see manual](http://www.gnu.org/software/emacs/elisp/html_node/Directory-Names.html) solves my problems better. In essence, you can tell emacs that compilation directory name is an alias ("abbreviation") for the source directory, so when it encounters a path in the compilation directory it re-writes it to be one in the source directory.Consider also ["Magic Filenames"](http://www.gnu.org/s/emacs/manual/html_node/elisp/Magic-File-Names.html) and the hook `file-name-handler-alist`.
Eric Anderson