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

Windows 如何创建右键单击上下文shell快捷方式“;用Emacs“编辑?”;?,windows,emacs,windows-shell,windows-explorer,Windows,Emacs,Windows Shell,Windows Explorer,Notepad++会自动添加一个shell快捷方式,这样当您在Windows资源管理器中时,可以右键单击文件并选择“使用Notepad++编辑”。如何对emacs执行相同的操作?我正在使用GNU Emacs 22.3 for Windows。解释了如何使用其他应用程序。只要改变路径,你就应该准备好了 创建此键/值: [HKEY_CLASSES_ROOT\*\shell\Edit with AppName\command] @=”\”C:\\Program Files\\Notepad2\\Not

Notepad++会自动添加一个shell快捷方式,这样当您在Windows资源管理器中时,可以右键单击文件并选择“使用Notepad++编辑”。如何对emacs执行相同的操作?我正在使用GNU Emacs 22.3 for Windows。

解释了如何使用其他应用程序。只要改变路径,你就应该准备好了

创建此键/值:

[HKEY_CLASSES_ROOT\*\shell\Edit with AppName\command]
@=”\”C:\\Program Files\\Notepad2\\Notepad2.exe\” \”%1\”"

下面是一个更容易理解的示例。

如果您不想探索注册表,可以在Windows资源管理器中执行此操作(适用于任何编辑器的说明,而不仅仅是Emacs):

  • 打开Windows资源管理器并选择
    Tools\Folder Options…
    菜单项

  • 单击
    文件类型
    选项卡,并为要与编辑器关联的文件类型选择扩展名。对于本例,我将使用TXT扩展名

  • 单击详细信息框中的
    Advanced
    按钮,打开
    编辑文件类型
    对话框

  • 您可以更改当前的
    open
    操作,或者指定一个新操作,如
    openwithmyeditor

    如果您选择编辑,请单击
    编辑…
    按钮,然后在用于编辑操作的
    应用程序中的
    文本框中,将完整路径放入编辑器,然后是
    “%1”
    。例如,
    C:\SciTe\wscite\SciTe.exe“%1”

    如果要创建新操作,请单击
    new…
    按钮,为该操作命名,并提供编辑器的完整路径,然后单击
    “%1”

  • 如果要使某个操作成为该文件类型的默认操作,请选择该操作,然后单击
    Set default
    按钮

  • OK
    退出所有对话框


  • 另一个选项是在
    发送到
    文件夹,
    %USERSPROFILE%\SendTo
    中放置编辑器可执行文件的快捷方式。我通常在这里创建一个名为“编辑器”的新文件夹,并为我使用的各种编辑器设置快捷方式。

    以下是我的答案-类似于其他答案。在名为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的上下文菜单中输入任何文件和目录(如果您是一个dired fan!)

    请注意,要使其工作,必须启动emacs,并且还必须启动emacs服务器(M-x服务器启动)。我建议用Windows启动emacs,并将(服务器启动)放在.emacs文件中

    另外,当您在windows资源管理器中按ctrl-shift-enter键时,autohotkey()的以下代码段将启动在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集成的Emacs发行版:


    它的安装程序创建一个资源管理器菜单项,它可以满足您的需要。

    下面是另一种方法。在WinXP和Vista中工作

    将此项添加到您的注册表:

    编辑-with-emacs.reg

    将此文件放在emacs bin目录中:

    launch-emacs-client.vbs


    注意:安装时运行类似的脚本。

    我想添加到上面polyglot的答案中——他提到的自动热键快捷方式非常方便,但代码不完整:GetText()函数是由自动热键论坛()上的某个人编写的,它是:

    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

    就像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\""
    

    只需添加一点,也可以通过单击后台打开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\""
    
    
    [HKEY\U CLASSES\U ROOT\Directory\Background\shell\openwemacs]
    @=“打开并使用Emacs”
    [HKEY\U CLASSES\U ROOT\Directory\Background\shell\openwemacs\command]
    @=“C:\\Program Files\\emacs-24.2\\bin\\runemacs.exe\%V”
    

    此处
    %V
    是当前目录。在这种情况下,使用
    %1
    不起作用。

    想要(主要是)鼠标驱动的方法来启动键盘密集型编辑器似乎很奇怪!你不用控制台吗?不用。良好的生产力来自键盘和鼠标的正确混合。能够从Windows资源管理器启动Emacs对许多人都很有用。您可能希望将%1替换为%L,否则Windows将为Emacs提供文件的短名称。看看这个问题:答案很好!然而,一些Emacs专家能否更进一步,展示如何在Emacs中构建和执行.reg文件,包括Emacs本身的绝对路径?我还是个新手,但我打赌Emacs专业版可以让这一切变得非常简单。我说过我有多喜欢Emacs吗?同样值得一提的是,您可能需要重新启动或停止/重新启动explorer.exe,如本文所述。如果您想在路径中包含环境变量(如
    %HOME%
    ),注册表项的类型必须是
    REG\u EXPAND\u SZ
    ,而不是
    REG\u SZ
    。这在Windows 10中对任何人都有效吗?(对我来说,它不是)您也可以通过添加行
    “icon”=“C:\\Program Files(x86)\\Emacs\\bin\\emacsclientw.exe”
    来指定图标,该行正好位于带
    @=“Edit&with Emacs”
    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\""
    
    <<<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\""