Previous: , Up: Notes for Mac OS X and Windows   [Contents][Index]


2.2.7.2 Notes for Windows

FEMLISP did work on Windows quite well using Allegro CL, but this has not been tested for quite some time.

When I tried installing FEMLISP recently on Windows using SBCL, FEMLISP itself worked, but I was not able to make the communication with the graphics program OpenDX work as well.

Since having no immediate graphics available is a kind of show stopper, I would rather suggest installing a virtual machine with Linux on your Windows box.

5

2.3 Working with Femlisp in a Common Lisp IDE

2.3.1 General information about working with Lisp

For working with Lisp in a satisfactory way, it is of uttermost importance that you use an editor which "understands" Lisp code and can indent it correctly, which shows matching parentheses and does syntax-highlighting. Otherwise, it is almost impossible to write nontrivial Lisp code. On the other hand, if such an editor is available, it will often provide commands for moving through the code and manipulating the code expression-wise, which makes writing Lisp even easier than writing, say, C or C++. It is very useful to learn these editor features.

Furthermore, in contrast to most other languages, the ANSI Common Lisp standard defines an interface for introspection. E.g., functions and special variables can be documented, and these so-called docstrings can be extracted at any time. For example:

(defvar *result*
  "This special variable is often used for storing the result of the
  last top-level computation.")

Now, (documentation '*result* 'variable) returns the docstring provided before. If you use a decent Lisp environment, this command can be invoked by pressing some key when the cursor is on the symbol *result*.

The ANSI Common Lisp standard requires also an interface for tracing, inspecting data, together with some debugging commands. However, implementations vary in the quality of the provided tools. Commercial Lisps as Allegro CL, Lispworks or Corman CL provide very elaborate IDEs which allow for easy access to the above-mentioned features. A free alternative is the editor Emacs together with the SLIME package. Emacs/SLIME can handle a large range of Lisp implementations and provides more or less the same possibilities as the commercial IDEs.

2.3.2 Installing and using GNU Emacs and SLIME

2.3.2.1 Installing Emacs

Emacs can be installed essentially on every computer system in use and works even in terminals. It is a Lisp system itself, and can be extended arbitrarily. As a rule of thumb you can make it do everything you want, and for many of your wishes, other people will already have fulfilled it, and you can use an appropriate Emacs package doing what you want.

On Debian/GNU Linux (and other distributions based on it, like the Ubuntu variants), Emacs can be installed using

    sudo apt install emacs

2.3.2.2 Getting started with Emacs

Your first step should be to work through the Emacs tutorial.

Probably your most difficult problem using Emacs will be, that the keyboard commands for copying, deleting and pasting are different from what you are used from other applications (M-w, C-w, C-y instead of C-c, C-x, C-v). The reason is that Emacs is much older than software from Apple/Microsoft which introduced the C-c, C-x, C-v commands. and although changing the Emacs keybindings to the new versions was discussed in the Emacs community, the developers could not agree on this change. However, there is a way to make Emacs understand this ‘Common User Access’ system by executing the command ‘M-x cua-mode‘, but since I do not use it myself, I hesitate to recommend it.

If possible, make sure that you get also the Emacs documentation which is not installed automatically on Debian/GNU Linux systems due to a silly disagreement in the community about “freeness” of its license. 6

2.3.2.3 Installing SLIME

SLIME is an Emacs package which can communicate with a Common Lisp process running within Emacs. It can be installed easily with Quicklisp, see Quicklisp by first executing

(ql:quickload "quicklisp-slime-helper")

from within your Common Lisp implementation, and then adding the lines

(load (expand-file-name "~/quicklisp/slime-helper.el"))
(setq inferior-lisp-program "sbcl")
(setq inferior-lisp-program-args '("--dynamic-space-size" "4000"
                                   "--control-stack-size" "100"))

;;; some fancy SLIME features
(slime-setup
 '(slime-cl-indent slime-asdf slime-fancy slime-fancy-inspector slime-fuzzy slime-autodoc slime-sprof))

;;; and a way to start/show the SLIME buffer with a single keypress
(defun show-repl-maybe-start-slime ()
  (interactive)
  (if (slime-connected-p)
      (slime-display-output-buffer)
    (slime-start :program inferior-lisp-program
                 :program-args inferior-lisp-program-args)))
(global-set-key [f9] 'show-repl-maybe-start-slime)

to your .emacs initialization file. You can find a bit more information on tweaking Emacs for your needs in the following section.

When you restart Emacs now (or when you reevaluate your .emacs-file), pressing [f9] should give you an interactive Common Lisp session. Entering here

(asdf:make :femlisp)

loads FEMLISP and you can start working. 7

2.3.2.4 Emacs initialization file

You can make Emacs behave in almost every way you want. This customization can be done interactively from within Emacs, but also on startup by writing Emacs Lisp commands in an initialization file called .emacs (or init.el in a directory called .emacs.d) situated in your home directory.8

Here is an extract from my own Emacs initialization file which may be useful for you:

;;; move Emacs Lisp a little closer to Common Lisp
(require 'cl)

;;; mostly self-explaining
(setq backup-by-copying t)
(set-language-environment "UTF-8")
(global-font-lock-mode 1)
(auto-compression-mode t)
(setq line-number-mode t)
(setq column-number-mode t)
(setq paren-mode 'sexp)
(show-paren-mode 1)
(setq track-eol t)

;;; show time on mode line in European format
(setq display-time-format "%d.%m.%Y %k:%M")
(display-time)

;;; Better behaviour for switch-buffer
(iswitchb-mode 1)

;;; Better behaviour for newline
(global-set-key (kbd "RET") 'newline-and-indent)
(define-key text-mode-map (kbd "RET") 'newline)

;;; SLIME
(load (expand-file-name "~/quicklisp/slime-helper.el"))
(setq inferior-lisp-program "sbcl")
(setq inferior-lisp-program-args '("--dynamic-space-size" "4000"
                                   "--control-stack-size" "100"))

(slime-setup
  '(slime-cl-indent slime-asdf slime-fancy slime-fancy-inspector
    slime-fuzzy slime-autodoc slime-sprof))

(defvar coding-system 'utf-8)
(setq slime-net-coding-system 'utf-8-unix)  ;utf-8-unix

(defun show-repl-maybe-start-slime ()
  (interactive)
  (if (slime-connected-p)
      (slime-display-output-buffer)
      (slime-start :program inferior-lisp-program
		   :program-args inferior-lisp-program-args)))

;;; Some useful keyboard shortcuts (activate them only if you don't need the keys for something else)
(global-set-key [f4]    'shell)
(global-set-key [f7]    'bury-buffer)
(global-set-key [f8]    'kill-this-buffer)
(global-set-key [f9] 'show-repl-maybe-start-slime)
(global-set-key (kbd "M-\\") 'dabbrev-expand)

Footnotes

(5)

Of course, if you are a Windows guru who wants to help, patches which make communication with OpenDX work on Windows are always welcome. Note that OpenDX has to work in scripting mode as this mode is used by FEMLISP. A good start would probably be, if you could make the following line work in a Cygwin shell (not the standard Windows command shell where it works as expected):

  dx -script

Ideally, this should result in a prompt “dx>” which you should be able to leave using the command “quit”.

(6)

Therefore, the command for installing Emacs documentation might be something a little more complicated like

    sudo apt install emacs25-common-non-dfsg

(7)

There are also keyboard shortcuts for the last command: Pressing ,l (comma and l) in the SLIME repl followed by <enter> (or <tab> and <enter>) asks for a system. Here you can enter the word ’femlisp’ which should load FEMLISP in your session.

(8)

The dot at the beginning makes that .emacs or .emacs.d are not shown by the UNIX command ‘ls‘, unless you call it as ‘ls -a‘.


Previous: , Up: Notes for Mac OS X and Windows   [Contents][Index]