How to create a right-click context shell shortcut “edit with Emacs”?

前端 未结 8 816
离开以前
离开以前 2021-01-30 11:22

Notepad++ automatically adds a shell shortcut so that when you\'re in Windows Explorer, you can right-click on a file and select \"edit with Notepad++\". How can I do the same w

相关标签:
8条回答
  • 2021-01-30 12:17

    Just like polyglot's answer, but no need to start a server or any of that mess.

    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\""
    
    0 讨论(0)
  • 2021-01-30 12:19

    Here's what I have - similar to some other answer. Create a new text file somewhere called emacs-conextmenu.reg (or anything-you-want.reg) and paste the following in:

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

    Change the path to your emacs installation path; remember to escape the "\" (whenever you have \, change that to \\).

    Now all you need to do is double-click this *.reg file in the explorer and you shall have a context menu entry for emacs for any file and any directory (if you are a dired fan!).

    Note that for this to work, emacs has to be started and emacs-server also has to be started (M-x server-start). I would suggest starting emacs with Windows and put (server-start) in your .emacs file.

    As a bonus, the following snippet for autohotkey (http://www.autohotkey.com/) will start the file selected in emacs when you press ctrl-shift-enter in windows explorer. This might be more handy if you edit lots of files in emacs but does not necessarily want to navigate to the file in emacs itself.

    #IfWinActive ahk_class CabinetWClass 
    ^+Enter::
      GetText(tmpvar)
      If (tmpvar != "")
         Run, d:/path/to/your/emacs/bin/dir/emacsclientw.exe -n "%tmpvar%"
    Return
    Return
    
    0 讨论(0)
提交回复
热议问题