在现有emacs框架中打开文件(Windows)

问题描述 投票:4回答:3

我在Windows 8上使用Emacs 24.3。我希望能够右键单击一个文件并选择“使用Emacs编辑”并在现有的emacs框架中打开该文件。我到目前为止所做的所有步骤都列在下面。大多数是从Emacs documentation page for Windows采取的方向。

以下是我用于在我的上下文菜单中添加“使用Emacs编辑”的注册表项:

[HKEY_CLASSES_ROOT\*\shell]
[HKEY_CLASSES_ROOT\*\shell\openwemacs]
@="&Edit with Emacs"
[HKEY_CLASSES_ROOT\*\shell\openwemacs\command]
@="C:\\Portable Software\\emacs-24.3\\bin\\emacsclientw.exe -n \"%1\""
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs]
@="Edit &with Emacs"
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs\command]
@="C:\\Portable Software\\emacs-24.3\\bin\\emacsclientw.exe --alternate-editor=\"C:\\Portable Software\\emacs-24.3\\bin\\runemacs.exe\" -n \"%1\""

我还将ALTERNATE_EDITOR环境变量设置为C:\\path\\to\\runemacs.exe

在我的.emacs开始时,我已经为每个this answer添加了以下代码。

(require 'server)
(or (server-running-p)
     (server-start))

添加在打开第二个文件时摆脱“服务器已在运行”错误,但它仍然在新框架中打开。

那么我缺少什么让emacs在现有框架中打开新文件?

windows emacs emacs24
3个回答
4
投票

我试图用SumatraPDF修复synctex时偶然发现了这一点。看起来除了指向ALTERNATE_EDITORrunemacs.exe环境变量之外,还必须创建一个指向服务器文件的EMACS_SERVER_FILE环境变量(我的存储在.emacs.d\server目录中)。一旦我这样做,我告诉Open with Emacs的文件在现有框架中打开而不是创建自己的文件。


0
投票

似乎emacsclient无法与服务器连接并且每次都无法启动emacs的新实例。您可能需要在已安装的任何软件防火墙中取消阻止某些内容。


0
投票

这对我有用。

使用以下内容创建C:\Program Files\runemacs.bat

@echo off

:: Set the path to where the Emacs binaries are
set binpath=C:\Program Files\emacs-26.1-x86_64\bin

:: If no arg is given edit this file
if "%~1"=="" (
  set filename="C:\Program Files\runemacs.bat"
) else (
  set filename="%~1"
)

:: Run Emacsclient
"%binpath%\emacsclientw.exe" --no-wait --alternate-editor="%binpath%\runemacs.exe" %filename%

并通过C:\Program Files\runemacs.bat而不是C:\Program Files\emacs-26.1-x86_64\bin\runemacs.exe打开所有文件。

© www.soinside.com 2019 - 2024. All rights reserved.