MsWindowsGlobalContextMenu

Last edit

Summary: Added context menu icon

Added:

> "Icon"="C:\\Program Files\\Emacs\\bin\\emacs.exe,0"
> # The above uses the icon of the Emacs exe for the context
> # and should match the path used for the command below.
> # The ,0 selects the main icon.


Starting Emacs From Global Context Menu

Here is a simple but useful way to access Emacs. It adds the option to open a file in Emacs to your global context menu (i.e., right clicking on a file). This runs a new Emacs instance for each file. (Note: not the “Open With” submenu, but the top level context menu.)

This has been tested under WinXP.

Create a file named global_context_emacs.reg:

REGEDIT4
[HKEY_CLASSES_ROOT\*\shell]

[HKEY_CLASSES_ROOT\*\shell\openwemacs]
@="&GNU Emacs"
# The above value appears in the global context menu, 
# i.e., when you right click on a file.
# (The '&' makes the next character a shortcut.)
"Icon"="C:\\Program Files\\Emacs\\bin\\emacs.exe,0"
# The above uses the icon of the Emacs exe for the context
# and should match the path used for the command below.
# The ,0 selects the main icon.

[HKEY_CLASSES_ROOT\*\shell\openwemacs\command]
@="C:\\Program Files\\Emacs\\bin\\runemacs.exe \"%1\""
# The above has to point to where you install Emacs

Obviously, the command in the last line here has to point to where you install Emacs. For example, I think the distribution zip file normally unpacks to a folder named “emacs22” or something like that. I renamed this to “Emacs”.

Double click this file to load its entries into the registry. You can use regedit to check if they are there, or remove them later.

For more elaborate context menu stuff, including opening successive files in the same Emacs instance, see EmacsClient. Note that I’ve used the same registry key names as on that page, so, if you load one of those files, it will replace this version (which is probably what you want).

thundt


I was able to get EmacsClient to open the file with EmacsW32 fairly trivially. Here is my change to thundt’s registry entry. Unless you installed EmacsW32 in a weird place, this should work out of the box:

REGEDIT4
[HKEY_CLASSES_ROOT\*\shell]

[HKEY_CLASSES_ROOT\*\shell\openwemacs]
@="&GNU Emacs"
# The above value appears in the global context menu, 
# i.e., when you right click on a file.
# (The '&' makes the next character a shortcut.)

[HKEY_CLASSES_ROOT\*\shell\openwemacs\command]
@="C:\\Program Files\\Emacs\\emacs\\bin\\emacsclientw -n \"%1\""
# The above has to point to where you install Emacs

JonathanArkell

Thanks for this Jonathan and thundt. I might steal it later, but there is already a rather similar entry in EmacsW32 in the Send To submenu.

Might I suggest using the following command with 22.3:

 C:\emacs-22.3\bin\emacsclientw -n --a C:\emacs-22.3\bin\runemacs.exe "%1" 

Also there is no pop up cmd window any longer.