You are looking at historical revision 16353 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. If you want to add a specific location permanently to the list of paths emacs should search for extensions, add the following line to your .emacs file:

 (setq load-path 
   (cons
     "<directory-where-your-emacs-lisp-files-live>" 
     load-path))

Add

 (require 'hen)
       

to make "hen-mode" available, and enter it by issuing the command 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.

The screenshot also shows the man egg in action. It can be used to interactively get help from the Chicken Manual.

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).

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) ) ) )

}}