================================== Setting up Emacs on Windows or Mac ================================== Emacs is the preferred Lisp source code editor for most CL developers; however, it is not easy for an Emacs neophyte to get an Emacs environment set up and configured properly for Lisp development. The problem is compounded if the development platform is Microsoft Windows since Unix (and variants) is the more common platform used by experienced Lisp developers. In order to help a Lisp beginner set up an Emacs Common Lisp development environment on a Microsoft Windows PC, this chapter will lay out step-by-step instructions for installing all the necessary components for each of the most popular Common Lisp implementations on Windows: - **Allegro Common Lisp (ACL):** Franz's own "ELI" will be used in Emacs. - **CLISP:** ILISP and Emacs Inferior Lisp Mode will be two alternative environments that can be used with CLISP. - **Corman Common Lisp:** The Emacs Inferior Lisp Mode will be used. - **LispWorks:** ILISP will be used in Emacs to provide the development environment (Note: the trial version of the product doesn't provide a non-gui Lisp image and this is necessary if the product is to be used with Emacs). By exactly following the installation instructions, the user will wind up with an Emacs setup that: - Allows the user to trial the most popular Lisp implementations for Windows. - Allows the user to try out 3 different techniques (ILISP, ELI, inferior-lisp mode) for establishing a Lisp development environment in Emacs - each with its own sets of pluses and minuses. - Configures Emacs so that it has keystroke bindings more similar to what a Windows user is accustomed to. - Configures Emacs with a number of custom configuration settings that are commonly used. | There is also a short appendix describing the sample .emacs file and brief Mac OS X setup instructions: | A. `Sample .emacs file <#Sample%20.emacs%20file>`__ | B. `Mac OS X Setup Instructions <#Mac%20OS%20X%20Setup%20Instructions>`__ For each installation, an installation directory is suggested. It is recommended that you install in the suggested directory since, if you use the suggested directory names, the provided Emacs start-up file (.emacs) will work "out-of-the-box". Please note the following: - If you use alternative directory names, you will need to modify the .emacs file (instructions provided in step #8). - The instructions assume you are using Winzip; however, you can use any alternative utility. - When you unpack .gz files with Winzip, it will ask you "Should WinZip decompress it to a temporary folder and open it?" - click on "No". When you unzip any files, you should ensure that "All files" radio button is selected and the "Use folder names" check box is ticked. - There are instructions for downloading all the implementations; however, it is not necessary to do so. You should complete step #1 (Read through step #2 to determine whether you want/need any of the optional Emacs utilities covered in this section. Step #3 is required if you want local access to the Common Lisp documentation. If you don't want/need the documentation, this step is optional as well.) and the relevant parts of #8 & #9 (regardless of which implementations you download) and you will need to download at least one of #4 - #7. You can download multiple implementations if you want to trial them. 1. Installing Emacs ~~~~~~~~~~~~~~~~~~~ - From a command line, create the following directories (used later): .. raw:: html
md c:\home\ md c:\home\site\ md c:\home\docs\ md c:\home\lisp\ md c:\home\info\ md c:\bin\- Download the precompiled `Emacs
* ANSI-CL: (gcl). ANSI Common Lisp Manual.4. Installing CLISP (optional) ------------------------------ - Download the precompiled `CLISP
(progn
(build-lisp-image "alisp.dxl" :case-mode :case-insensitive-upper
:include-ide nil :restart-app-function nil)
(sys:copy-file "sys:allegro-ansi.exe" "sys:alisp.exe"))
- A non-IDE Lisp image & exe (alisp.exe) will be created in the ACL
directory to be used with Emacs. Exit the ACL IDE.
- OPTIONAL: Download the `Franz
documentation
(load-all-patches)
(save-image "lw42-console" :console t :environment nil)
(quit)
- Go to a dos command line and enter the following commands to create
the non-gui console version of the LispWorks executable:
.. raw:: html
cd c:\bin\lispworks-4.2 lispworks-4200 -init c:\home\lisp\console.lispThis will result in the lw42-console.exe file being created in the c:\\bin\\lispworks-4.2 directory. 7. Installing Corman CL ----------------------- - Download the precompiled binaries for `Corman Lisp
(setf (current-directory) *cormanlisp-directory*)
8. Configuration steps
----------------------
- Setup environmental variables either in the autoexec.bat file (e.g. -
Windows/98) or the Control Panel/System (e.g. - Windows/NT/2000/XP):
- HOME: Should be set to c:/home (Note: use "/" rather than "". Note
also that you should make certain that you don't have both a User
and a System HOME variable set up when setting up the HOME
environmental variable under Windows/NT/2000/XP. If you do, the
User variable will override the System one. Delete one of the two
(better to leave the system one if you want multiple login users
to use your same emacs configuration) and make certain that it is
set to the c:\\home directory.).
- EMACSDIR: Should be set to c:\\bin\\emacs-21.3
- PATH: The c:\\bin\\emacs-21.3\\bin directory path should be
prepended to the existing PATH to ensure that the Emacs executable
can be found (e.g. -- set path=c:\\bin\\emacs-21.3\\bin;%path%).
- If the specified directory locations were used, no changes to the
.emacs file should be necessary. If file locations were changed, the
directory locations that are specified in the first section of the
.emacs file (the "Site-Specific Variables" section) should be
modified with the correct directory locations (Note: when specifying
directory locations in the .emacs file, use "/" rather than "" as the
directory separator character).
- If not all the Lisp implementations were downloaded, the .emacs file
will still work "as is". If you did download multiple installations,
you will probably want to change the lisp-used variable (default
value is the first lisp implementation in the list of lisp
implementations that you installed) to default to the main lisp
implementation that you will be using (you don't have to change it,
you can still toggle to the other lisp implementations using
"C-M-F5").
- Reboot the PC after making the above changes and configuration
settings.
- Start Emacs (either by using the Start menu's Gnu Emacs shortcut or
by using Run on the Windows Start menu with the command
"c:\\emacs\\bin\\runemacs.exe") and do the following:
- If you installed the cua.el utility:
- Double-click on the "site" directory to drill down into that
directory.
- Compile the cua.el file by pressing "B" when the cursor is on
the file name in the dired window (answer "y" to the
"Byte-Compile (y or n)" prompt).
- If you installed the cua-emul.el utility:
- Double-click on the "site" directory to drill down into that
directory.
- Compile the cua-emul.el file by pressing "B" when the cursor is
on the file name in the dired window (answer "y" to the
"Byte-Compile (y or n)" prompt).
- If you installed the color-theme.el utility:
- Double-click on the "site" directory to drill down into that
directory.
- Compile the color-theme.el file by pressing "B" when the cursor
is on the file name in the dired window (answer "y" to the
"Byte-Compile (y or n)" prompt).
- If you installed CLISP and ILISP, do the following:
- Press "C-M-F5" until the minibuffer window at the bottom says
"lisp-used: :clisp-ilisp" indicating that you have toggled to
CLISP mode.
- Start CLISP by pressing "F5".
- After starting ILISP/CLISP in Emacs, use "M-x
ilisp-compile-inits" to compile the CLISP Lisp initialization
files. When finished, press "F4" to close the *clisp-hs*
window.
- If you installed Lispworks and ILISP, do the following:
- Press "C-M-F5" until the minibuffer window at the bottom says
"lisp-used: :lw-ilisp" indicating that you have toggled to
LispWorks mode.
- Start LispWorks by pressing "F5".
- After starting ILISP/CLISP in Emacs, use "M-x
ilisp-compile-inits" to compile the LispWorks Lisp
initialization files. When finished, press "F4" to close the
window.
- All configuration steps should now be complete - exit Emacs by
pressing "C-x C-c" and pressing "y" when you get the "Do you really
want to exit Emacs ? (y or n)" prompt in the minibuffer.
9. Testing the environments
---------------------------
- Start Emacs (either by using the Start menu's Gnu Emacs shortcut or
by using Run on the Windows Start menu with the command
"c:\\emacs\\bin\\runemacs.exe") and do the following:
- If you installed CLISP, do the following:
- Click in the dired window and press "C-M-F5" until the
minibuffer window at the bottom says "lisp-used: :clisp-ilisp"
indicating that you have toggled to CLISP mode).
- Test that CLISP runs by pressing "F5" (CLISP should open in the
bottom window and the ILISP menu should appear in the Emacs
menu bar).
- Click in the *clisp-hs* window and press "C-h b" (this will
show you the keybindings that are in effect for
ILISP/CLISP).
- Click in the *Help* window and scroll through the keybinding
list. When finished, press "F4" to close that window.
- Click in the *clisp-hs* window and press "F4" to close that
window.
- If you installed ACL, do the following:
- Click in the dired window and press "C-M-F5" until the
minibuffer window at the bottom says "lisp-used: :acl-eli"
indicating that you have toggled to ACL mode).
- Test that ACL runs by pressing "F5". The ACL icon will appear
in the Windows system tray.
- A Listener for ACL should also appear in an Emacs
*common-lisp* buffer and the ACL menus should appear in the
Emacs menu bar.
- Click in the *common-lisp* window and press "C-h b" (this
will show you the keybindings that are in effect for
ELI/ACL).
- Click in the *Help* window and scroll through the keybinding
list. When finished, press "F4" to close that window.
- Click in the *common-lisp* window and select the
ACLFile/Exit Allegro CL menu option (this will close down
the ACL connection and the ACL application will end).
- If you installed LispWorks, do the following:
- Click in the dired window and press "C-M-F5" until the
minibuffer window at the bottom says "lisp-used: :lw-ilisp"
indicating that you have toggled to LispWorks mode).
- Test that LispWorks runs by pressing "F5" (LispWorks should
open in the bottom window and the ILISP menu should appear in
the Emacs menu bar).
- Click in the *lispworks* window and press "C-h b" (this will
show you the keybindings that are in effect for
ILISP/LispWorks).
- Click in the *Help* window and scroll through the keybinding
list. When finished, press "F4" to close that window.
- Click in the *lispworks* window and press "F4" to close that
window.
- If you installed Corman, do the following:
- Click in the dired window and press "M-C-F5" until the
minibuffer window at the bottom says "lisp-used: :corman-inf"
indicating that you have toggled to Corman mode).
- Test that Corman runs by pressing "F5".
- Click in the *inferior-lisp* window and press "C-h b" (this
will show you the keybindings that are in effect for Corman
in Inferior Lisp Mode).
- Click in the *Help* window and scroll through the keybinding
list. When finished, press "F4" to close that window.
- Click in the *inferior-lisp* window and press "F4" to close
that window.
- If you installed the documentation, you can test that the online
documentation works by pressing "F1" (for the HyperSpect) or
"M-F1" (for CLtL2) when the cursor is on a Lisp keyword (e.g. --
"defun" or "setq"). This should bring up a browser with the
documentation for that keyword. See the function key definitions
below for accessing other documentation.
- Exit Emacs by pressing "C-x C-c" and pressing "y" when you get the
"Do you really want to exit Emacs ? (y or n)" prompt in the
minibuffer.
You should now have a working Windows/Emacs setup that supports a number
of different Lisp implementations.
A. Sample .emacs file
---------------------
- Following is a brief explanation of each of the sections of the
sample `.emacs <.emacs>`__ file:
- **Site-Specific Variables:** Contains directory locations for the
different Lisp implementations, Lisp documentation and
Emacs-specific files. It also sets the default Lisp implementation
(Note: if you want to specify a different default Lisp
implementation, change the lisp-used variable to one of
:clisp-ilisp, :clisp-inf, :acl-eli, :lw-ilisp, :corman-inf).
- **Initial Code Load:** Loads Emacs files that are needed later on.
- **System Customizations:** Some standard customizations that make
Emacs easier to use.
- **Programming - Common Lisp:** CL-specific setup.
- **Programming - Elisp:** Emacs Lisp-specific setup.
- **Lisp Key Overrides:** ILISP & ELI have their own key mappings -
here are some extra ones:
- F1 - Brings up the CL Hyperspec (if it was installed)
documentation page for the Lisp symbol under the cursor using
the default browser.
- S-F1 - Brings up the CL Hyperspec (if it was installed)
documentation page for the Lisp symbol under the cursor using
w3 (if it was installed).
- C-u F1 - Brings up the CL Hyperspec (if it was installed)
documentation page for the format character under the cursor
using the default browser.
- C-u S-F1 - Brings up the CL Hyperspec (if it was installed)
documentation page for the format character under the cursor
using w3 (if it was installed).
- C-F1 - Brings up the Franz CL (if it was installed)
documentation page for the Lisp symbol under the cursor using
the default browser.
- C-S-F1 - Brings up the Franz CL (if it was installed)
documentation page for the Lisp symbol under the cursor using
w3 (if it was installed).
- M-F1 - Brings up the CLtL2 (if it was installed) documentation
page for the Lisp symbol under the cursor using the default
browser.
- M-S-F1 - Brings up the CLtL2 (if it was installed)
documentation page for the Lisp symbol under the cursor using
w3 (if it was installed).
- C-M-F1 - Brings up the info (if it was installed) documentation
page for the Lisp symbol under the cursor.
- F5 - Starts the appropriate Lisp mode for the Lisp
implementation that was selected (use C-M-F5 to select the Lisp
implementation before pressing F5 to start it).
- C-M-F5 - Toggles between the different installed Lisp
implementations.
- M-p - For ACL only, in a Lisp listener, retrieves the previous
historical entry (this is already the binding in ILISP).
- M-n - For ACL only, in a Lisp listener, retrieves the next
historical entry (this is already the binding in ILISP).
- C-c d - For ACL only, does a "Do What I Mean" eval/compile (see
function documentation for eli-lisp-eval-or-compile-dwim).
- C-c x - For ACL or the ILISP Lisps, does a "Do What I Mean"
eval/compile (see function documentation for
copy-eval-dwim-lisp).
- C-c e - Prompts for a Lisp form to evaluate.
- C-c ; - Comments out the sexp that the cursor is on (repeated
presses comment outward sexp's). (see function documentation
for insert-balanced-comments).
- C-c : - Uncomments comments that were insered with
insert-balanced-comments (see function documentation for
remove-balanced-comments).
- **Standard Key Overrides:** Some convenience key setups. The
following key bindings have been added:
- mouse-2 - Brings up a menu of Lisp symbols when in a Lisp
source file.
- F6 - Switches focus to another window (when multiple windows
are in an Emacs frame).
- F7 - Closes all windows except for the window that currently
has focus.
- C-F7 - If ECB was loaded, toggles between multiple ECB windows
and just a single source window.
- M-F7 - If ECB was loaded, toggles between different ECB window
layouts.
- F12 - Emacs shell
- C-F12 - Default shell
- M-F12 - Bash shell (if present on computer)
- C-c f - Finds the Emacs Lisp function at the cursor location.
- C-c F - Finds the file whose name is at the cursor location.
- C-c s - Search forward using the symbol that is currently under
the cursor.
- C-c r - Search backward using the symbol that is currently
under the cursor.
- C-c / - Do a word completion (using hippie-expand).
- C-c ] - Goto the matching parenthesis of the parenthesis under
the cursor.
- C-c g - Goto a line (prompts for line#).
- C-c a - Select the entire buffer contents.
- **MS Windows Customizations:** These settings make Emacs feel more
like a Windows application. For Windows machines, they add the
following bindings:
- In dired mode, when you press the "w" key when the cursor is on
a file name, the file will be opened with the default
application for that file type.
- When cua.el is installed:
- C-c - Standard Windows copy.
- C-x - Standard Windows cut.
- C-v - Standard Windows paste.
- C-z - Standard Windows undo.
- When cua-emul.el is installed:
- M-F4 - Close frame (closes Emacs if only one Emacs frame is
open).
- C-F4 - Close the current buffer.
- C-TAB - Switch to next buffer.
- C-S-TAB - Switch to previous buffer.
- **Mac OS X Customizations:** Mac OS X specific customizations:
- Keypad DEL - Deletes character under cursor.
- C-kp-HOME - Goes to beginning of buffer.
- C-kp-END - Goes to end of buffer.
- **Start Directory:** After Emacs starts up, the start directory
will be the HOME directory.
B. Mac OS X Setup Instructions
------------------------------
- At this stage, support for Mac OS X on this page is very limited and
(since I do not use Mac OS X on a regular basis) I would welcome
someone else providing a separate page of instructions. This section
lists the things that are different from the above Windows
instructions.
- There are multiple different versions of Emacs (some Aqua-ized, some
not) for the Mac and there will eventually be an official FSF Emacs
that supports the Aqua GUI. I used `David Caldwell's Carbon
build