4.1: Emacs-Lisp interface

#Q 4.1-1) How do I print to the emacs-lisp interface created *common-lisp* buffer when I run my application in its own Lisp image?
#Q 4.1-2) Can I connect a UNIX emacs to a Windows Lisp?
#Q 4.1-3) Can I run Emacs on Windows and Lisp on UNIX?
#Q 4.1-4) Why doesn't the emacs-lisp interface startup when I don't have a network connection?


Q 4.1-1) How do I print to the emacs-lisp interface created *common-lisp* buffer when I run my application in its own Lisp image?

A 4.1-1) You can do this by putting advice on the function excl:start-emacs-lisp-interface. The advice must, however, exist at the time the emacs-lisp interface is started, which means you will have to make new Lisp image.

For example, put the following into a file, /tmp/test.cl:

(in-package :user) 

(defun doit () 
  (sleep 3) 
  (let* ((proc (multiprocessing:process-name-to-process 
                #+mswindows "*common-lisp*" 
                #-mswindows "Initial Lisp Listener")) 
         (stream 
          #+mswindows 
          (mp::symeval-in-process '*standard-output* proc) 
          #-mswindows 
         (mp::symeval-in-stack-group 
           '*standard-output* 
           (mp::process-stack-group proc)))) 
     (format stream "The emacs-lisp interface has started...~%") 
     (force-output stream))) 

(advise excl:start-emacs-lisp-interface :after :eli-startup-print nil (doit)) 

start up Lisp and do this:

:cl /tmp/test.cl (dumplisp :name "/tmp/test.dxl") 

and startup Lisp with the image you just created using M-x fi:common-lisp, and specifying /tmp/test.dxl as the image. You will then see

The emacs-lisp interface has started... 

in the *common-lisp* buffer.


Q 4.1-2) Can I connect a UNIX emacs to a Windows Lisp?

A 4.1-2) Not in release 5.0, but starting in release 5.0.1, you can. Follow these instructions.

  1. On Windows start Lisp, either by using the shortcut that contains "to Emacs" in it, or any Lisp that you have evaluated the following form:
(excl:start-emacs-lisp-interface) 
  1. On UNIX, in Emacs, do:
M-x set-variable RET fi:connect-to-windows RET t 
M-x fi:common-lisp RET RET <specify windows host> RET ... 

You should now be connected to the Lisp running on Windows.


Q 4.1-3) Can I run Emacs on Windows and Lisp on UNIX?

A 4.1-3) No. The emacs-lisp interface does not currently support this.


Q 4.1-4) Why doesn't the emacs-lisp interface startup when I don't have a network connection?

A 4.1-7) Typically this is a not a problem on Unix, so we will discuss how to deal with this on Windows (but the Unix solution is similar).

The short answer is the startup is failing because the emacs-lisp interface does a lookup on the host localhost, looking in a Windows hosts file for a transslation of localhost. If such a translation cannot be found, either because there is no hosts file or the hosts file does not contain a translation for localhost (to 127.0.0.1), then the ELI function fi:common-lisp will fail to startup lisp.

You can check if you have this problem by typing

ping localhost

to a DOS prompt (Windows 95/98) or a Command prompt (Windows NT): If the reult is a message like host localhost not found, then you will not be able to use fi:common-lisp without further work.

There are two solutions:

  1. Create a <Windows directory>\hosts file (no extension) with the contents:
127.0.0.1    localhost 

There is a TAB between 127.0.0.1 and localhost. The <Windows directory> is ofter c:\windows\ but may be different on your machine.

  1. Put the following in your c:\.emacs file:
(setq fi:common-lisp-host "127.0.0.1") 

© Copyright 1998, Franz Inc., Berkeley, CA.  All rights reserved.
$Revision: 1.1.2.9 $