0
|
1 ;;; -*- Mode: Emacs-Lisp -*-
|
|
2
|
|
3 ;;; ilisp-dia.el --
|
|
4
|
|
5 ;;; This file is part of ILISP.
|
|
6 ;;; Version: 5.7
|
|
7 ;;;
|
|
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
|
|
9 ;;; 1993, 1994 Ivan Vasquez
|
|
10 ;;; 1994, 1995 Marco Antoniotti and Rick Busdiecker
|
|
11 ;;;
|
|
12 ;;; Other authors' names for which this Copyright notice also holds
|
|
13 ;;; may appear later in this file.
|
|
14 ;;;
|
|
15 ;;; Send mail to 'ilisp-request@lehman.com' to be included in the
|
|
16 ;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP
|
|
17 ;;; mailing list were bugs and improvements are discussed.
|
|
18 ;;;
|
|
19 ;;; ILISP is freely redistributable under the terms found in the file
|
|
20 ;;; COPYING.
|
|
21
|
|
22
|
|
23 ;;;%%CUSTOMIZING DIALECTS
|
|
24 ;;;
|
|
25 ;;; ILISP is already set up with support for a number of dialects.
|
|
26 ;;; Each dialect has a command NAME that will start an inferior LISP
|
|
27 ;;; of that dialect. NAME-hook is a hook that will run after the
|
|
28 ;;; default settings for NAME are set up. NAME-program is the default
|
|
29 ;;; program for NAME. A prefix when starting a dialect will cause you
|
|
30 ;;; to be prompted for the buffer name and the program. When setting
|
|
31 ;;; something in a hook, you should use the most general dialect that
|
|
32 ;;; makes sense. Dialect definitions and their hooks are executed from
|
|
33 ;;; least specific to most specific. They will be executed before the
|
|
34 ;;; inferior LISP is started.
|
|
35 ;;;
|
|
36 ;;; These are the currently supported dialects. The dialects
|
|
37 ;;; are listed so that the indentation correponds to the hierarchical
|
|
38 ;;; relationship between dialects.
|
|
39 ;;; clisp
|
|
40 ;;; allegro
|
|
41 ;;; Clisp (Haible and Stoll)
|
|
42 ;;; lispworks (Harlequin)
|
|
43 ;;; lucid
|
|
44 ;;; cmulisp
|
|
45 ;;; kcl
|
|
46 ;;; akcl
|
|
47 ;;; ibcl
|
|
48 ;;; ecl
|
|
49 ;;; gcl
|
|
50 ;;; scheme
|
|
51 ;;; oaklisp
|
|
52 ;;; Scheme->C (still "in fieri")
|
|
53 ;;;
|
|
54 ;;; If anyone figures out support for other dialects I would be happy
|
|
55 ;;; to include it in future releases.
|
|
56 ;;;
|
|
57 ;;; ;;; Example of local changes and extensions to ilisp mode
|
|
58 ;;; (setq ilisp-load-hook
|
|
59 ;;; '(lambda ()
|
|
60 ;;; ;; Change the allegro lisp program
|
|
61 ;;; (setq allegro-program "/usr/misc/bin/lisp")
|
|
62 ;;; ;; Add a new key binding
|
|
63 ;;; (defkey-ilisp "\C-\M-a" 'arglist-lisp)
|
|
64 ;;; ;; Define a new subdialect to run on another machine.
|
|
65 ;;; (defdialect cmlisp "Connection Machine LISP."
|
|
66 ;;; lucid
|
|
67 ;;; (setq ilisp-program
|
|
68 ;;; "rsh power /usr/local/cm/bin/starlisp"))))
|
|
69 ;;;
|
|
70 ;;; ;;; Automatically load a new subdialect
|
|
71 ;;; (autoload 'cmlisp "ilisp" "Run an inferior CM lisp." t)
|
|
72 ;;;
|
|
73 ;;; To define a new dialect use the macro defdialect. For examples,
|
|
74 ;;; look at the dialect definitions in this file. There are hooks and
|
|
75 ;;; variables for almost anything that you are likely to need to
|
|
76 ;;; change. The relationship between dialects is hierarchical with
|
|
77 ;;; the root values being defined in setup-ilisp. For a new dialect,
|
|
78 ;;; you only need to change the variables that are different than in
|
|
79 ;;; the parent dialect.
|
|
80
|
|
81
|
|
82 ;;;
|
|
83 ;;; ILISP dialect definition code.
|
|
84 ;;;
|
|
85
|
|
86 ;;;%Dialects
|
|
87 (defun lisp-add-dialect (dialect)
|
|
88 "Add DIALECT as a supported ILISP dialect."
|
|
89 (if (not (lisp-memk dialect ilisp-dialects 'car))
|
|
90 (setq ilisp-dialects
|
|
91 (cons (list dialect) ilisp-dialects))))
|
|
92
|
|
93 ;;;
|
|
94 (defun ilisp-start-dialect (buffer program setup)
|
|
95 ;; Allow dialects to be started from command line
|
|
96 (if (eq current-prefix-arg 0) (setq current-prefix-arg nil))
|
|
97 (setq ilisp-last-buffer (current-buffer)
|
|
98 buffer (if current-prefix-arg
|
|
99 (read-from-minibuffer "Buffer: " buffer)
|
|
100 buffer))
|
|
101 (funcall setup buffer)
|
|
102 (setq ilisp-program
|
|
103 (or program
|
|
104 (if current-prefix-arg
|
|
105 (lisp-read-program "Program: " ilisp-program)
|
|
106 ilisp-program)))
|
|
107 (ilisp buffer setup))
|
|
108
|
|
109 ;;;
|
|
110 (defmacro defdialect (dialect full-name parent &rest body)
|
|
111 "Define a new ILISP dialect. DIALECT is the name of the function to
|
|
112 invoke the inferior LISP. The hook for that LISP will be called
|
|
113 DIALECT-hook. The default program will be DIALECT-program. FULL-NAME
|
|
114 is a string that describes the inferior LISP. PARENT is the name of
|
|
115 the parent dialect."
|
|
116 (let ((setup (read (format "setup-%s" dialect)))
|
|
117 (hook (read (format "%s-hook" dialect)))
|
|
118 (program (read (format "%s-program" dialect)))
|
|
119 (dialects (format "%s" dialect)))
|
|
120 (`
|
|
121 (progn
|
|
122 (defvar (, hook) nil (, (format "*Inferior %s hook." full-name)))
|
|
123 (defvar (, program) nil
|
|
124 (, (format "*Inferior %s default program." full-name)))
|
|
125 (defun (, setup) (buffer)
|
|
126 (, (format "Set up for interacting with %s." full-name))
|
|
127 (, (read (format "(setup-%s buffer)" parent)))
|
|
128 (,@ body)
|
|
129 (setq ilisp-program (or (, program) ilisp-program)
|
|
130 ilisp-dialect (cons '(, dialect) ilisp-dialect))
|
|
131 (run-hooks '(, (read (format "%s-hook" dialect)))))
|
|
132 (defun (, dialect) (&optional buffer program)
|
|
133 (, (format "Create an inferior %s. With prefix, prompt for buffer and program."
|
|
134 full-name))
|
|
135 (interactive (list nil nil))
|
|
136 (ilisp-start-dialect (or buffer (, dialects))
|
|
137 program
|
|
138 '(, setup))
|
|
139 (setq (, program) ilisp-program))
|
|
140 (lisp-add-dialect (, dialects))))))
|
|
141
|
|
142 ;;;%%ilisp
|
|
143 (defun setup-ilisp (buffer)
|
|
144 "Set up for interacting with an inferior LISP."
|
|
145 (set-buffer (get-buffer-create "*ilisp-send*"))
|
|
146 (kill-all-local-variables)
|
|
147 (lisp-mode)
|
|
148 (setq ilisp-buffer (format "*%s*" buffer))
|
|
149 (set-buffer (get-buffer-create ilisp-buffer))
|
|
150 (setq major-mode 'ilisp-mode
|
|
151 mode-name "ILISP")
|
|
152 (lisp-mode-variables t)
|
|
153 ;; Set variables to nil
|
|
154 (let ((binary ilisp-binary-extension)
|
|
155 (init ilisp-init-binary-extension)
|
|
156 (vars ilisp-locals))
|
|
157 (while (not (null vars))
|
|
158 (make-local-variable (car vars))
|
|
159 (set (car vars) nil)
|
|
160 (setq vars (cdr vars)))
|
|
161 ;; Preserve from initialization
|
|
162 (if binary (setq ilisp-binary-extension binary))
|
|
163 (if init (setq ilisp-init-binary-extension init)))
|
|
164 ;; Comint defaults
|
|
165 (set-ilisp-input-ring-size 200)
|
|
166 (setq comint-prompt-regexp "^[^<> ]*>+:? *"
|
|
167
|
|
168 comint-get-old-input 'ilisp-get-old-input
|
|
169 comint-input-sentinel (function ignore)
|
|
170 comint-input-filter 'ilisp-input-filter
|
|
171 comint-input-sender 'comint-default-send
|
|
172 comint-eol-on-send t)
|
|
173 ;; Comint-ipc defaults
|
|
174 (setq comint-send-newline t
|
|
175 comint-always-scroll nil
|
|
176 comint-output-buffer " *Output*"
|
|
177 comint-error-buffer " *Error Output*"
|
|
178 comint-error-regexp "^\"ILISP:"
|
|
179 comint-output-filter (function identity)
|
|
180 comint-interrupt-start 'comint-interrupt-start
|
|
181 comint-handler 'ilisp-handler
|
|
182 comint-update-status 'ilisp-update-status
|
|
183 comint-prompt-status 'comint-prompt-status
|
|
184 comint-abort-hook 'ilisp-abort-handler)
|
|
185 (setq ilisp-use-map ilisp-mode-map
|
|
186 ilisp-init-hook '((lambda () (ilisp-init nil nil t)))
|
|
187 ilisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)*\\)?\\s *\\'"
|
|
188 ilisp-filter-length 3
|
|
189 ilisp-error-filter 'ilisp-error-filter
|
|
190 ilisp-error-regexp ".*"
|
|
191 ilisp-symbol-delimiters "^ \t\n\('\"#.\)<>"
|
|
192 ilisp-program "lisp"
|
|
193 ilisp-locator 'lisp-locate-ilisp
|
|
194 ilisp-calls-locator 'lisp-locate-calls)
|
|
195 (run-hooks 'ilisp-mode-hook))
|
|
196
|
|
197 (defun run-ilisp ()
|
|
198 "Create an inferior LISP prompting for dialect. With prefix, prompt
|
|
199 for buffer name as well."
|
|
200 (interactive)
|
|
201 (let ((dialect (completing-read "Dialect: " ilisp-dialects nil t)))
|
|
202 (if (not (zerop (length dialect)))
|
|
203 (call-interactively (read dialect)))))
|
|
204
|