我希望将t/...
下的所有路径重写为n/...
,以便查找文件(或者就像next-error启动的那样)。我希望我不可能打开t/...
版本。
动机:我一直在把一个代码库从NFS (我编辑的地方)同步到/tmp上,所以我的构建速度更快(bjam,这是相当慢的)。我想强制emacs打开NFS版本,而不是始终打开/tmp版本。我想可能有某种find-file钩子可以做到这一点。有什么建议吗?流浪汉可能不会这么做。
如果我的编译缓冲区路径被重写,我也会很高兴。
发布于 2011-06-21 20:03:27
对于编译,您可以使用变量compilation-finish-functions
,如下所示:
(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/")))))
现在,您可能需要更新"/tmp/"
和替换的正则表达式。阅读Regexp Search上的内容。你也可以变得花哨,并实际检查你用替换创建的路径是否确实存在……
https://stackoverflow.com/questions/6430530
复制相似问题