windows - 如何创建右键单击上下文 shell 快捷方式 "edit with Emacs"?

标签 windows emacs windows-shell windows-explorer

Notepad++ 自动添加一个 shell 快捷方式,这样当您在 Windows 资源管理器中时,您可以右键单击一个文件并选择“使用 Notepad++ 编辑”。我怎样才能对 emacs 做同样的事情?我正在使用适用于 Windows 的 GNU Emacs 22.3。

最佳答案

这就是我所拥有的 - 类似于其他一些答案。在某处创建一个名为 emacs-conextmenu.reg(或任何你想要的.reg)的新文本文件并将以下内容粘贴到:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell]
[HKEY_CLASSES_ROOT\*\shell\openwemacs]
@="&Edit with Emacs"
[HKEY_CLASSES_ROOT\*\shell\openwemacs\command]
@="Absolute\\Path\\to\\your\\emacs\\bin\\emacsclientw.exe -n \"%1\""
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs]
@="Edit &with Emacs"
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs\command]
@="Absolute\\Path\\to\\your\\emacs\\bin\\emacsclientw.exe -n \"%1\""

将路径更改为您的 emacs 安装路径;记得转义“\”(只要有\,请将其更改为\\)。

现在您需要做的就是在资源管理器中双击这个 *.reg 文件,您将有一个针对任何文件和任何目录的 emacs 上下文菜单条目(如果您是铁杆粉丝!)。

请注意,要使其正常工作,必须启动 emacs 并且还必须启动 emacs-server (M-x server-start)。我建议使用 Windows 启动 emacs 并将 (server-start) 放入您的 .emacs 文件中。

作为奖励,当您在 Windows 资源管理器中按 ctrl-shift-enter 键时,以下 autohotkey (http://www.autohotkey.com/) 片段将启动在 emacs 中选择的文件。如果您在 emacs 中编辑大量文件但不一定要导航到 emacs 本身中的文件,这可能会更方便。

#IfWinActive ahk_class CabinetWClass 
^+Enter::
  GetText(tmpvar)
  If (tmpvar != "")
     Run, d:/path/to/your/emacs/bin/dir/emacsclientw.exe -n "%tmpvar%"
Return
Return

关于windows - 如何创建右键单击上下文 shell 快捷方式 "edit with Emacs"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/455077/

相关文章:

php - 描述中给出的代码在Windows系统中是否可执行?

c++ - 单击上下文菜单项时运行程序

c++ - 程序使用的DLL,其中声明的变量存储在哪里?

linux - 如何避免 Windows 上 Git/IntelliJ 中文件中的 CR?

windows - Windows 上应用程序颜色(背景、按钮等)的指南?

html - 使用 emacs/HTML 模式可以进行正向/反向链接吗?

emacs - 防止 Emacs 在按回车键时删除尾随空格

css - Windows 10 缩放默认高于 100% 导致网站大小问题

Emacs 响应缓慢 : how to profile?

winapi - 为什么属性表中的图标用这么少的颜色呈现?