在 Windows 下将路径转换挂接到 Emacs 的最佳位置
Best place to hook path conversion in to Emacs under Windows
我将 GNU Emacs on Windows with git-bash 用于 unix 工具,例如 locate
、grep
和 find
。 git-bash 工具吐出以下形式的路径:
/c/path/to/file/file.txt
Emacs 需要 find-file
、find-file-at-point
或(使用 helm
包)函数 helm-find-file
其路径形式
c:/path/to/file/file.txt
我写了一个转换器函数,将前者转换为后者,我通过 expand-file-name
中的 defadvice
连接了它。这工作得很好(例如,在我最初的用例中,使 helm-locate
与 git-bash locate
合作)。
然而在某些情况下它不起作用,例如在 find-file-at-point
的交互式使用中。所以我的问题是什么是更通用的地方来连接这个转换器以使交互式调用正常工作?
jenesaisquoi's comment brought me to cygwin-mount.el。我用 gitbash 试了一下 - 它神奇地起作用了!
原因是 gitbash 提供了与 cygwin 和 gitbash[ 相似的 mount
命令=24=] 的路径也是 cygwin 路径。
只需确保 gitbash 二进制文件在 emacs 的 PATH
环境变量中。
我将 GNU Emacs on Windows with git-bash 用于 unix 工具,例如 locate
、grep
和 find
。 git-bash 工具吐出以下形式的路径:
/c/path/to/file/file.txt
Emacs 需要 find-file
、find-file-at-point
或(使用 helm
包)函数 helm-find-file
其路径形式
c:/path/to/file/file.txt
我写了一个转换器函数,将前者转换为后者,我通过 expand-file-name
中的 defadvice
连接了它。这工作得很好(例如,在我最初的用例中,使 helm-locate
与 git-bash locate
合作)。
然而在某些情况下它不起作用,例如在 find-file-at-point
的交互式使用中。所以我的问题是什么是更通用的地方来连接这个转换器以使交互式调用正常工作?
jenesaisquoi's comment brought me to cygwin-mount.el。我用 gitbash 试了一下 - 它神奇地起作用了!
原因是 gitbash 提供了与 cygwin 和 gitbash[ 相似的 mount
命令=24=] 的路径也是 cygwin 路径。
只需确保 gitbash 二进制文件在 emacs 的 PATH
环境变量中。