I want any paths under t/...
to be rewritten to n/...
instead, for find-file in general (or just as initiated by next-error). I want it to be impossible for me to open the t/...
version.
Motivation: I've been rsyncing a codebase from NFS (where I edit) to /tmp, so my build is faster (bjam, which is quite slow). I want to force emacs to open the NFS version instead of the /tmp version ALWAYS. I imagine there's some kind of find-file hook that may be able to do this. Any suggestions? Tramp probably doesn't do this.
I'd be just as happy to have my compile buffer paths rewritten instead.
For the compilation, you can use the variable compilation-finish-functions
, with something like this:
(add-hook 'compilation-finish-functions 'my-change-tmp-to-nfs)
(defun my-change-tmp-to-nfs (buffer &optional stat)
"change tmp to nfs"
(interactive "b")
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(let ((buffer-read-only nil))
(while (re-search-forward "/tmp/" nil t)
(replace-match "/nfs/")))))
Now, you'll probably need to update the regex for the "/tmp/"
, and the replacement. Read up on Regexp Search. You could also get fancy and actually check to see that the path you created with the substitution actually exists...