How to use allegro common lisp with emacs What does the Emacs-Lisp interface do for me? Basically, fi will start a lisp process (locally or remotely) and send your input to the lisp process. There will be a *common-lisp* (or something similar) buffer, which is essentially a shell buffer which passes your input to the lisp listener. You can also edit lisp source files in emacs. fi will handle all the mundane indentation stuff, and will also allow you to send forms (s-expressions) to the lisp process without leaving the source file. In a typical session you might: (1) Start up a lisp session (M-x run-common-lisp) (2) Open a source file (C-x C-f ) (3) Edit the file (4) Send the file (buffer) to the lisp process (C-c C-b), where it will be compiled. (5) Jump to the lisp buffer and invoke your program. (6) Jump to source file and debug! (and on and on...) Where's the documentation? Hopefully this file will be enough to get you started running a lisp process and editing files, but there's a lot more. The fi package comes with good documentation. Look at the *.doc files in /opt/gnu/share/emacs/site-lisp/fi-2.0.16 There's also an examples directory. There a FAQ available at the allegro web site (http://www.franz.com/faq/aclfaq-0.html). If (when!) you're comfortable with lisp, you might just jump straight to the source! How do I get started? Here's an annotated version of the relevant forms in my .emacs file: NOTE: You MUST change the "HOST NAME HERE" string to the name of a machine where you will run acl. NOTE: If you run acl on a remote machine you must exit the lisp process before quitting emacs. Otherwise, the remote process may not be properly exited. ;;;------------------------------------------------------------------ ;;; allegro common lisp interface (fi) ;;;------------------------------------------------------------------ ;;; I've placed all the setup in a emacs command, since I don't use lisp ;;; every time I start up emacs. When I do want to use the lisp ;;; interface I do (M-x my-load-allegro-lisp-interface) (defun my-load-allegro-lisp-interface () ;; Tell emacs that this is an interactive function - it can be invoked ;; using M-x and can be bound to a keystroke. (interactive) ;; Add the directory where fi lives to the emacs "load-path", ;; which is analogous to the unix PATH variable. (setq load-path (cons "/soft/acl6.1/SunOS5.7/eli/" load-path)) ;(setq load-path (cons "/opt/gnu/share/emacs/site-lisp/fi-2.0.16" load-path)) ;; Load the file "fi-site-init" which initializes the fi package (load "fi-site-init") ;; assign default values to the startup arguments - you need to set ;; the hostname to a machine where you want to run the acl process (setq fi:common-lisp-buffer-name "*acl-common-lisp*") (setq fi:common-lisp-directory (expand-file-name "~/lisp")) (setq fi:common-lisp-image-name "/soft/acl6.1/SunOS5.7/alisp") (setq fi:common-lisp-image-arguments nil) (setq fi:common-lisp-host "HOST NAME HERE") (setq fi:emacs-to-lisp-transaction-directory (expand-file-name "~/tmp")) ;; Now define the function I will use to invoke acl within the fi ;; interface. Alternatively, you can invoke fi:common-lisp directly, ;; which will prompt you for the argument values. (defun run-common-lisp () "This function starts up lisp with your defaults" (interactive) (fi:common-lisp fi:common-lisp-buffer-name fi:common-lisp-directory fi:common-lisp-image-name fi:common-lisp-image-arguments fi:common-lisp-host)) ;; I override some of the default keybindings. You may want to delete ;; this bit and try the defaults. In emacs, a "hook" is a list of ;; functions invoked at a particular time. The ;; fi:inferior-common-lisp-mode-hook is called when a new lisp buffer ;; is created. (add-hook 'fi:inferior-common-lisp-mode-hook (lambda () (define-key fi:inferior-common-lisp-mode-map '(meta p) 'fi:pop-input) (define-key fi:inferior-common-lisp-mode-map '(meta n) 'fi:push-input) (define-key fi:inferior-common-lisp-mode-map '(control a) 'fi:subprocess-beginning-of-line))) ) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Using the fi interface: Once your .emacs file is set up (and loaded! Either restart emacs or use "M-x load-file" to load your new .emacs file), you can jump right in. If you've copied the .emacs code more or less verbatim you need to M-x my-load-common-lisp-interface to load the interface functions. To start-up a lisp process use: M-x run-common-lisp (defined above, uses default arguments) or M-x fi:common-lisp (you will be prompted for arguments) There will probably be some waiting now. Eventually you will get a prompt like this one: USER(1): To edit: Whenever you edit a file with an .lsp or .lisp suffix, the acl-lisp-mode will automatically be used. Some handy keybindings: The lisp process buffer will behave much like acl invoked from a standard shell. One important difference: you must type C-c C-c to send an interrupt to the process. While editing a file, the editor should automatically indent and highlight parens. Here are some handy keybindings to use while editing: C-c C-s : sends the last s-expression to the lisp process, where it is compiled C-c C-b : sends the entire buffer to the lisp process, where it is compiled M-Sh-m : macro-expands the form at the cursor M-Sh-w : recursively macro-expands the form at the cursor M-Sh-c : asks for a function name, then lists the callers of that function