You are looking at historical revision 16900 of this page. It may differ significantly from its current revision.

Using CHICKEN with emacs

Various packages exist for supporting Scheme programming with the emacs editor.

scheme-complete

Particularly recommended is Alex Shinn's scheme-complete, which provides intelligent autocompletion:

http://synthcode.com/wiki/scheme-complete

hen.el

hen.el is an emacs mode specifically for CHICKEN, but is currently unmaintained:

http://www.call-with-current-continuation.org/hen.el

To use it, copy it somewhere into a location you normally use for emacs extensions and add this to your emacs initialization file:

 (require 'hen)

To enable it, in any Scheme buffer do an M-x hen-mode.

paredit

paredit provides structural editing for Scheme and Lisp code:

http://mumble.net/~campbell/emacs/paredit.el

Quack

Neil van Dyke's Quack enhances Emacs support for Scheme and can be used for editing CHICKEN code.

The screenshot above shows GNU Emacs using Quack to edit a "hello world" program and the CHICKEN REPL being executed from within Emacs.

Cluck

cluck is a clone of Quack but specialized for Chicken scheming.

Builtin Scheme support

Emacs has builtin support for syntax-highlighting of Scheme code and running a Scheme interpreter in an interactive buffer. To use it with CHICKEN, add this to your ~/.emacs file:

 (setq scheme-program-name "csi -:c")

The -:c is to force interactive mode, which is required on some platforms (most notably Windows).

This variable is customizable, which is the preferred way in GNU Emacs and XEmacs to set user preferences: menu Options -> Customize Emacs -> Specific Option, type in scheme-program-name. Emacs displays a form; fill in csi -:c for the program name, click "Set for Current Session", and then "Save for Future Sessions". This will update (or create if it does not already exist) the custom-set-variables section in your ~/.emacs file.

Useful elisp snippets

I have these definitions in my ~/.emacs file, which allow loading the current buffer, optionally by compiling it first to native code:

(define-key scheme-mode-map "\C-c\C-l" 'scheme-load-current-file)
(define-key scheme-mode-map "\C-c\C-k" 'scheme-compile-current-file)

(require 'cmuscheme)

(define-key scheme-mode-map "\C-c\C-l" 'scheme-load-current-file)
(define-key scheme-mode-map "\C-c\C-k" 'scheme-compile-current-file)

(defun scheme-load-current-file (&optional switch)
  (interactive "P")
  (let ((file-name (buffer-file-name)))
    (comint-check-source file-name)
    (setq scheme-prev-l/c-dir/file (cons (file-name-directory    file-name)
					 (file-name-nondirectory file-name)))
    (comint-send-string (scheme-proc) (concat "(load \""
					      file-name
					      "\"\)\n"))
    (if switch
      (switch-to-scheme t)
      (message "\"%s\" loaded." file-name) ) ) )

(defun scheme-compile-current-file (&optional switch)
  (interactive "P")
  (let ((file-name (buffer-file-name)))
    (comint-check-source file-name)
    (setq scheme-prev-l/c-dir/file (cons (file-name-directory    file-name)
					 (file-name-nondirectory file-name)))
    (message "compiling \"%s\" ..." file-name)
    (comint-send-string (scheme-proc) (concat "(compile-file \""
					      file-name
					      "\"\)\n"))
    (if switch
      (switch-to-scheme t)
      (message "\"%s\" compiled and loaded." file-name) ) ) )