1 ;;; -*- Mode: Emacs-Lisp -*-
4 ;;; ILISP Dialect definition code.
6 ;;; This file is part of ILISP.
7 ;;; Please refer to the file COPYING for copyrights and licensing
9 ;;; Please refer to the file ACKNOWLEGDEMENTS for an (incomplete) list
10 ;;; of present and past contributors.
12 ;;; $Id: ilisp-dia.el,v 1.6 2006-05-16 22:50:22 james Exp $
15 ;;;%%CUSTOMIZING DIALECTS
17 ;;; ILISP is already set up with support for a number of dialects.
18 ;;; Each dialect has a command NAME that will start an inferior LISP
19 ;;; of that dialect. NAME-hook is a hook that will run after the
20 ;;; default settings for NAME are set up. NAME-program is the default
21 ;;; program for NAME. A prefix when starting a dialect will cause you
22 ;;; to be prompted for the buffer name and the program. When setting
23 ;;; something in a hook, you should use the most general dialect that
24 ;;; makes sense. Dialect definitions and their hooks are executed from
25 ;;; least specific to most specific. They will be executed before the
26 ;;; inferior LISP is started.
28 ;;; These are the currently supported dialects. The dialects
29 ;;; are listed so that the indentation correponds to the hierarchical
30 ;;; relationship between dialects.
33 ;;; clisp (Haible and Stoll)
34 ;;; lispworks (Harlequin)
37 ;;; sbcl (really a derivative of CMUCL)
46 ;;; Scheme->C (still "in fieri")
48 ;;; chez (Chez Scheme)
50 ;;; snow (stk without Tk)
51 ;;; guile (yep! Here it comes. Still incomplete though)
53 ;;; If anyone figures out support for other dialects I would be happy
54 ;;; to include it in future releases.
56 ;;; ;;; Example of local changes and extensions to ilisp mode
57 ;;; (setq ilisp-load-hook
59 ;;; ;; Change the allegro lisp program
60 ;;; (setq allegro-program "/usr/misc/bin/lisp")
61 ;;; ;; Add a new key binding
62 ;;; (defkey-ilisp "\C-\M-a" 'arglist-lisp)
63 ;;; ;; Define a new subdialect to run on another machine.
64 ;;; (defdialect cmlisp "Connection Machine LISP."
66 ;;; (setq ilisp-program
67 ;;; "rsh power /usr/local/cm/bin/starlisp"))))
69 ;;; ;;; Automatically load a new subdialect
70 ;;; (autoload 'cmlisp "ilisp" "Run an inferior CM lisp." t)
72 ;;; To define a new dialect use the macro defdialect. For examples,
73 ;;; look at the dialect definitions in this file. There are hooks and
74 ;;; variables for almost anything that you are likely to need to
75 ;;; change. The relationship between dialects is hierarchical with
76 ;;; the root values being defined in setup-ilisp. For a new dialect,
77 ;;; you only need to change the variables that are different than in
78 ;;; the parent dialect.
82 ;;; ILISP dialect definition code.
88 (defun lisp-add-dialect (dialect)
89 "Add DIALECT as a supported ILISP dialect."
90 (when (not (member* dialect ilisp-dialects :key #'car :test #'equal))
92 (cons (list dialect) ilisp-dialects))))
95 (defun ilisp-start-dialect (buffer program setup)
96 ;; Allow dialects to be started from command line
97 (when (eq current-prefix-arg 0)
98 (setq current-prefix-arg nil))
99 (setq ilisp-last-buffer (current-buffer)
100 buffer (if current-prefix-arg
101 (read-from-minibuffer "Buffer: " buffer)
103 (funcall setup buffer)
106 (if current-prefix-arg
107 (lisp-read-program "Program: " ilisp-program)
109 (ilisp buffer setup))
112 (defmacro defdialect (dialect full-name parent &rest body)
113 "Define a new ILISP dialect.
114 DIALECT is the name of the function to invoke the inferior LISP. The
115 hook for that LISP will be called DIALECT-hook. The default program
116 will be DIALECT-program. FULL-NAME is a string that describes the
117 inferior LISP. PARENT is the name of the parent dialect."
119 (let ((setup (read (format "setup-%s" dialect)))
120 (hook (read (format "%s-hook" dialect)))
121 (program (read (format "%s-program" dialect)))
122 (dialects (format "%s" dialect)))
125 (defvar (, hook) nil (, (format "*Inferior %s hook." full-name)))
126 (defvar (, program) nil
127 (, (format "*Inferior %s default program." full-name)))
128 (defun (, setup) (buffer)
129 (, (format "Set up for interacting with %s." full-name))
130 (, (read (format "(setup-%s buffer)" parent)))
132 (setq ilisp-program (or (, program) ilisp-program)
133 ilisp-dialect (cons '(, dialect) ilisp-dialect))
134 (run-hooks '(, (read (format "%s-hook" dialect)))))
135 (defun (, dialect) (&optional buffer program)
136 (, (format "Create an inferior %s. With prefix, prompt for buffer and program."
138 (interactive (list nil nil))
139 (ilisp-start-dialect (or buffer (, dialects))
142 (setq (, program) ilisp-program))
143 (lisp-add-dialect (, dialects))))))
146 (defun setup-ilisp (buffer)
147 "Set up for interacting with an inferior LISP."
148 (set-buffer (get-buffer-create "*ilisp-send*"))
149 (kill-all-local-variables)
151 (setq ilisp-buffer (format "*%s*" buffer))
152 (when ilisp-*enable-ilisp-special-frame-p*
153 (push ilisp-buffer special-display-buffer-names))
154 (set-buffer (get-buffer-create ilisp-buffer))
155 (setq major-mode 'ilisp-mode
157 (lisp-mode-variables t)
159 ;; Set variables to nil
160 (let ((binary ilisp-binary-extension)
161 (init ilisp-init-binary-extension)
164 (make-local-variable var)
167 ;; Preserve from initialization
168 (when binary (setq ilisp-binary-extension binary))
169 (when init (setq ilisp-init-binary-extension init)))
171 (set-ilisp-input-ring-size 200)
172 (setq comint-prompt-regexp "^[^<> ]*>+:? *"
173 comint-use-prompt-regexp t ; Emacs 21 fields don't seem to work with comint-ipc (?)
174 comint-get-old-input 'ilisp-get-old-input
175 comint-input-filter-functions nil
176 comint-input-filter 'ilisp-input-filter
177 comint-input-sender 'comint-default-send
178 comint-eol-on-send t)
180 ;; Comint-ipc defaults
181 (setq comint-send-newline t
182 comint-always-scroll nil
183 comint-output-buffer " *Output*"
184 comint-error-buffer " *Error Output*"
185 comint-error-regexp "^\"ILISP:"
186 comint-output-filter (function identity)
187 comint-interrupt-start 'comint-interrupt-start
188 comint-handler 'ilisp-handler
189 comint-update-status 'ilisp-update-status
190 comint-prompt-status 'comint-prompt-status
191 comint-abort-hook 'ilisp-abort-handler)
193 (setq ilisp-use-map ilisp-mode-map
194 ilisp-init-hook-local '((lambda ()
195 (ilisp-init nil nil t)
196 (run-hooks 'ilisp-init-hook)))
197 ilisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)*\\)?\\s *\\'"
198 ilisp-filter-length 3
199 ilisp-error-filter 'ilisp-error-filter
200 ilisp-error-regexp ".*"
202 ;; 20000216 Marco Antoniotti
203 ;; Removed the 'dot' (.) from the set of symbol delimiters.
204 ;; This allows the correct handling of symbols like
206 ;; The relevant code is in 'lisp-previous-symbol' et al. in
208 ;; ilisp-symbol-delimiters "^ \t\n\('\"#.\)<>"
209 ilisp-symbol-delimiters "^ \t\n\('\"#\)<>"
211 ilisp-locator 'lisp-locate-ilisp
212 ilisp-calls-locator 'lisp-locate-calls)
214 (run-hooks 'ilisp-mode-hook))
218 "Create an inferior LISP prompting for dialect.
219 With prefix, prompt for buffer name as well."
221 (let ((dialect (completing-read "Dialect: " ilisp-dialects nil t)))
222 (if (not (zerop (length dialect)))
223 (call-interactively (read dialect)))))
226 ;;; end of file -- ilisp-dia.lisp --