Karl Martino, Updated: 10/06/2002
Emacs is my favorite text editor. It was originally written by Richard Stallman way back in 1975. Thousands upon thousands use it everyday as a practical Swiss army knife. Editting text, source code, HTML, reading e-mail, managing files, and more. It’s learning curve can be steep, but there is a huge reward in productivity.
This is for Windows users. If you are running Linux or any other variant of Unix for that matter, including Mac OS-X, Emacs is already installed. You can thumb your noses at us now.
Set up your environment
This follows personal conventions I use on Windows systems.
- Create the directory d:\home. This is your new Home directory. Many Unix based applications utilize the Home directory to store user preferences, libraries, extensions, and personal files. Windows has it’s own scheme for this, and counting upon the variant you are using, you can find your Windows Home directory in many different places. The less you need to interact with Windows managed directories the better, so here we are creating our own. When using Emacs, or most Unix based tools, you will be able to refer to this directory with the shortcut “~/”.
- Create the directory d:\home\emacs. This is where you will install various optional Emacs libraries.
- Create the directory d:\usr\local. This is where you will install Unix derived applications. I locate any application that doesn’t utilize it’s own installation routine here. Makes maintenance easier.
- Create the directory d:\usr\bin. This is where you will install batch files and executables that you will need to run from the command line.
- Create the directory d:\home\projects. This is where you will create subdirectories for each development project you are working on. If you’re not a developer, you can skip this step.
- You should have an up-to-date startup disk, including a copy of Autoexec.bat, in case things go wrong. For Windows 98 and 95 you will need to edit autoexec.bat to create an environment variable for your Home directory and to add d:\usr\bin to your path. Click “Start”, then “Run”, type “sysedit”, hit [Enter]. Add to the bottom of autoexec.bat:
SET HOME=d:\home SET PATH=%PATH%;D:\usr\bin
Save and exit. Restart your computer. If all is not well, you have probably damaged your autoexec.bat some way. Hope you had your startup disk.
- Having a less hyperactive and more informative My Computer is useful. For Windows 98, open "My Computer". In the menu make sure under "View" | "Toolbars" that "Address Bar" is checked. In the "View" | "Folder Options..." dialog box click "Custom, based upon the settings you choose:" and click "Settings...". Choose "Open each folder in same window". Click "OK". Click the "View" tab. Check "Display the full path in the title bar", expand "Hidden Files" and choose "Show all files", and uncheck "Hide file extensions of known file types". Click "OK".
- Download Emacs. Browse this address, and download the file whose name contains the latest version, "fullbin", and "i386". For example: emacs-21.2-fullbin-i386.tar.gz. Save this in a place where you can find it on your file system.
- Browse to the file using "My Computer". Double click the file. If you have WinZip installed, it will start and show you a dialog box to confirm decompressing the file to a temporary folder and opening it. Click "Yes".
- Now you should be in WinZip and it's showing you the contents of the archive. Click the "Extract" button in the toolbar. In the dialog box that comes up, make sure "Overwrite existing files" and "Use folder names" are checked. Choose d:\usr\local\ in the "Extract to" field. The dialog allows you to browse your file system to it. Click "Extract". Exit WinZip.
- You can delete the archive now, but my preference is to save it in a folder for later use in case I need to reinstall.
- Browse to d:\usr\local\. Extracting the archive above created a folder here. It probably looks like "Emacs-21.2" or something like that. Click into it and click into the "bin" folder. Copy the address in the address bar to the clipboard [CTRL+C].
- See note about editting autoexec.bat above! Open sysedit. Go to the bottom of autoexec.bat. Add a new line. Type "SET PATH=%PATH%;" and paste the directory path you just copied in the previous step [CTRL+V]. It should look something like this:
Save and exit.
- Restart your computer and cross your fingers. If all has gone well, you will have restarted. If not, you probably have messed up your autoexec.bat. Good luck to ya if that's the case. Otherwise....
- Use "My Computer" and navigate to "D:\usr\local\[emacs dir]\bin\". Double click "addpm.exe". You will get a dialog box asking you is it ok to install Emacs to a directory. Click "OK". You can close the window that results. Now you can start Emacs by clicking "Start" | "Programs" | "Gnu Emacs" | "Emacs". You can also start Emacs by starting a DOS prompt and typing "Emacs" [Enter].
- Welcome to Emacs. Ugly isn't it? You can change that.
Nothing is better then taking the Emacs tutorial provided in its Help menu. This EmacsWiki Category will point you in the right direction if you need more.
Emacs is easy to customize for your taste. It's so easy that once I sat down in front of someone else's PC and was confused as to how Emacs worked on it - and a bit blinded by the syntax highlighting. You can customize everything.
The primary method is to create and then modify a file in your Home directory named ".emacs". Yes Windows users, it's name looks just like a file extention without the file name. This naming convention, a file name prefixed with a ".", is used on Unix systems to hide files from casual directory browsing.
You can find my commented ".emacs" file here. Right click, choose "Save Target As...", choose your Home directory, and rename the file to ".emacs".
Install the HTML Helper Mode for editting HTML source, and languages like JSP and PHP. Download "html-helper-mode.tar.gz" from the site and extract the contents of the archive to your d:\home\emacs\ directory. Edit your ".emacs" file and add:
(setq load-path (cons "~/emacs/" load-path)) (require 'html-helper-mode)
Save, exit, restart and you should be ready to go. I have a bit more in my own .emacs to configure the mode to start automatically upon opening JSP and SHTML files.
Configure SQL mode and Emacs will work as a front end to various database platforms. Very handy.
The Java Development Environment for Emacs turns Emacs into a full blown IDE for Java.
Emacs Bookmarks are a big time saver.
Setting up printing on Windows is a little complicated.
Compile libraries example:
% cd /path/to/cc-mode % $(EMACS) -batch -q -f batch-byte-compile cc-*.el
Function definition example:
(defun publish-file () "publish file" (interactive) (shell-command (concat "c:/perl/scripts/EmacsPublish.pl" buffer-file-name)))
Key mapping examples:
(global-set-key "C-xC-p" 'publish-file) (global-set-key [f7] 'start-kbd-macro)
GNU Emacs FAQ for Windows NT and Windows 95/98
The starting point for Windows users.
Sams Teach Yourself Emacs in 24 Hours
The whole book online.
A great place to go for Emacs customization.
An excellent growing resource.
Installing NT Emacs
A good reference for getting started.
The worldwide Lisp archive
Command prompt replacement for Windows 95/98/NT/2000.
Why I became an Emacs user
Big geeky essay.