如何创建右键上下文 shell 快捷方式“使用 Emacs 编辑”?

2024-02-20

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 文件中。

作为奖励,以下自动热键代码片段(http://www.autohotkey.com/ http://www.autohotkey.com/)将在您在 Windows 资源管理器中按 ctrl-shift-enter 时启动 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何创建右键上下文 shell 快捷方式“使用 Emacs 编辑”? 的相关文章

随机推荐