1.0 Updates:
  1. none

Installing ABCL and Emacs on Windows and the MAC
Elliott

Emacs and ABCL LISP run identically on Windows, Mac, and Unix, so it is a very convenient development environment. This file will also help you to install ABCL common lisp so that you can run it without using emacs.

For emacs installs, refer to the emacs reference card for the meanings of C-x (control x) and M-x (Meta x). RET means Return-key or Enter-key.

You can download the abcl.jar file here, or get the latest from Armed Bear . You want the "bin" file, not the "contrib" file. These suggestions assume you have already installed java on your computer. If not, do that first.



On Windows

Setting up ABCL—Armed Bear Common LISP:

  1. Much of this takes place in a Command Shell. WindowsKey | CMD will get you to a CMD command shell. Typing start in a command shell will start a second command shell, if needed for convenience.

  2. WindowsKey | File Explorer will show your directories. All of the changes we make to directories will be reflected there. You can make new directories ("Folders") in File Explorer, or in the CMD command shell.

  3. Note that in a CMD Command Shell, "pwd" prints out directory where you are currently working. "cd .." will move UP one directory. "cd ai" will move DOWN into e.g. into the "\ai" sub-directory in this case. "dir" will show you all of the files and directories in your current directory, along with their permissions.

  4. "copy", "rename", "erase", "mkdir" and "rmdir" will copy, rename, remove, make-directory and remove-directory files, respectively. "Exit" to kill the shell process. See Windows commands for more, or search the web for "Windows commands" or "Windows Command Line". Starting with Win10 we have "PowerShell" which is more powerful and a superset of CMD.

  5. Notepad++ is a simple text editor. Be sure to put double quotes around a file name if you don't want Notepad++ to add ".txt" to the end of it. (For example, when creating a .bat file or a .html file.)

  6. Find your home directory:
    1. Method One: WindowsKey | CMD, start a command shell. Type "pwd" to see your current directory. This is usually your home directory.

    2. Method Two (Win10): WindowsKey | PowerShell. Type "cd ~" then "pwd" to see your current directory. This is your home directory.

  7. Create a subdirectory of your default home directory named "/ai". For example, I created C:\Users\elliott\ai.

  8. Download the abcl.jar file and put it in your \ai subdirectory. When you download the file it is probably in your \Users\elliott\Downloads directory (substitute your user name).

  9. At this point if you only use Notepad++ and only work in the \ai subdirectory, you have everthing you need. You can run LISP by typing java -jar abcl.jar .

  10. Assuming you wnat to make things a little easier, create a shell batch file called abcl.bat:

    1. In some text editor (Notepad++?) create a file called abcl.bat in the \ai directory with the following lines in it [but adjust for your user account name]:
      
      Rem This is Clark Elliott's Windows batch file for running ABCL LISP  <-- but change to your name
      echo "Running LISP from Windows from a batch file"
      java -jar \Users\elliott\ai\abcl.jar   <-- but substitute your own directory
      

    2. Save the file
  11. Type abcl <- If things go as planned this will run your batch file and start LISP

  12. At this point, if you only develop in Notepad++, and work only in this one directory, you have everything you need.

  13. Edit your PATH variable.

    1. In a CMD shell, type set path to see your current path settings. Type Exit to exit from the shell.

    2. WindowsKey | Environment should take you to the control panel where you can edit the system environment variables. Edit the Environment Variables. In the System variables, highlight Path . Edit it. Add a new path for your \ai directory where the abcl.bat file resides: C:\Users\elliott\ai" Save everything.

    3. In a CMD shell, type set path again to see your current path settings. You should see your \ai directory in the path now.

    4. Type abcl to see if LISP starts up as before. Use (quit) to quit LISP. Then type "cd .." to navigate UP to your home directory. Type abcl again. You should still be able to start LISP. If so, good, you can now start LISP from any directory.

  14. At this point, if you only develop in Notepad++, you have everything you need to work in ANY directory.

Emacs install Windows:

  1. Download Emacs from Emacs . You want the binary file that matches your 64-bit (or 32-bit?) Windows system. Run the install in the usual way. Curently double-clicking on the downloaded install file should be enough to install emacs. Try emacs now (below).

  2. Alternatively if the installation was not sucessful, you can find the "runemacs" executable and pin this to your taskbar:
    
    C:\Program Files\emacs-26...x86_64\bin\runemacs.exe
    
    
    If you are still having problems you can try running this program to complete the install:
    
    C:\Program Files\emacs-26...x86_64\bin\addpm.exe
    
    

  3. WindowsKey | Emacs, double-click to run emacs. If it starts up good job! Use C-x, C-c to exit from emacs.

  4. Emacs should start in your default directory. You can use C-x, C-f in emacs to start to open a file. You will see what directory you are in next to the "Find file: " label. [Used C-g to escape from loading a file.] If you are not in your home directory you might have to edit the Windows Emacs properties (right click on the Emacs icon). Under "Shortcut" you can set the "Start in:" property. Point this to your home directory.
  5. If things still aren't working right, you might need to set your HOME variable:

    1. WindowsKey | Environment should take you to the control panel where you can edit the system environment variables. Edit the Environment Variables. Add a new System variable named HOME and put the path to your home directory in it. E.g., for me it is C:\Users\Elliott. Save everything.

    2. Verify: In a new CMD shell, type set home You should see your HOME variable set to your home directory now.

  6. Download the sample-init.el file. In a perfect world we will rename this initialization/customization file .emacs and it will load automatically. Otherwise, we will just load it manually with the Mx load-file RET command in emacs.

  7. Move or copy the sample-init.el file into your home directory [e.g., C:\Users\elliott in my case]. (Keep this original, in case we have to go back to it and make another copy.) Copy the sample-init.el file to a new file with the name .emacs

  8. Start emacs again: WindowsKey | Emacs, double-click to run emacs. Try the C-w and C-q commands. If the cursor skips ahead by a word, and back by a word then you have successfully loaded the .emacs startup file automatically. Good job!

  9. If C-w and C-q don't work then you can try loading the init file into emacs manually. Use M-x load-file RET .emacs and then repeat the check of C-w and C-q. If this works, then there is a problem getting the .emacs file to load automatically. Otherwise, everything is the same. In this case you will have to load the initialiaztion file manually until you figure out the problem.


On the Mac (and very similar for unix)

Setting up ABCL—Armed Bear Common LISP:

  1. Much of this takes place in a Terminal Window. Use Spotlight [Command-spacebar] / Terminal to open a Terminal Window. Use Command-N to open a second window for convenience as needed.

  2. Note that in a Terminal Window, "pwd" prints out directory where you are currently working. "cd .." will move UP one directory. "cd ai" will move DOWN into e.g. into the "/ai" sub-directory in this case. "ls -l" (listing, long-form) will show you all of the files and directories in your current directory, along with their permissions.

  3. "cp", "mv", "rm" "mkdir", and "rmdir" will copy, rename, remove, make-directory and remove-directory files, respectively. "cd ~" will take you to your home directory. Search on "unix shell commands" if you want to know more. (The Mac operating system runs on top of unix.)

  4. There are at least two simple native text editors on the Mac, TextEdit and nano . nano is really simple and has virtually no learning curve. With TextEdit, be sure to use Format / Convert to Text / UTF-8 so that you get plain text.

  5. Create a subdirectory of your default home directory named "/ai". For example, I created /Users/elliott/ai. In a Terminal Windows running in your defualt directory you can type: "mkdir ai"

  6. To change to that directory, type "cd ai"

  7. Download the abcl.jar file and put a copy of it in your /ai subdirectory. You may find the file in your /Users/elliott/Downloads folder (but substitute your account name).

  8. Create a shell script named abcl:

    1. In some text editor (emacs? nano? TextEdit?) create a file called abcl in the /ai directory with the following lines in it [but adjust for your user account name]:
      
      #! /bin/sh
      echo "Running LISP from a shell script"
      java -jar /Users/elliott/ai/abcl.jar
      

    2. Save the file, and [from within a Terminal] in the ai directory (where the abcl file is now saved) type chmod 755 abcl . This will allow you to execute the file.

  9. Type ./abcl and see if java runs and LISP is loaded. If so, success with your sh script! (quit) will exit from LISP.

  10. At this point, if you only develop in TextEdit, and work exclusively in this directory, you have everything you need.

  11. To get rid of having to type ./ in front of all your shell scripts, then edit the /etc/paths file as follows. But be careful not to make a mistake, or nothing will run on your computer until you fix the paths file:

    1. sudo nano /etc/paths <-- you can also use emacs to edit the file if you are comfortable with it. sudo stands for "super-user do." nano is a simple editor.

    2. Add a line with just a single period on it. "."

    3. While you are at it, add another line /Users/[YourAccountName]/ai. For example I am /Users/elliott/ai. This will allow us to run your new shell script from anywhere.

    4. Save the file.

  12. Try abcl to see if it works now.

  13. Use the "cd .." command to move UP one directory (return to your home directory from the ai subdirectory). Alternatively, you can use "cd ~"

  14. Type abcl to see if your path is correct and your system can find your abcl shell script. If so, you'll be in LISP again. (quit) to exit LISP.

  15. From now on, you should be able to start a Terminal in any directory and just type abcl to run LISP. That is, you will find and run your shell script in the /ai directory, which in turn will run java and load lisp into it from the abcl.jar file.

  16. Search on the string "how to write unix shell scripts" on Google if you want to learn more.

Emacs install Mac:

  1. Download Emacs from Emacs for OSX <-- For my install this was for Emacs-26.1-2-universal.dmg. But your version may be later.

  2. After download, double-click on the DMG file and follow the install instructions.

  3. Command-Spacebar will take you to Spotlight. Enter "emacs" and you'll see the icon to start emacs.

  4. Double-click on Emacs and see that it runs. See what the colors and the fonts look like by default. To exit from Emacs use Control-x, control-c.

  5. From user default /users/[YourName] directory, create a subdirectory named ai . This is where we will put all your work files. As you grow comfortable, of course you will want to make subdirectories for your various projects.

  6. Download the sample-init.el file. In a perfect world we will rename this initialization/customization file .emacs and it will load automatically. Otherwise, we will just load it manually with the Mx load-file RET command in emacs.

  7. Move or copy the sample-init.el file into your home directory [e.g., /Users/elliott in my case]. (Keep this original, in case we have to go back to it and make another copy.) Copy the sample-init.el file to a new file with the name .emacs

  8. Use spotlight to start emacs again. The colors and fonts should look about the same, and you should not expect to see any errors (but if you do it might still be OK). In the default screen try C-w and C-q. If these move you forward and back by word then you have successfully loaded the .emacs initialization file.

  9. If C-w and C-q don't work then you can try loading the init file into emacs manually. Use M-x load-file RET .emacs and then repeat the check of C-w and C-q. If this works, then there is a problem getting the .emacs file to load automatically. Otherwise, everything is the same.

Running LISP natively in Emacs

  1. The no-configuration way to run lisp is pretty easy. Just use M-x shell to start a command shell. In the shell, start up LISP, e.g., by typing java -jar abcl.jar, or (assuming you have set it as above) by typing abcl . Then you can copy Defuns from your LISP program in an editor buffer, and paste them into the shell buffer. Or, you can just edit your .lisp file and re-load it into LISP with (load "myfile"). Note that LISP will assume the .lisp file extension.

  2. To configure emacs to run LISP natively edit the line in the .emacs startup file to read:
    
    MAC:     (setq inferior-lisp-program "/Users/elliott/ai/abcl")
    WINDOWS: (setq inferior-lisp-program "C:/Users/elliott/ai/abcl")  <- Note FORWARD slashes
    
    That is, change the path to point to whatever the name of your shell script or .bat file is.

  3. Restart emacs. Type M-x run-lisp

  4. Assuming all has gone well, you should now have a buffer called *inferior-lisp* with LISP running in it.

  5. You now also have access to some convenient LISP commands. See the customized Emacs reference card I have provided. For example, C-, C-e will evaluate the LISP defun surrounding the cursor. [That is, it will re-define that defun in LISP.]