Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .