记事本+ +自动添加一个shell快捷方式,以便当您在Windows资源pipe理器,您可以右键单击一个文件,并select“用记事本++编辑”。 我该怎么做与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(Mx服务器启动)。 我建议用Windows启动emacs,并将(服务器启动)放入.emacs文件中。
作为一个奖励,下面的代码autohotkey( http://www.autohotkey.com/ )将启动在emacs中选择的文件,当你按下ctrl-shift-enter在Windows资源管理器。 如果您在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
就像polyglot的答案,但不需要启动服务器或任何混乱。
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell] [HKEY_CLASSES_ROOT\*\shell\openwemacs] @="&Edit with Emacs" [HKEY_CLASSES_ROOT\*\shell\openwemacs\command] @="C:\\Program Files (x86)\\Emacs\\bin\\emacsclientw.exe --alternate-editor=\"C:\\Program Files (x86)\\Emacs\\bin\\runemacs.exe\" -n \"%1\"" [HKEY_CLASSES_ROOT\Directory\shell\openwemacs] @="Edit &with Emacs" [HKEY_CLASSES_ROOT\Directory\shell\openwemacs\command] @="C:\\Program Files (x86)\\Emacs\\bin\\emacsclientw.exe --alternate-editor=\"C:\\Program Files (x86)\\Emacs\\bin\\runemacs.exe\" -n \"%1\""
如果你没有注册的注册表,你可以从Windows资源管理器(任何编辑器,而不仅仅是Emacs的说明)做到这一点:
打开Windows资源管理器并选择Tools\Folder Options...
菜单项。
单击File Types
选项卡,然后选择要与编辑器关联的File Types
的扩展名。 对于这个例子,我将使用TXT扩展。
单击详细信息框中的Advanced
按钮以显示Edit File Type
对话框。
您可以更改当前open
操作,也可以指定一个新的操作,如Open with MyEditor
。
如果选择编辑,请单击Edit...
按钮,然后在Application used to peform action
文本框的Application used to peform action
,将完整路径放到编辑器中,然后放入"%1"
。 例如, C:\SciTe\wscite\SciTE.exe "%1"
。
如果你想创建一个新的动作,点击New...
按钮,给动作一个名字,给你的编辑器提供完整的路径,然后是"%1"
。
如果您要将某个操作设置为该文件类型的默认设置,请选择操作,然后单击“ Set Default
按钮。
没有任何对话框。
另一种选择是在Send To
文件夹%USERSPROFILE%\SendTo
放入编辑器可执行文件的快捷方式。 我通常在这里创建一个名为“编辑器”的新文件夹,并将快捷方式放到我使用的各种编辑器中。
除此之外,还可以通过单击背景来打开emacs中的当前目录。
<<<Code as posted by polyglot>>> [HKEY_CLASSES_ROOT\Directory\Background\shell\openwemacs] @="Open &with Emacs" [HKEY_CLASSES_ROOT\Directory\Background\shell\openwemacs\command] @="C:\\Program Files\\emacs-24.2\\bin\\runemacs.exe \"%V\""
这里%V
是当前目录。 在这种情况下使用%1
不起作用。
这个网站解释了如何与另一个应用程序。 只要改变路径,你应该全部设置。
创建这个键/值:
[HKEY_CLASSES_ROOT\*\shell\Edit with AppName\command] @=”\”C:\\Program Files\\Notepad2\\Notepad2.exe\” \”%1\”"
这是另一个参考 ,这是一个更容易遵循。
查看与Windows集成的Emacs发行版: http : //ourcomments.org/Emacs/EmacsW32.html
它的安装程序创建一个资源管理器菜单条目,它可以做你想要的
这是另一种做同样的事情的方法。 适用于WinXP和Vista。
将此添加到您的注册表中:
编辑与- emacs.reg
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Emacs] @="Edit With &Emacs" [HKEY_CLASSES_ROOT\*\shell\Emacs\command] @="Wscript.exe C:\\emacs\\emacs-22.3\\bin\\launch-emacs-client.vbs \"%1\""
把这个文件放在你的emacs bin目录下:
推出-的Emacs client.vbs
Set objShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") If WScript.Arguments.Count = 1 Then strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_Process") Dim isRunning isRunning = False For Each objItem in colItems If InStr(objItem.CommandLine, "emacs.exe") Then isRunning = True End If Next If isRunning Then objShell.Run(fso.GetParentFolderName(WScript.ScriptFullName) & "/emacsclientw.exe -n """ & WScript.Arguments(0) & """") Else objShell.Run(fso.GetParentFolderName(WScript.ScriptFullName) & "/runemacs.exe """ & WScript.Arguments(0) & """") End If Else objShell.Run(fso.GetParentFolderName(WScript.ScriptFullName) & "/runemacs.exe") End If
注意: W32安装程序在安装时运行类似的脚本。
我想添加到上面的polyglot的答案 – 他提到的AutoHotkey快捷方式非常方便,但代码是不完整的:GetText()函数是由某人在AutoHotkey论坛( http://www.autohotkey.com/forum /viewtopic.php?p=279576#279576 ),它是:
GetText(ByRef MyText = "") { SavedClip := ClipboardAll Clipboard = Send ^c ClipWait 0.1 If ERRORLEVEL { Clipboard := SavedClip MyText = ERRORLEVEL := 1 Return } MyText := Clipboard Clipboard := SavedClip Return MyText } ;to test: #k:: GetText(FileName) msgbox clipboard=%FileName% return
请注意,ClipWait延迟可能需要修改:我必须将其设置为2!