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 with emacs? I am using GNU Emacs 22.3 for Windows.
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
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\""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With