aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Blandy1992-07-21 23:40:16 +0000
committerJim Blandy1992-07-21 23:40:16 +0000
commit926d501901d8e649781471731c35dddcc48e6ce7 (patch)
tree89831f2614305bf97fb874f12de68c0ac765d6dd
parent520412198b953b6c36d933822dac8bab0852a279 (diff)
downloademacs-926d501901d8e649781471731c35dddcc48e6ce7.tar.gz
emacs-926d501901d8e649781471731c35dddcc48e6ce7.zip
*** empty log message ***
-rw-r--r--lisp/progmodes/inf-lisp.el369
1 files changed, 196 insertions, 173 deletions
diff --git a/lisp/progmodes/inf-lisp.el b/lisp/progmodes/inf-lisp.el
index 806c648826a..05b62d56204 100644
--- a/lisp/progmodes/inf-lisp.el
+++ b/lisp/progmodes/inf-lisp.el
@@ -1,30 +1,36 @@
1;;; cmulisp.el --- improved version of standard inferior-lisp mode 1;;; inf-lisp.el --- an inferior-lisp mode
2 2
3;; Author: Olin Shivers <shivers@cs.cmu.edu> 3;; Author: Olin Shivers <shivers@cs.cmu.edu>
4;; Last-Modified: 16 Jul 1993 4;; Last-Modified: 16 Jul 1992
5;; Keyword: processes, lisp 5;; Keyword: processes, lisp
6 6
7;;; Copyright Olin Shivers (1988). 7;;; Copyright Olin Shivers (1988).
8;;; Please imagine a long, tedious, legalistic 5-page gnu-style copyright 8
9;;; notice appearing here to the effect that you may use this code any 9;;; This file is part of GNU Emacs.
10;;; way you like, as long as you don't charge money for it, remove this 10
11;;; notice, or hold me liable for its results. 11;;; GNU Emacs is free software; you can redistribute it and/or modify
12;;; it under the terms of the GNU General Public License as published by
13;;; the Free Software Foundation; either version 2, or (at your option)
14;;; any later version.
15
16;;; GNU Emacs is distributed in the hope that it will be useful,
17;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;;; GNU General Public License for more details.
20
21;;; You should have received a copy of the GNU General Public License
22;;; along with GNU Emacs; see the file COPYING. If not, write to
23;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
12 24
13;;; Commentary: 25;;; Commentary:
14 26
15;;; This replaces the standard inferior-lisp mode.
16;;; Hacked from tea.el by Olin Shivers (shivers@cs.cmu.edu). 8/88 27;;; Hacked from tea.el by Olin Shivers (shivers@cs.cmu.edu). 8/88
17;;; Please send me bug reports, bug fixes, and extensions, so that I can
18;;; merge them into the master source.
19;;;
20;;; Change log at end of file.
21 28
22;;; This file defines a a lisp-in-a-buffer package (cmulisp mode) built on top 29;;; This file defines a a lisp-in-a-buffer package (inferior-lisp
23;;; of comint mode. Cmulisp mode is similar to, and intended to replace, its 30;;; mode) built on top of comint mode. This version is more
24;;; counterpart in the standard gnu emacs release. This replacements is more 31;;; featureful, robust, and uniform than the Emacs 18 version. The
25;;; featureful, robust, and uniform than the released version. The key 32;;; key bindings are also more compatible with the bindings of Hemlock
26;;; bindings are also more compatible with the bindings of Hemlock and Zwei 33;;; and Zwei (the Lisp Machine emacs).
27;;; (the Lisp Machine emacs).
28 34
29;;; Since this mode is built on top of the general command-interpreter-in- 35;;; Since this mode is built on top of the general command-interpreter-in-
30;;; a-buffer mode (comint mode), it shares a common base functionality, 36;;; a-buffer mode (comint mode), it shares a common base functionality,
@@ -33,7 +39,7 @@
33 39
34;;; For documentation on the functionality provided by comint mode, and 40;;; For documentation on the functionality provided by comint mode, and
35;;; the hooks available for customising it, see the file comint.el. 41;;; the hooks available for customising it, see the file comint.el.
36;;; For further information on cmulisp mode, see the comments below. 42;;; For further information on inferior-lisp mode, see the comments below.
37 43
38;;; Needs fixin: 44;;; Needs fixin:
39;;; The load-file/compile-file default mechanism could be smarter -- it 45;;; The load-file/compile-file default mechanism could be smarter -- it
@@ -44,7 +50,7 @@
44;;; because the extension for executable files varies so much (.o, .bin, 50;;; because the extension for executable files varies so much (.o, .bin,
45;;; .lbin, .mo, .vo, .ao, ...). 51;;; .lbin, .mo, .vo, .ao, ...).
46;;; 52;;;
47;;; It would be nice if cmulisp (and inferior scheme, T, ...) modes 53;;; It would be nice if inferior-lisp (and inferior scheme, T, ...) modes
48;;; had a verbose minor mode wherein sending or compiling defuns, etc. 54;;; had a verbose minor mode wherein sending or compiling defuns, etc.
49;;; would be reflected in the transcript with suitable comments, e.g. 55;;; would be reflected in the transcript with suitable comments, e.g.
50;;; ";;; redefining fact". Several ways to do this. Which is right? 56;;; ";;; redefining fact". Several ways to do this. Which is right?
@@ -58,24 +64,25 @@
58;;============================================================================= 64;;=============================================================================
59;; Some suggestions for your .emacs file. 65;; Some suggestions for your .emacs file.
60;; 66;;
61;; ; If cmulisp lives in some non-standard directory, you must tell emacs 67;; ; If inferior-lisp lives in some non-standard directory, you must tell emacs
62;; ; where to get it. This may or may not be necessary. 68;; ; where to get it. This may or may not be necessary.
63;; (setq load-path (cons (expand-file-name "~jones/lib/emacs") load-path)) 69;; (setq load-path (cons (expand-file-name "~jones/lib/emacs") load-path))
64;; 70;;
65;; ; Autoload cmulisp from file cmulisp.el 71;; ; Autoload inferior-lisp from file inf-lisp.el
66;; (autoload 'cmulisp "cmulisp" 72;; (autoload 'inferior-lisp "inferior-lisp"
67;; "Run an inferior Lisp process." 73;; "Run an inferior Lisp process."
68;; t) 74;; t)
69;; 75;;
70;; ; Define C-c t to run my favorite command in cmulisp mode: 76;; ; Define C-c t to run my favorite command in inferior-lisp mode:
71;; (setq cmulisp-load-hook 77;; (setq inferior-lisp-load-hook
72;; '((lambda () 78;; '((lambda ()
73;; (define-key cmulisp-mode-map "\C-ct" 'favorite-cmd)))) 79;; (define-key inferior-lisp-mode-map "\C-ct" 'favorite-cmd))))
74 80
75 81
76;;; Brief Command Documentation: 82;;; Brief Command Documentation:
77;;;============================================================================ 83;;;============================================================================
78;;; Comint Mode Commands: (common to cmulisp and all comint-derived modes) 84;;; Comint Mode Commands: (common to inferior-lisp and all
85;;; comint-derived modes)
79;;; 86;;;
80;;; m-p comint-previous-input Cycle backwards in input history 87;;; m-p comint-previous-input Cycle backwards in input history
81;;; m-n comint-next-input Cycle forwards 88;;; m-n comint-next-input Cycle forwards
@@ -95,7 +102,7 @@
95;;; top-level job. 102;;; top-level job.
96;;; comint-mode-hook is the comint mode hook. 103;;; comint-mode-hook is the comint mode hook.
97 104
98;;; CMU Lisp Mode Commands: 105;;; Inferior Lisp Mode Commands:
99;;; c-m-x lisp-send-defun This binding is a gnu convention. 106;;; c-m-x lisp-send-defun This binding is a gnu convention.
100;;; c-c c-l lisp-load-file Prompt for file name; tell Lisp to load it. 107;;; c-c c-l lisp-load-file Prompt for file name; tell Lisp to load it.
101;;; c-c c-k lisp-compile-file Prompt for file name; tell Lisp to kompile it. 108;;; c-c c-k lisp-compile-file Prompt for file name; tell Lisp to kompile it.
@@ -115,14 +122,14 @@
115;;; c-c c-f lisp-show-function-documentation Query Lisp for a function's doc. 122;;; c-c c-f lisp-show-function-documentation Query Lisp for a function's doc.
116;;; c-c c-v lisp-show-variable-documentation Query Lisp for a variable's doc. 123;;; c-c c-v lisp-show-variable-documentation Query Lisp for a variable's doc.
117 124
118;;; cmulisp Fires up the Lisp process. 125;;; inferior-lisp Fires up the Lisp process.
119;;; lisp-compile-region Compile all forms in the current region. 126;;; lisp-compile-region Compile all forms in the current region.
120;;; 127;;;
121;;; CMU Lisp Mode Variables: 128;;; Inferior Lisp Mode Variables:
122;;; cmulisp-filter-regexp Match this => don't get saved on input hist 129;;; inferior-lisp-filter-regexp Match this => don't get saved on input hist
123;;; inferior-lisp-program Name of Lisp program run-lisp executes 130;;; inferior-lisp-program Name of Lisp program run-lisp executes
124;;; inferior-lisp-load-command Customises lisp-load-file 131;;; inferior-lisp-load-command Customises lisp-load-file
125;;; cmulisp-mode-hook 132;;; inferior-lisp-mode-hook
126;;; inferior-lisp-prompt Initialises comint-prompt-regexp. 133;;; inferior-lisp-prompt Initialises comint-prompt-regexp.
127;;; Backwards compatibility. 134;;; Backwards compatibility.
128;;; lisp-source-modes Anything loaded into a buffer that's in 135;;; lisp-source-modes Anything loaded into a buffer that's in
@@ -135,24 +142,27 @@
135 142
136(require 'comint) 143(require 'comint)
137 144
138(defvar cmulisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'" 145(defvar inferior-lisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'"
139 "*What not to save on inferior Lisp's input history 146 "*What not to save on inferior Lisp's input history
140Input matching this regexp is not saved on the input history in cmulisp 147Input matching this regexp is not saved on the input history in inferior-lisp
141mode. Default is whitespace followed by 0 or 1 single-letter :keyword 148mode. Default is whitespace followed by 0 or 1 single-letter :keyword
142(as in :a, :c, etc.)") 149(as in :a, :c, etc.)")
143 150
144(defvar cmulisp-mode-map nil) 151(defvar inferior-lisp-mode-map nil)
145(cond ((not cmulisp-mode-map) 152(cond ((not inferior-lisp-mode-map)
146 (setq cmulisp-mode-map 153 (setq inferior-lisp-mode-map
147 (full-copy-sparse-keymap comint-mode-map)) 154 (full-copy-sparse-keymap comint-mode-map))
148 (lisp-mode-commands cmulisp-mode-map) 155 (setq inferior-lisp-mode-map
149 (define-key cmulisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp) 156 (nconc inferior-lisp-mode-map shared-lisp-mode-map))
150 (define-key cmulisp-mode-map "\C-c\C-l" 'lisp-load-file) 157 (define-key inferior-lisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp)
151 (define-key cmulisp-mode-map "\C-c\C-k" 'lisp-compile-file) 158 (define-key inferior-lisp-mode-map "\C-c\C-l" 'lisp-load-file)
152 (define-key cmulisp-mode-map "\C-c\C-a" 'lisp-show-arglist) 159 (define-key inferior-lisp-mode-map "\C-c\C-k" 'lisp-compile-file)
153 (define-key cmulisp-mode-map "\C-c\C-d" 'lisp-describe-sym) 160 (define-key inferior-lisp-mode-map "\C-c\C-a" 'lisp-show-arglist)
154 (define-key cmulisp-mode-map "\C-c\C-f" 'lisp-show-function-documentation) 161 (define-key inferior-lisp-mode-map "\C-c\C-d" 'lisp-describe-sym)
155 (define-key cmulisp-mode-map "\C-c\C-v" 'lisp-show-variable-documentation))) 162 (define-key inferior-lisp-mode-map "\C-c\C-f"
163 'lisp-show-function-documentation)
164 (define-key inferior-lisp-mode-map "\C-c\C-v"
165 'lisp-show-variable-documentation)))
156 166
157;;; These commands augment Lisp mode, so you can process Lisp code in 167;;; These commands augment Lisp mode, so you can process Lisp code in
158;;; the source files. 168;;; the source files.
@@ -174,14 +184,14 @@ mode. Default is whitespace followed by 0 or 1 single-letter :keyword
174;;; Previous versions of this package bound commands to C-c <letter> 184;;; Previous versions of this package bound commands to C-c <letter>
175;;; bindings, which is not allowed by the gnumacs standard. 185;;; bindings, which is not allowed by the gnumacs standard.
176 186
177(defun cmulisp-install-letter-bindings () 187(defun inferior-lisp-install-letter-bindings ()
178 "This function binds many cmulisp commands to C-c <letter> bindings, 188 "This function binds many inferior-lisp commands to C-c <letter> bindings,
179where they are more accessible. C-c <letter> bindings are reserved for the 189where they are more accessible. C-c <letter> bindings are reserved for the
180user, so these bindings are non-standard. If you want them, you should 190user, so these bindings are non-standard. If you want them, you should
181have this function called by the cmulisp-load-hook: 191have this function called by the inferior-lisp-load-hook:
182 (setq cmulisp-load-hook '(cmulisp-install-letter-bindings)) 192 (setq inferior-lisp-load-hook '(inferior-lisp-install-letter-bindings))
183You can modify this function to install just the bindings you want." 193You can modify this function to install just the bindings you want."
184 194
185 (define-key lisp-mode-map "\C-ce" 'lisp-eval-defun-and-go) 195 (define-key lisp-mode-map "\C-ce" 'lisp-eval-defun-and-go)
186 (define-key lisp-mode-map "\C-cr" 'lisp-eval-region-and-go) 196 (define-key lisp-mode-map "\C-cr" 'lisp-eval-region-and-go)
187 (define-key lisp-mode-map "\C-cc" 'lisp-compile-defun-and-go) 197 (define-key lisp-mode-map "\C-cc" 'lisp-compile-defun-and-go)
@@ -192,17 +202,18 @@ You can modify this function to install just the bindings you want."
192 (define-key lisp-mode-map "\C-cd" 'lisp-describe-sym) 202 (define-key lisp-mode-map "\C-cd" 'lisp-describe-sym)
193 (define-key lisp-mode-map "\C-cf" 'lisp-show-function-documentation) 203 (define-key lisp-mode-map "\C-cf" 'lisp-show-function-documentation)
194 (define-key lisp-mode-map "\C-cv" 'lisp-show-variable-documentation) 204 (define-key lisp-mode-map "\C-cv" 'lisp-show-variable-documentation)
195 205
196 (define-key cmulisp-mode-map "\C-cl" 'lisp-load-file) 206 (define-key inferior-lisp-mode-map "\C-cl" 'lisp-load-file)
197 (define-key cmulisp-mode-map "\C-ck" 'lisp-compile-file) 207 (define-key inferior-lisp-mode-map "\C-ck" 'lisp-compile-file)
198 (define-key cmulisp-mode-map "\C-ca" 'lisp-show-arglist) 208 (define-key inferior-lisp-mode-map "\C-ca" 'lisp-show-arglist)
199 (define-key cmulisp-mode-map "\C-cd" 'lisp-describe-sym) 209 (define-key inferior-lisp-mode-map "\C-cd" 'lisp-describe-sym)
200 (define-key cmulisp-mode-map "\C-cf" 'lisp-show-function-documentation) 210 (define-key inferior-lisp-mode-map "\C-cf" 'lisp-show-function-documentation)
201 (define-key cmulisp-mode-map "\C-cv" 'lisp-show-variable-documentation)) 211 (define-key inferior-lisp-mode-map "\C-cv"
212 'lisp-show-variable-documentation))
202 213
203 214
204(defvar inferior-lisp-program "lisp" 215(defvar inferior-lisp-program "lisp"
205 "*Program name for invoking an inferior Lisp with `cmulisp'.") 216 "*Program name for invoking an inferior Lisp with `inferior-lisp'.")
206 217
207(defvar inferior-lisp-load-command "(load \"%s\")\n" 218(defvar inferior-lisp-load-command "(load \"%s\")\n"
208 "*Format-string for building a Lisp expression to load a file. 219 "*Format-string for building a Lisp expression to load a file.
@@ -217,7 +228,7 @@ but it works only in Common Lisp.")
217 "Regexp to recognise prompts in the inferior Lisp. 228 "Regexp to recognise prompts in the inferior Lisp.
218Defaults to \"^[^> ]*>+:? *\", which works pretty good for Lucid, kcl, 229Defaults to \"^[^> ]*>+:? *\", which works pretty good for Lucid, kcl,
219and franz. This variable is used to initialise comint-prompt-regexp in the 230and franz. This variable is used to initialise comint-prompt-regexp in the
220cmulisp buffer. 231inferior-lisp buffer.
221 232
222More precise choices: 233More precise choices:
223Lucid Common Lisp: \"^\\(>\\|\\(->\\)+\\) *\" 234Lucid Common Lisp: \"^\\(>\\|\\(->\\)+\\) *\"
@@ -226,24 +237,24 @@ kcl: \"^>+ *\"
226 237
227This is a fine thing to set in your .emacs file.") 238This is a fine thing to set in your .emacs file.")
228 239
229(defvar cmulisp-mode-hook '() 240(defvar inferior-lisp-mode-hook '()
230 "*Hook for customising cmulisp mode") 241 "*Hook for customising inferior-lisp mode")
231 242
232(defun cmulisp-mode () 243(defun inferior-lisp-mode ()
233 "Major mode for interacting with an inferior Lisp process. 244 "Major mode for interacting with an inferior Lisp process.
234Runs a Lisp interpreter as a subprocess of Emacs, with Lisp I/O through an 245Runs a Lisp interpreter as a subprocess of Emacs, with Lisp I/O through an
235Emacs buffer. Variable inferior-lisp-program controls which Lisp interpreter 246Emacs buffer. Variable inferior-lisp-program controls which Lisp interpreter
236is run. Variables inferior-lisp-prompt, cmulisp-filter-regexp and 247is run. Variables inferior-lisp-prompt, inferior-lisp-filter-regexp and
237inferior-lisp-load-command can customize this mode for different Lisp 248inferior-lisp-load-command can customize this mode for different Lisp
238interpreters. 249interpreters.
239 250
240For information on running multiple processes in multiple buffers, see 251For information on running multiple processes in multiple buffers, see
241documentation for variable cmulisp-buffer. 252documentation for variable inferior-lisp-buffer.
242 253
243\\{cmulisp-mode-map} 254\\{inferior-lisp-mode-map}
244 255
245Customisation: Entry to this mode runs the hooks on comint-mode-hook and 256Customisation: Entry to this mode runs the hooks on comint-mode-hook and
246cmulisp-mode-hook (in that order). 257inferior-lisp-mode-hook (in that order).
247 258
248You can send text to the inferior Lisp process from other buffers containing 259You can send text to the inferior Lisp process from other buffers containing
249Lisp source. 260Lisp source.
@@ -272,17 +283,15 @@ to continue it."
272 (interactive) 283 (interactive)
273 (comint-mode) 284 (comint-mode)
274 (setq comint-prompt-regexp inferior-lisp-prompt) 285 (setq comint-prompt-regexp inferior-lisp-prompt)
275 (setq major-mode 'cmulisp-mode) 286 (setq major-mode 'inferior-lisp-mode)
276 (setq mode-name "CMU Lisp") 287 (setq mode-name "Inferior Lisp")
277 (setq mode-line-process '(": %s")) 288 (setq mode-line-process '(": %s"))
278 (if (string-match "^18.4" emacs-version) ; hack. 289 (lisp-mode-variables t)
279 (lisp-mode-variables) ; This is right for 18.49 290 (use-local-map inferior-lisp-mode-map) ;c-c c-k for "kompile" file
280 (lisp-mode-variables t)) ; This is right for 18.50
281 (use-local-map cmulisp-mode-map) ;c-c c-k for "kompile" file
282 (setq comint-get-old-input (function lisp-get-old-input)) 291 (setq comint-get-old-input (function lisp-get-old-input))
283 (setq comint-input-filter (function lisp-input-filter)) 292 (setq comint-input-filter (function lisp-input-filter))
284 (setq comint-input-sentinel 'ignore) 293 (setq comint-input-sentinel 'ignore)
285 (run-hooks 'cmulisp-mode-hook)) 294 (run-hooks 'inferior-lisp-mode-hook))
286 295
287(defun lisp-get-old-input () 296(defun lisp-get-old-input ()
288 "Snarf the sexp ending at point" 297 "Snarf the sexp ending at point"
@@ -292,49 +301,52 @@ to continue it."
292 (buffer-substring (point) end)))) 301 (buffer-substring (point) end))))
293 302
294(defun lisp-input-filter (str) 303(defun lisp-input-filter (str)
295 "Don't save anything matching cmulisp-filter-regexp" 304 "Don't save anything matching inferior-lisp-filter-regexp"
296 (not (string-match cmulisp-filter-regexp str))) 305 (not (string-match inferior-lisp-filter-regexp str)))
297 306
298(defun cmulisp (cmd) 307(defun inferior-lisp (cmd)
299 "Run an inferior Lisp process, input and output via buffer *cmulisp*. 308 "Run an inferior Lisp process, input and output via buffer *inferior-lisp*.
300If there is a process already running in *cmulisp*, just switch to that buffer. 309If there is a process already running in *inferior-lisp*, just switch
310to that buffer.
301With argument, allows you to edit the command line (default is value 311With argument, allows you to edit the command line (default is value
302of inferior-lisp-program). Runs the hooks from cmulisp-mode-hook (after the 312of inferior-lisp-program). Runs the hooks from
303comint-mode-hook is run). 313inferior-lisp-mode-hook (after the comint-mode-hook is run).
304\(Type \\[describe-mode] in the process buffer for a list of commands.)" 314\(Type \\[describe-mode] in the process buffer for a list of commands.)"
305 (interactive (list (if current-prefix-arg 315 (interactive (list (if current-prefix-arg
306 (read-string "Run lisp: " inferior-lisp-program) 316 (read-string "Run lisp: " inferior-lisp-program)
307 inferior-lisp-program))) 317 inferior-lisp-program)))
308 (if (not (comint-check-proc "*cmulisp*")) 318 (if (not (comint-check-proc "*inferior-lisp*"))
309 (let ((cmdlist (cmulisp-args-to-list cmd))) 319 (let ((cmdlist (inferior-lisp-args-to-list cmd)))
310 (set-buffer (apply (function make-comint) "cmulisp" (car cmdlist) nil 320 (set-buffer (apply (function make-comint)
311 (cdr cmdlist))) 321 "inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
312 (cmulisp-mode))) 322 (inferior-lisp-mode)))
313 (setq cmulisp-buffer "*cmulisp*") 323 (setq inferior-lisp-buffer "*inferior-lisp*")
314 (switch-to-buffer "*cmulisp*")) 324 (switch-to-buffer "*inferior-lisp*"))
325
326(fset 'run-lisp 'inferior-lisp)
315 327
316;;; Break a string up into a list of arguments. 328;;; Break a string up into a list of arguments.
317;;; This will break if you have an argument with whitespace, as in 329;;; This will break if you have an argument with whitespace, as in
318;;; string = "-ab +c -x 'you lose'". 330;;; string = "-ab +c -x 'you lose'".
319(defun cmulisp-args-to-list (string) 331(defun inferior-lisp-args-to-list (string)
320 (let ((where (string-match "[ \t]" string))) 332 (let ((where (string-match "[ \t]" string)))
321 (cond ((null where) (list string)) 333 (cond ((null where) (list string))
322 ((not (= where 0)) 334 ((not (= where 0))
323 (cons (substring string 0 where) 335 (cons (substring string 0 where)
324 (tea-args-to-list (substring string (+ 1 where) 336 (inferior-lisp-args-to-list (substring string (+ 1 where)
325 (length string))))) 337 (length string)))))
326 (t (let ((pos (string-match "[^ \t]" string))) 338 (t (let ((pos (string-match "[^ \t]" string)))
327 (if (null pos) 339 (if (null pos)
328 nil 340 nil
329 (cmulsip-args-to-list (substring string pos 341 (inferior-lisp-args-to-list (substring string pos
330 (length string))))))))) 342 (length string)))))))))
331 343
332(defun lisp-eval-region (start end &optional and-go) 344(defun lisp-eval-region (start end &optional and-go)
333 "Send the current region to the inferior Lisp process. 345 "Send the current region to the inferior Lisp process.
334Prefix argument means switch-to-lisp afterwards." 346Prefix argument means switch-to-lisp afterwards."
335 (interactive "r\nP") 347 (interactive "r\nP")
336 (comint-send-region (cmulisp-proc) start end) 348 (comint-send-region (inferior-lisp-proc) start end)
337 (comint-send-string (cmulisp-proc) "\n") 349 (comint-send-string (inferior-lisp-proc) "\n")
338 (if and-go (switch-to-lisp t))) 350 (if and-go (switch-to-lisp t)))
339 351
340(defun lisp-eval-defun (&optional and-go) 352(defun lisp-eval-defun (&optional and-go)
@@ -360,11 +372,12 @@ Prefix argument means switch-to-lisp afterwards."
360 "Compile the current region in the inferior Lisp process. 372 "Compile the current region in the inferior Lisp process.
361Prefix argument means switch-to-lisp afterwards." 373Prefix argument means switch-to-lisp afterwards."
362 (interactive "r\nP") 374 (interactive "r\nP")
363 (comint-send-string (cmulisp-proc) 375 (comint-send-string
364 (format "(funcall (compile nil `(lambda () (progn 'compile %s))))\n" 376 (inferior-lisp-proc)
365 (buffer-substring start end))) 377 (format "(funcall (compile nil `(lambda () (progn 'compile %s))))\n"
378 (buffer-substring start end)))
366 (if and-go (switch-to-lisp t))) 379 (if and-go (switch-to-lisp t)))
367 380
368(defun lisp-compile-defun (&optional and-go) 381(defun lisp-compile-defun (&optional and-go)
369 "Compile the current defun in the inferior Lisp process. 382 "Compile the current defun in the inferior Lisp process.
370Prefix argument means switch-to-lisp afterwards." 383Prefix argument means switch-to-lisp afterwards."
@@ -381,9 +394,9 @@ Prefix argument means switch-to-lisp afterwards."
381 "Switch to the inferior Lisp process buffer. 394 "Switch to the inferior Lisp process buffer.
382With argument, positions cursor at end of buffer." 395With argument, positions cursor at end of buffer."
383 (interactive "P") 396 (interactive "P")
384 (if (get-buffer cmulisp-buffer) 397 (if (get-buffer inferior-lisp-buffer)
385 (pop-to-buffer cmulisp-buffer) 398 (pop-to-buffer inferior-lisp-buffer)
386 (error "No current process buffer. See variable cmulisp-buffer.")) 399 (error "No current process buffer. See variable inferior-lisp-buffer."))
387 (cond (eob-p 400 (cond (eob-p
388 (push-mark) 401 (push-mark)
389 (goto-char (point-max))))) 402 (goto-char (point-max)))))
@@ -419,38 +432,40 @@ and switch to the process buffer."
419 (lisp-compile-defun t)) 432 (lisp-compile-defun t))
420 433
421;;; A version of the form in H. Shevis' soar-mode.el package. Less robust. 434;;; A version of the form in H. Shevis' soar-mode.el package. Less robust.
422;(defun lisp-compile-sexp (start end) 435;;; (defun lisp-compile-sexp (start end)
423; "Compile the s-expression bounded by START and END in the inferior lisp. 436;;; "Compile the s-expression bounded by START and END in the inferior lisp.
424;If the sexp isn't a DEFUN form, it is evaluated instead." 437;;; If the sexp isn't a DEFUN form, it is evaluated instead."
425; (cond ((looking-at "(defun\\s +") 438;;; (cond ((looking-at "(defun\\s +")
426; (goto-char (match-end 0)) 439;;; (goto-char (match-end 0))
427; (let ((name-start (point))) 440;;; (let ((name-start (point)))
428; (forward-sexp 1) 441;;; (forward-sexp 1)
429; (process-send-string "cmulisp" (format "(compile '%s #'(lambda " 442;;; (process-send-string "inferior-lisp"
430; (buffer-substring name-start 443;;; (format "(compile '%s #'(lambda "
431; (point))))) 444;;; (buffer-substring name-start
432; (let ((body-start (point))) 445;;; (point)))))
433; (goto-char start) (forward-sexp 1) ; Can't use end-of-defun. 446;;; (let ((body-start (point)))
434; (process-send-region "cmulisp" (buffer-substring body-start (point)))) 447;;; (goto-char start) (forward-sexp 1) ; Can't use end-of-defun.
435; (process-send-string "cmulisp" ")\n")) 448;;; (process-send-region "inferior-lisp"
436; (t (lisp-eval-region start end))))) 449;;; (buffer-substring body-start (point))))
437; 450;;; (process-send-string "inferior-lisp" ")\n"))
438;(defun lisp-compile-region (start end) 451;;; (t (lisp-eval-region start end)))))
439; "Each s-expression in the current region is compiled (if a DEFUN) 452;;;
440;or evaluated (if not) in the inferior lisp." 453;;; (defun lisp-compile-region (start end)
441; (interactive "r") 454;;; "Each s-expression in the current region is compiled (if a DEFUN)
442; (save-excursion 455;;; or evaluated (if not) in the inferior lisp."
443; (goto-char start) (end-of-defun) (beginning-of-defun) ; error check 456;;; (interactive "r")
444; (if (< (point) start) (error "region begins in middle of defun")) 457;;; (save-excursion
445; (goto-char start) 458;;; (goto-char start) (end-of-defun) (beginning-of-defun) ; error check
446; (let ((s start)) 459;;; (if (< (point) start) (error "region begins in middle of defun"))
447; (end-of-defun) 460;;; (goto-char start)
448; (while (<= (point) end) ; Zip through 461;;; (let ((s start))
449; (lisp-compile-sexp s (point)) ; compiling up defun-sized chunks. 462;;; (end-of-defun)
450; (setq s (point)) 463;;; (while (<= (point) end) ; Zip through
451; (end-of-defun)) 464;;; (lisp-compile-sexp s (point)) ; compiling up defun-sized chunks.
452; (if (< s end) (lisp-compile-sexp s end))))) 465;;; (setq s (point))
453;;; 466;;; (end-of-defun))
467;;; (if (< s end) (lisp-compile-sexp s end)))))
468;;;
454;;; End of HS-style code 469;;; End of HS-style code
455 470
456 471
@@ -469,11 +484,11 @@ Used by these commands to determine defaults.")
469 "Load a Lisp file into the inferior Lisp process." 484 "Load a Lisp file into the inferior Lisp process."
470 (interactive (comint-get-source "Load Lisp file: " lisp-prev-l/c-dir/file 485 (interactive (comint-get-source "Load Lisp file: " lisp-prev-l/c-dir/file
471 lisp-source-modes nil)) ; NIL because LOAD 486 lisp-source-modes nil)) ; NIL because LOAD
472 ; doesn't need an exact name 487 ; doesn't need an exact name
473 (comint-check-source file-name) ; Check to see if buffer needs saved. 488 (comint-check-source file-name) ; Check to see if buffer needs saved.
474 (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name) 489 (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name)
475 (file-name-nondirectory file-name))) 490 (file-name-nondirectory file-name)))
476 (comint-send-string (cmulisp-proc) 491 (comint-send-string (inferior-lisp-proc)
477 (format inferior-lisp-load-command file-name)) 492 (format inferior-lisp-load-command file-name))
478 (switch-to-lisp t)) 493 (switch-to-lisp t))
479 494
@@ -482,13 +497,13 @@ Used by these commands to determine defaults.")
482 "Compile a Lisp file in the inferior Lisp process." 497 "Compile a Lisp file in the inferior Lisp process."
483 (interactive (comint-get-source "Compile Lisp file: " lisp-prev-l/c-dir/file 498 (interactive (comint-get-source "Compile Lisp file: " lisp-prev-l/c-dir/file
484 lisp-source-modes nil)) ; NIL = don't need 499 lisp-source-modes nil)) ; NIL = don't need
485 ; suffix .lisp 500 ; suffix .lisp
486 (comint-check-source file-name) ; Check to see if buffer needs saved. 501 (comint-check-source file-name) ; Check to see if buffer needs saved.
487 (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name) 502 (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name)
488 (file-name-nondirectory file-name))) 503 (file-name-nondirectory file-name)))
489 (comint-send-string (cmulisp-proc) (concat "(compile-file \"" 504 (comint-send-string (inferior-lisp-proc) (concat "(compile-file \""
490 file-name 505 file-name
491 "\"\)\n")) 506 "\"\)\n"))
492 (switch-to-lisp t)) 507 (switch-to-lisp t))
493 508
494 509
@@ -532,7 +547,7 @@ Used by these commands to determine defaults.")
532(defun lisp-symprompt (prompt default) 547(defun lisp-symprompt (prompt default)
533 (list (let* ((prompt (if default 548 (list (let* ((prompt (if default
534 (format "%s (default %s): " prompt default) 549 (format "%s (default %s): " prompt default)
535 (concat prompt ": "))) 550 (concat prompt ": ")))
536 (ans (read-string prompt))) 551 (ans (read-string prompt)))
537 (if (zerop (length ans)) default ans)))) 552 (if (zerop (length ans)) default ans))))
538 553
@@ -570,60 +585,64 @@ Nil if it can't find one."
570 "Send a command to the inferior Lisp to give documentation for function FN. 585 "Send a command to the inferior Lisp to give documentation for function FN.
571See variable lisp-function-doc-command." 586See variable lisp-function-doc-command."
572 (interactive (lisp-symprompt "Function doc" (lisp-fn-called-at-pt))) 587 (interactive (lisp-symprompt "Function doc" (lisp-fn-called-at-pt)))
573 (comint-proc-query (cmulisp-proc) (format lisp-function-doc-command fn))) 588 (comint-proc-query (inferior-lisp-proc)
589 (format lisp-function-doc-command fn)))
574 590
575(defun lisp-show-variable-documentation (var) 591(defun lisp-show-variable-documentation (var)
576 "Send a command to the inferior Lisp to give documentation for function FN. 592 "Send a command to the inferior Lisp to give documentation for function FN.
577See variable lisp-var-doc-command." 593See variable lisp-var-doc-command."
578 (interactive (lisp-symprompt "Variable doc" (lisp-var-at-pt))) 594 (interactive (lisp-symprompt "Variable doc" (lisp-var-at-pt)))
579 (comint-proc-query (cmulisp-proc) (format lisp-var-doc-command var))) 595 (comint-proc-query (inferior-lisp-proc) (format lisp-var-doc-command var)))
580 596
581(defun lisp-show-arglist (fn) 597(defun lisp-show-arglist (fn)
582 "Sends an query to the inferior Lisp for the arglist for function FN. 598 "Sends an query to the inferior Lisp for the arglist for function FN.
583See variable lisp-arglist-command." 599See variable lisp-arglist-command."
584 (interactive (lisp-symprompt "Arglist" (lisp-fn-called-at-pt))) 600 (interactive (lisp-symprompt "Arglist" (lisp-fn-called-at-pt)))
585 (comint-proc-query (cmulisp-proc) (format lisp-arglist-command fn))) 601 (comint-proc-query (inferior-lisp-proc) (format lisp-arglist-command fn)))
586 602
587(defun lisp-describe-sym (sym) 603(defun lisp-describe-sym (sym)
588 "Send a command to the inferior Lisp to describe symbol SYM. 604 "Send a command to the inferior Lisp to describe symbol SYM.
589See variable lisp-describe-sym-command." 605See variable lisp-describe-sym-command."
590 (interactive (lisp-symprompt "Describe" (lisp-var-at-pt))) 606 (interactive (lisp-symprompt "Describe" (lisp-var-at-pt)))
591 (comint-proc-query (cmulisp-proc) (format lisp-describe-sym-command sym))) 607 (comint-proc-query (inferior-lisp-proc)
608 (format lisp-describe-sym-command sym)))
592 609
593 610
594(defvar cmulisp-buffer nil "*The current cmulisp process buffer. 611(defvar inferior-lisp-buffer nil "*The current inferior-lisp process buffer.
595 612
596MULTIPLE PROCESS SUPPORT 613MULTIPLE PROCESS SUPPORT
597=========================================================================== 614===========================================================================
598Cmulisp.el supports, in a fairly simple fashion, running multiple Lisp 615Inf-lisp.el supports, in a fairly simple fashion, running multiple
599processes. To run multiple Lisp processes, you start the first up with 616Lisp processes. To run multiple Lisp processes, you start the first up
600\\[cmulisp]. It will be in a buffer named *cmulisp*. Rename this buffer 617with \\[inferior-lisp]. It will be in a buffer named *inferior-lisp*.
601with \\[rename-buffer]. You may now start up a new process with another 618Rename this buffer with \\[rename-buffer]. You may now start up a new
602\\[cmulisp]. It will be in a new buffer, named *cmulisp*. You can 619process with another \\[inferior-lisp]. It will be in a new buffer,
603switch between the different process buffers with \\[switch-to-buffer]. 620named *inferior-lisp*. You can switch between the different process
621buffers with \\[switch-to-buffer].
604 622
605Commands that send text from source buffers to Lisp processes -- 623Commands that send text from source buffers to Lisp processes --
606like lisp-eval-defun or lisp-show-arglist -- have to choose a process 624like lisp-eval-defun or lisp-show-arglist -- have to choose a process
607to send to, when you have more than one Lisp process around. This 625to send to, when you have more than one Lisp process around. This
608is determined by the global variable cmulisp-buffer. Suppose you 626is determined by the global variable inferior-lisp-buffer. Suppose you
609have three inferior lisps running: 627have three inferior lisps running:
610 Buffer Process 628 Buffer Process
611 foo cmulisp 629 foo inferior-lisp
612 bar cmulisp<2> 630 bar inferior-lisp<2>
613 *cmulisp* cmulisp<3> 631 *inferior-lisp* inferior-lisp<3>
614If you do a \\[lisp-eval-defun] command on some Lisp source code, 632If you do a \\[lisp-eval-defun] command on some Lisp source code,
615what process do you send it to? 633what process do you send it to?
616 634
617- If you're in a process buffer (foo, bar, or *cmulisp*), 635- If you're in a process buffer (foo, bar, or *inferior-lisp*),
618 you send it to that process. 636 you send it to that process.
619- If you're in some other buffer (e.g., a source file), you 637- If you're in some other buffer (e.g., a source file), you
620 send it to the process attached to buffer cmulisp-buffer. 638 send it to the process attached to buffer inferior-lisp-buffer.
621This process selection is performed by function cmulisp-proc. 639This process selection is performed by function inferior-lisp-proc.
622 640
623Whenever \\[cmulisp] fires up a new process, it resets cmulisp-buffer 641Whenever \\[inferior-lisp] fires up a new process, it resets
624to be the new process's buffer. If you only run one process, this will 642inferior-lisp-buffer to be the new process's buffer. If you only run
625do the right thing. If you run multiple processes, you can change 643one process, this will do the right thing. If you run multiple
626cmulisp-buffer to another process buffer with \\[set-variable]. 644processes, you can change inferior-lisp-buffer to another process
645buffer with \\[set-variable].
627 646
628More sophisticated approaches are, of course, possible. If you find youself 647More sophisticated approaches are, of course, possible. If you find youself
629needing to switch back and forth between multiple processes frequently, 648needing to switch back and forth between multiple processes frequently,
@@ -631,25 +650,29 @@ you may wish to consider ilisp.el, a larger, more sophisticated package
631for running inferior Lisp processes. The approach taken here is for a 650for running inferior Lisp processes. The approach taken here is for a
632minimal, simple implementation. Feel free to extend it.") 651minimal, simple implementation. Feel free to extend it.")
633 652
634(defun cmulisp-proc () 653(defun inferior-lisp-proc ()
635 "Returns the current cmulisp process. See variable cmulisp-buffer." 654 "Returns the current inferior-lisp process. See variable inferior-lisp-buffer."
636 (let ((proc (get-buffer-process (if (eq major-mode 'inferior-lisp-mode) 655 (let ((proc (get-buffer-process (if (eq major-mode 'inferior-lisp-mode)
637 (current-buffer) 656 (current-buffer)
638 cmulisp-buffer)))) 657 inferior-lisp-buffer))))
639 (or proc 658 (or proc
640 (error "No current process. See variable cmulisp-buffer")))) 659 (error "No current process. See variable inferior-lisp-buffer"))))
641 660
642 661
643;;; Do the user's customisation... 662;;; Do the user's customisation...
644;;;=============================== 663;;;===============================
645(defvar cmulisp-load-hook nil 664(defvar inferior-lisp-load-hook nil
646 "This hook is run when cmulisp is loaded in. 665 "This hook is run when inferior-lisp is loaded in.
647This is a good place to put keybindings.") 666This is a good place to put keybindings.")
648 667
649(run-hooks 'cmulisp-load-hook) 668(run-hooks 'inferior-lisp-load-hook)
650 669
651;;; CHANGE LOG 670;;; CHANGE LOG
652;;; =========================================================================== 671;;; ===========================================================================
672;;; 7/21/92 Jim Blandy
673;;; - Changed all uses of the cmulisp name or prefix to inferior-lisp;
674;;; this is now the official inferior lisp package. Use the global
675;;; ChangeLog from now on.
653;;; 5/24/90 Olin 676;;; 5/24/90 Olin
654;;; - Split cmulisp and cmushell modes into separate files. 677;;; - Split cmulisp and cmushell modes into separate files.
655;;; Not only is this a good idea, it's apparently the way it'll be rel 19. 678;;; Not only is this a good idea, it's apparently the way it'll be rel 19.
@@ -688,6 +711,6 @@ This is a good place to put keybindings.")
688;;; - If M-x cmulisp is invoked with a prefix arg, it allows you to 711;;; - If M-x cmulisp is invoked with a prefix arg, it allows you to
689;;; edit the command line. 712;;; edit the command line.
690 713
691(provide 'cmulisp) 714(provide 'inf-lisp)
692 715
693;;; cmulisp.el ends here 716;;; inf-lisp.el ends here