From: BK
Subject: [How-to] carbonised/Aqua emacs with ILISP under OSX
Date: 
Message-ID: <39d9c156.0305040229.718ae840@posting.google.com>
How to make an Aqua version of Emacs work with ILISP under OSX

First of all, thanks to everybody who helped me on this. I really
apreciate it and will compile a step-by-step guide and make it
available to both the ILISP and Carbon Emacs projects once I have fine
tuned everything. If I find the time and stamina to do so, I might
create an OSX install package, so that the whole becomes a one-click
affair for OSX users.

For now, here is a quick and dirty summary ...


INSTALL/PREPARE EMACS

1) DOWNLOAD - Get an aquafied version of Emacs, for exmple

http://www.porkrind.org/emacs/offsite-mirror1/Emacs-21.1.tar.gz


2) LOCATION - Find a place for Emacs to live, for example

/Applications   -or-   /Developer/Applications

CAUTION! Some builds of Aqua versions of Emacs only work if they are
located in /Applications. If Emacs fails to launch, put it in
/Applications. If yours does launch from elsewhere and you want to put
it elsewhere, it is a good idea to make sure that no folder name in
the path has whitespace in it, for example

use "Emacs21" or "Emacs-21" as a folder name instead of "Emacs 21"

I recommend to put Emacs directly into /Applications or
/Developer/Applications without any surrounding folder.


3) ENVIRONMENT - Make sure Emacs doesn't feel homesick in its new Aqua
home

When an Aqua version of Emacs is launched from the Finder, it will
inherit its environment from the Finder. That environment does not
automatically contain Unix environment variables. For most Aqua
applications this doesn't matter, but for Emacs it can pose a problem.
It is a good idea to make sure that Emacs can see important Unix
environment variables, just in case it will need them.

One way to address this is to launch Emacs from the terminal

$ open -a Emacs

but we didn't get a Mac to launch applications from the command line,
did we?!

So, here is how to provide some of the important Unix environment
variables to Aqua applications and thereby to our Aqua version of
Emacs:

(1) first let's take a look at what our Unix environment actually is
...

in terminal type

$ setenv

this is where we are going to peek from, so leave the terminal alone
for now

(2) next, we create a property list with some of the same content

- launch Property List Editor (in /Developer/Applications)
- create a new property list (File -> New)
- create a root entry (click New Root)
- expand the root entry (click on the little triangle)
- create a new child entry (click New Child)
- give it a name where it says "New item" (for example PATH)
- paste the content of PATH from the terminal window to where it says
"Value"

do this to create the following entries:

Name: EMACS
Value: /Developer/Applications/Emacs.app/Contents/MacOS/Emacs

If you didn't put Emacs into /Developer/Applications, adjust
accordingly

Name: PATH
Value: /Users/username/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin

Replace "username" with your Unix username. You may want to copy the
content of PATH from the terminal window, the above represents factory
settings only. Make sure you replace any ocurrance of "~/" with the
path to your home directory, typically /Users/username

Name: HOME
Value: /Users/username

Again, replace "username" with your Unix username. Check against the
value in the terminal window.

Name: USER
Value: username

Again, replace "username" with your Unix username.

If there are any other environment variables showing up in terminal
that you think should be available to Emacs, make entries for those
accordingly.

Once you are done, save the propery list as environment.plist in a
hidden directory called .MacOSX in your home directory. You can do
this directly from Propery List Editor using File -> Save -> New
Folder ".MacOSX" then save the file as environment.plist

Finally, go back to terminal and check it's there

$ cat ~/.MacOSX/environment.plist

should output something like this:

==============================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM
"file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
	<key>CCL_DEFAULT_DIRECTORY</key>
	<string>/Developer/OpenMCL/ccl</string>
	<key>EMACS</key>
	<string>/Developer/Applications/Emacs.app/Contents/MacOS/Emacs</string>
	<key>HOME</key>
	<string>/Users/johndoe</string>
	<key>OPENMCL_IMAGE</key>
	<string>dppccl.image</string>
	<key>OPENMCL_KERNEL</key>
	<string>dppccl</string>
	<key>PATH</key>
<string>/Users/johndoe/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin</string>
	<key>USER</key>
	<string>johndoe</string>
</dict>
</plist>
==============================================================================

(Note: In this example there are additional entries for OpenMCL)

Now, log out and back in again to make your Aqua environment pick up
the entries.


INSTALL/PREPARE ILISP

1) DOWNLOAD - Get ILISP, for example

http://prdownloads.sourceforge.net/ilisp/ilisp-5.12.0.tar.gz?download


2) LOCATION - Find a place for ILISP to live, for example

/Library/ilisp

is a good place on OSX, because amongst all the locations that would
seem to make sense, /Library is the only one that is visible within
the Finder and thus if we want to take a look at certain files, we
don't need to go to the terminal to get access.


3) COMPILE ILISP

CAUTION! I haven't tested this part yet because TFB was so kind to
email me an already compiled version of ILISP and I used that one to
get my setup working. However, I will test this later and if there are
any further steps, I will include those in the step-by-step guide I
promised.

edit the Makefile in the ilisp directory and adjust the EMACS entry.
Set it to the same path already speficied above in environment.plist,
ie.

/Developer/Applications/Emacs.app/Contents/MacOS/Emacs

in the terminal type

$ cd /Library/ilisp
$ make

The INSTALLATION file says:

"Run `make' or `make compile' to build ILISP from source.  Ignore any
compilation warnings unless they result in ILISP not compiling
completely."


4) CONFIGURE ILISP

Create a configuration file ".ilisp" in your home directory. You can
use the template file ilisp.emacs which comes with ILISP and customise
it. However, my setup complained a couple of times, so I narrowed it
down to what would seem the absolute minimum. As I will add in things
step by step again, I hope to be able to present a more complete file
in the final step-by-step guide. For now, here is the minimalist
version of .ilisp

==============================================================================
;;; ILISP folder location

(add-to-list 'load-path "/Library/ilisp")


;;; Autoload based on your Lisp.

(autoload 'common-lisp "ilisp" "Inferior generic Common Lisp." t)


;;; Define where Lisp programs are found.

(setq openmcl-program "/Developer/OpenMCL/ccl/lisp")
; NB: not so sure about this one - may change


;;; This makes reading a Lisp file load in ILISP.

(set-default 'auto-mode-alist
             (append '(("\\.lisp$" . lisp-mode)
                       ("\\.lsp$" . lisp-mode)
                       ("\\.cl$" . lisp-mode))
                     auto-mode-alist))

(setq lisp-mode-hook '(lambda () (require 'ilisp)))


(load "ilisp")
==============================================================================

NOTE! There are various entries for autoload in the template file
ilisp.emacs for various CL systems. I use OpenMCL, for which there was
no such entry because it works with the generic entry. If you use any
of the systems for which there is such an entry, you will need to
insert that entry into your .ilisp file.


PUTTING IT ALL TOGETHER

1) Tell Emacs to load ILISP at launch

create a file .emacs in your home directory and put in the line

(load-file "~/.ilisp")


2) Make sure ILISP can find you Common Lisp

NOTE! In this example I use OpenMCL, adjust accordingly for other CL
systems.

I put OpenMCL into /Developer/OpenMCL. Consequently, the OpenMCL start
script (which I have already edited accordingly) is located at

/Developer/OpenMCL/ccl/scripts/openmcl

==============================================================================
# Set the CCL_DEFAULT_DIRECTORY  environment variable; 
# the lisp will use this to setup translations for the CCL: logical
host.

if [ -z "$OPENMCL_KERNEL" ]; then
  case `uname -s` in
    Darwin)
    OPENMCL_KERNEL=dppccl
    ;;
    Linux)
    OPENMCL_KERNEL=ppccl
    ;;
    *)
    echo "Can't determine host OS.  Fix this."
    exit 1
    ;;
  esac
fi

CCL_DEFAULT_DIRECTORY=${DD} exec ${DD}/${OPENMCL_KERNEL} ··@"
==============================================================================

For Emacs and ILISP to find this script, I created a symbolic link to
it in /usr/bin. To do this, in terminal type

$ sudo ln -s /Developer/OpenMCL/ccl/scripts/openmcl /usr/bin/openmcl

The directory /usr/bin is defined in the path, both in the Unix
environment and in ~/.MacOSX/environment.plist, so both ILISP and
Emacs can find it there.


3) Testing

launch your Aqua version of Emacs from the Finder

then issue the command: M-x openmcl

(Short for: press META and "x", then type "openmcl" and hit the return
key)

OpenMCL (or whatever CL system you have configured and specified
instead) should now show up in your Emacs window and the status bar
should show something like:

--:**-Emacs   *openmcl*        (ILISP
:ready)--Lnn--100%----------------------


Note the "ILisp" Menu in Emacs' menu bar. That's what we were after!


STILL TO DO

This is a minimalistic configuration, just to make sure everything is
working. There are plenty of things in ilisp.emacs which add
functionality and which I have to add back in (one at a time). The
most important one of those is the HyperSpec. Then key bindings will
also deserve some attention. AW hinted at a utility called CUA which
apparently provides Apple style cut/copy/paste key bindings. Once I
have completed and tested this all, I will include it in the guide I
promised. For now, I hope that this post will help anyone who is
interested to play with Lisp and therefore in need of a minimal IDE
such as Emacs/ILISP provides.

Again, thanks to everybody who has helped me get this far.

rgds
bk

PS: Marco, until I have completed this and written up a better guide,
you may want to cut and paste this posting into an OSX specific readme
file and make it available to anyone who has a need.
From: BK
Subject: Re: [How-to] carbonised/Aqua emacs with ILISP under OSX
Date: 
Message-ID: <39d9c156.0305040528.660796c6@posting.google.com>
Cut and paste error in my previous post! The openmcl script was
incomplete. For anyone who needs it, here is the complete script for
an OpenMCL installation located at /Developer/OpenMCL

#!/bin/sh
#
# Change the definition of CCL_DEFAULT_DIRECTORY below to refer to
# your OpenMCL installation directory.  
# Any definition of CCL_DEFAULT_DIRECTORY already present in the
environment
# takes precedence over definitions made below.

if [ -z "$CCL_DEFAULT_DIRECTORY" ]; then
  CCL_DEFAULT_DIRECTORY=/Developer/OpenMCL/ccl
fi

# This is shorter (& easier to type), making the invocation below
# a little easier to read.

DD=${CCL_DEFAULT_DIRECTORY}

# If you don't want to guess the name of the OpenMCL kernel on
# every invocation (or if you want to use a kernel with a
# non-default name), you might want to uncomment and change
# the following line:
#OPENMCL_KERNEL=some_name

# Set the CCL_DEFAULT_DIRECTORY  environment variable; 
# the lisp will use this to setup translations for the CCL: logical
host.

if [ -z "$OPENMCL_KERNEL" ]; then
  case `uname -s` in
    Darwin)
    OPENMCL_KERNEL=dppccl
    ;;
    Linux)
    OPENMCL_KERNEL=ppccl
    ;;
    *)
    echo "Can't determine host OS.  Fix this."
    exit 1
    ;;
  esac
fi

CCL_DEFAULT_DIRECTORY=${DD} exec ${DD}/${OPENMCL_KERNEL} ··@"