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
Here's is another way to do the same thing. Works in WinXP and Vista.
Add this to your registery:
edit-with-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\""
Place this file in your emacs bin directory:
launch-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
Note: the W32 installer runs a similar script on installation.
With a little addition, also opening the current directory in emacs by clicking on the background becomes possible.
<<<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\""
Here %V
is the current directory. Using %1
doesn't work in this case.
Check out an Emacs distribution with Windows integration: http://ourcomments.org/Emacs/EmacsW32.html
Its installer creates an Explorer menu entry which does what you want.
If you're not up for spelunking the registry, you can do this from the Windows Explorer (instructions for any editor, not just Emacs):
Open the Windows Explorer and select the Tools\Folder Options...
menu item.
Click on the File Types
tab and select the extension for the type of file you want to associate with your editor. For this example, I'll use the TXT extension.
Click the Advanced
button in the details frame to bring up the Edit File Type
dialog.
You can either change the current open
action, or specify a new action like Open with MyEditor
.
If you choose to edit, click the Edit...
button and in the Application used to peform action
textbox, put the full path to your editor, followed by "%1"
. For example, C:\SciTe\wscite\SciTE.exe "%1"
.
If you want to create a new action, click the New...
button, give the action a name, and give the full path to your editor, followed by "%1"
.
If you want to make an action the default for that file type, select the action, then click the Set Default
button.
OK
out of all dialogs.
Another option would be to put a shortcut to your editor's executable in your Send To
folder, %USERSPROFILE%\SendTo
. I usually create a new folder in here called "Editors" and put shortcuts to the various editors I use.
This site explains how to do it with another app. Just change the path and you should be all set.
Create this key/value:
[HKEY_CLASSES_ROOT\*\shell\Edit with AppName\command]
@=”\”C:\\Program Files\\Notepad2\\Notepad2.exe\” \”%1\”"
Here's another reference, which is a little easier to follow.
I want to add to polyglot's answer above -- the AutoHotkey shortcut he mentions is very handy, but the code is incomplete: the GetText() function was written by somebody on the AutoHotkey forum (http://www.autohotkey.com/forum/viewtopic.php?p=279576#279576), and it is:
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
Note that ClipWait delay might need to be modified: I had to set it to 2!