【问题标题】:Opening File with emacsclient from windows从 Windows 使用 emacsclient 打开文件
【发布时间】:2020-12-29 13:43:38
【问题描述】:

我尝试在 wsl2/Debian 上运行的 emacsclient 中从 Windows10 中打开文件。

在启动时,我启动 wsl/debian、X410 作为 X-server 和 emacs 守护进程。

我可以使用以下 startclient.bat 使用 emacsclient 启动一个新的 emacs 框架:

@echo off

debian.exe run "if [ -z \"$(pidof emacsclient)\" ]; then export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0; emacsclient -c; pkill '(gpg|ssh)-agent'; fi;"

然后我创建了一个快捷方式,以便我可以从任务栏打开一个新的 emacs 框架。令我惊讶的是,它工作得非常顺利......到目前为止。但是,我不知道如何在 Windows 资源管理器中使用 emacsclient 打开文件。

我想我需要将一个参数传递给 bat 文件中的 emacsclient -c,但是我该怎么做呢?

编辑: 通过执行以下操作:

debian.exe run "if [ -z \"$(pidof emacsclient)\" ]; then export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0; emacsclient -c "%1"; pkill '(gpg|ssh)-agent'; fi;"

我可以用 emacsclient 打开一个文件:

startclient.bat file.txt

但是,当使用 open 时,文件的路径会混乱 而不是

/mnt/c/Users/path/to/file

我明白了

/mnt/c/Windows/system32/C:\Users\path\to\file

我将如何将正确的路径作为变量传递?

【问题讨论】:

    标签: batch-file emacs windows-subsystem-for-linux wsl-2


    【解决方案1】:

    不太确定/mnt/c/Windows/system32/ 的来源,但您可以将%1 参数与wslpath 括起来,将C:\Users\path\to\file 转换为/mnt/c/Users/path/to/file,如下所示:

    emacsclient -c "$(wslpath '%1')"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多