Making GNU Emacs play well on Microsoft Windows 7

Emacs 24 has been released, hooray! Here’s how you can download and install it on Windows 7. Bonus tip: pin it to your taskbar so that you can open Emacs easily.

Step 1. Get the Emacs zip file from http://ftp.gnu.org/pub/gnu/emacs/windows/ . You’re looking for something like emacs-24.1-bin-i386.zip, or whatever the latest version is. Download and extract the files. I like extracting it to C:\ and renaming the new emacs-24.1 directory to c:\emacs so that I can get to it easily. I’ll assume you’re renaming it too, but if you prefer to keep your Emacs installation elsewhere, just translate the rest of these instructions.

Step 2. Add Emacs to your path. This way, you can start Emacs or emacsclient from anywhere. To change your system path, click on the Windows logo, right-click on Computer, and choose Properties. Click on Advanced system settings, then click on Environment Variables.

If you see a Path variable under User variables, click on it, then click on Edit. Add c:\emacs\bin to the beginning of this path, separating it from the next item with a semicolon. Click OK.

On the other hand, if you don’t see a Path variable under User variables, click on New and add it. The variable name should be Path and the value should be c:\emacs\bin. Click OK.

Step 3. While you’re here, you might as well set your Home variable. This is what Emacs will use whenever you refer to ~, or the home directory. To set that, look under User variables and click on New. Create a variable called HOME, and set the value to whichever directory you would like to use as your home directory. For example, I’ll set mine to c:\sacha. Again, click on OK, then click OK a few more times until you’re done with the System Properties dialog box.

Step 4. All right, let’s start up Emacs! Click on the Windows icon, and type runemacs at the Run prompt. You should see runemacs in the list. If you don’t, you may need to log out and log in so that your new path settings are applied. Once you’ve sorted that out, start runemacs. You should see Emacs open, yay!

Step 5. Want to be able to start up and switch to Emacs quickly? To pin Emacs to your task bar, right-click on the Emacs icon in the task bar. Right-click on the small Emacs icon that appears, and click on Properties. Change the target to c:\emacs\bin\runemacs.exe, and change the start directory to whichever directory you prefer. You can also choose to start it maximized – handy. Once you’ve set that up, click OK. I like dragging the Emacs icon so that it’s the very first item in my task bar. That way, pressing the Windows key and the number 1 at the same time lets me switch to Emacs and away from Emacs easily.

That’s it. Check out http://planet.emacsen.org for lots of other Emacs bloggers. Happy editing!

One Pingback/Trackback

10 responses to “Making GNU Emacs play well on Microsoft Windows 7”

  1. Ronnie Holm says:

    One possible issue with Step 3 and 4 is that HOME is now set for any application. Depending on which other Unix-type applications you’re running, this can be an annoyance. What I do instead is create a shortcut with this destination:

    C:\Windows\System32\cmd.exe /C “set HOME=E:\Shared\Software\emacs-24.1&&E:\Shared\Software\emacs-24.1\bin\runemacs.exe”

    I’ve described this in a bit more detail here, together with my simple .emacs file:

    http://www.bugfree.dk/blog/2010/04/15/configuring-emacs-through-emacs-lisp/

  2. Sacha Chua says:

    Ronnie: Thanks for sharing that! Handy tip.

  3. I plan to upgrade on July 2, but I’ve already downloaded the binary.

    Step 2 (modifying PATH) isn’t necessary if you use only shortcuts to invoke Emacs.

    I was going to ask how you use Tag completion in Org. But I just figured it out. By default the keystroke is M-. But as this is the key Windows uses to switch applications, it’s not available to us. Instead, Emacs will accept C-i for , so C-M-i works.

  4. Ciaran Mulloy says:

    Many thanks for the useful information provided in the above article.

    I am trying to work out to replicate the ease of working in Windows (from time to time) that I enjoy in Linux.

    On installing the zip file in your chosen windows folder if you execute the program ‘addpm’ which is located in the ‘bin’ subdirectory of the emacs-24.1 folder this will then add the emacs icon into the program listing (creates a folder called Gnu Emacs containing the Emacs executable). It’s then possible to right click on the executable icon and pin it to task bar or start menu as required.

  5. Abhishek L says:

    I have most of this set, except for step2 on setting %HOME%. Here I use site-start.el to setenv HOME to a location like /home the advantage being that this thing can be conveniently carried in a usb stick without having to worry about Home environments elsewhere. However tramp seems to somehow expand remote filenames to user@localhost:C:/ , though it works perfectly out of the box if HOME is not set though.

  6. Mark Lewin says:

    Great to see someone posting about Emacs under Windows. In case it helps anyone, I was unable to get the emacs Window to maximize until I put this in my .emacs file:

    ;; Maximizes Emacs in Windows
    (w32-send-sys-command #xf030)

    1. sachac says:

      Yeah, Windows gets no love… <laugh>

      Ooh, that’s great. Thanks for sharing! =) It turns out there are more w32 sys commands on EmacsWiki – hmm, interesting…

  7. Darren Irvine says:

    Thanks for the start.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>