Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to have emacs registered with file extensions on windows, but only one emacs instance should be open, even if I open several files through their extensions.

I have installed emacs from emacs-22.3-bin-i386.zip by unpacking to c:\bin\emacs on a windows server 2003 system (32 bit)

I created a script c:\bin\emacs\bin\emacs-filetarget.cmd

@echo off
"%~dp0emacsclientw.exe" -na "%~dp0runemacs.exe" "%1"

When I open the first file *.el with c:\bin\emacs\bin\emacs-filetarget.cmd it gets opened in a new emacs instance which is fine.

But the second file *.el gets opened in a second emacs instance. I am looking for a way to have only one emacs instance where all subsequent files are opened.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

You need to make sure the emacs server is started. Add the following to your .emacs file:

(server-start)

And then always use emacsclientw.exe to start emacs.

For reference, I use an emacs.cmd file which looks like this:

@echo off
if "%1"=="" goto nofile

start "" "c:\emacs\bin\emacsclientw.exe" -n %*
goto end

:nofile
start "" "c:\emacs\bin\runemacs.exe

:end

The "runemacs" instance is because emacsclientw requires that you specify a filename.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.