SiteMap Search ElispArea HowTo Glossary RecentChanges News Problems Suggestions
Yemen, National Day

EmacsMsWindowsIntegration

This page is about different ways to integrate Emacs into MS Windows:

Run Emacs from a `cmd' Window

Put the Emacs ‘bin’ folder in the Windows PATH environment variable (right-click Computer, Properties, Advanced, Environment Variables). This also simplifies other methods mentioned on this page (no explicit paths needed then).

Use a Shortcut

Use this code for a desktop/task-bar shortcut:

emacsclientw.exe -na runemacs.exe -c ""

This shortcut starts Emacs from scratch if it’s not running, and opens a new frame if it is.

The -c is key: without it, you have to pass a file to open (even if it’s "", which does work but is uglier) or else emacsclient will exit with an error. (Right-click on desktop, New Shortcut, etc., then drag the shortcut into the Quick-Launch bar if you want.)

  -n means no wait - don't wait for the server to return
  -a EDITOR specifies to the emacsclientw.exe which editor to run if emacs.exe is not already running
  -c tells emacs to create a new frame instead of trying to use the existing frame

Milouse, 2013/03/08: on Windows XP and Gnu/Emacs 24.2, I have to use the following shortcut to have things working as expected with a non integrated Emacs (just unziped version somewhere in my computer) :

C:\Path\To\emacsclientw.exe --alternate-editor="C:\Path\To\runemacs.exe" -c

And, more important thing: you have to put the (server-start) declaration in your init.el file, otherwise the shortcut will keep creating new and disconnected instance of emacs.

Create File Associations

Use Windows command-line commands ‘ftype’ and ‘assoc’:

    ftype txtfile=emacsclientw -na runemacs "%1"
    ftype EmacsLisp=emacsclientw -na runemacs "%1"
    ftype CodeFile=emacsclientw -na runemacs "%1"
    assoc .txt=txtfile
    assoc .text=txtfile
    assoc .log=txtfile
    assoc .el=EmacsLisp
    assoc .c=CodeFile
    assoc .h=CodeFile

Set `emacsclient' as Your Editor

This almost works:

  git config --global core.editor "emacsclient -a runemacs '%*'"

If Emacs is not already running then it starts Emacs OK, but it returns right away – doesn’t wait. So the git commit fails (because the default message is unchanged).

Anyone know how to make emacsclient wait in the case where it has to start the alternate editor? (Do not use emacsclientw here; it doesn’t wait.)


CategoryWThirtyTwo