annotate lisp/=cmulisp.el @ 24419:30e478cd167e

(shell-command-default-error-buffer): Renamed from shell-command-on-region-default-error-buffer. (shell-command-on-region): Mention in echo area when there is some error output. Mention success or failure, too. Accumulate multiple error outputs going forward, with formfeed in between. Display the error buffer when we have put something in it. (shell-command): Add the ERROR-BUFFER argument feature.
author Karl Heuer <kwzh@gnu.org>
date Mon, 01 Mar 1999 03:19:32 +0000
parents 507f64624555
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 ;;; cmulisp.el --- improved version of standard inferior-lisp mode
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3 ;;; Copyright Olin Shivers (1988).
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2229
diff changeset
4
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2229
diff changeset
5 ;; Keywords: processes, lisp
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2229
diff changeset
6
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 ;;; Please imagine a long, tedious, legalistic 5-page gnu-style copyright
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;;; notice appearing here to the effect that you may use this code any
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;;; way you like, as long as you don't charge money for it, remove this
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;;; notice, or hold me liable for its results.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
2229
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1368
diff changeset
12 ;;; Commentary:
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1368
diff changeset
13
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;;; This replaces the standard inferior-lisp mode.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;;; Hacked from tea.el by Olin Shivers (shivers@cs.cmu.edu). 8/88
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;;; Please send me bug reports, bug fixes, and extensions, so that I can
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;;; merge them into the master source.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;;; Change log at end of file.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;;; This file defines a a lisp-in-a-buffer package (cmulisp mode) built on top
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;;; of comint mode. Cmulisp mode is similar to, and intended to replace, its
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 ;;; counterpart in the standard gnu emacs release. This replacements is more
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 ;;; featureful, robust, and uniform than the released version. The key
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 ;;; bindings are also more compatible with the bindings of Hemlock and Zwei
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 ;;; (the Lisp Machine emacs).
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 ;;; Since this mode is built on top of the general command-interpreter-in-
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ;;; a-buffer mode (comint mode), it shares a common base functionality,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ;;; and a common set of bindings, with all modes derived from comint mode.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;;; This makes these modes easier to use.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ;;; For documentation on the functionality provided by comint mode, and
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ;;; the hooks available for customising it, see the file comint.el.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ;;; For further information on cmulisp mode, see the comments below.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ;;; Needs fixin:
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 ;;; The load-file/compile-file default mechanism could be smarter -- it
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 ;;; doesn't know about the relationship between filename extensions and
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 ;;; whether the file is source or executable. If you compile foo.lisp
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 ;;; with compile-file, then the next load-file should use foo.bin for
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 ;;; the default, not foo.lisp. This is tricky to do right, particularly
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 ;;; because the extension for executable files varies so much (.o, .bin,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 ;;; .lbin, .mo, .vo, .ao, ...).
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 ;;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 ;;; It would be nice if cmulisp (and inferior scheme, T, ...) modes
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 ;;; had a verbose minor mode wherein sending or compiling defuns, etc.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 ;;; would be reflected in the transcript with suitable comments, e.g.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 ;;; ";;; redefining fact". Several ways to do this. Which is right?
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 ;;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 ;;; When sending text from a source file to a subprocess, the process-mark can
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 ;;; move off the window, so you can lose sight of the process interactions.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 ;;; Maybe I should ensure the process mark is in the window when I send
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 ;;; text to the process? Switch selectable?
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 (require 'comint)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 ;; YOUR .EMACS FILE
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 ;;=============================================================================
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 ;; Some suggestions for your .emacs file.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 ;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 ;; ; If cmulisp lives in some non-standard directory, you must tell emacs
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 ;; ; where to get it. This may or may not be necessary.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 ;; (setq load-path (cons (expand-file-name "~jones/lib/emacs") load-path))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 ;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 ;; ; Autoload cmulisp from file cmulisp.el
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 ;; (autoload 'cmulisp "cmulisp"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 ;; "Run an inferior Lisp process."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 ;; t)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 ;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 ;; ; Define C-c t to run my favorite command in cmulisp mode:
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 ;; (setq cmulisp-load-hook
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 ;; '((lambda ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 ;; (define-key cmulisp-mode-map "\C-ct" 'favorite-cmd))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
75 ;; Brief Command Documentation:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
76 ;;============================================================================
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
77 ;; Comint Mode Commands: (common to cmulisp and all comint-derived modes)
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
78 ;;
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
79 ;; m-p comint-previous-input Cycle backwards in input history
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
80 ;; m-n comint-next-input Cycle forwards
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
81 ;; m-c-r comint-previous-input-matching Search backwards in input history
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
82 ;; return comint-send-input
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
83 ;; c-a comint-bol Beginning of line; skip prompt.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
84 ;; c-d comint-delchar-or-maybe-eof Delete char unless at end of buff.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
85 ;; c-c c-u comint-kill-input ^u
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
86 ;; c-c c-w backward-kill-word ^w
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
87 ;; c-c c-c comint-interrupt-subjob ^c
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
88 ;; c-c c-z comint-stop-subjob ^z
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
89 ;; c-c c-\ comint-quit-subjob ^\
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
90 ;; c-c c-o comint-kill-output Delete last batch of process output
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
91 ;; c-c c-r comint-show-output Show last batch of process output
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
92 ;; send-invisible Read line w/o echo & send to proc
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
93 ;; comint-continue-subjob Useful if you accidentally suspend
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
94 ;; top-level job.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
95 ;; comint-mode-hook is the comint mode hook.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
97 ;; CMU Lisp Mode Commands:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
98 ;; c-m-x lisp-send-defun This binding is a gnu convention.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
99 ;; c-c c-l lisp-load-file Prompt for file name; tell Lisp to load it.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
100 ;; c-c c-k lisp-compile-file Prompt for file name; tell Lisp to kompile it.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
101 ;; Filename completion is available, of course.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
102 ;;
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
103 ;; Additionally, these commands are added to the key bindings of Lisp mode:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
104 ;; c-m-x lisp-eval-defun This binding is a gnu convention.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
105 ;; c-c c-e lisp-eval-defun Send the current defun to Lisp process.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
106 ;; c-x c-e lisp-eval-last-sexp Send the previous sexp to Lisp process.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
107 ;; c-c c-r lisp-eval-region Send the current region to Lisp process.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
108 ;; c-c c-c lisp-compile-defun Compile the current defun in Lisp process.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
109 ;; c-c c-z switch-to-lisp Switch to the Lisp process buffer.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
110 ;; c-c c-l lisp-load-file (See above. In a Lisp file buffer, default
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
111 ;; c-c c-k lisp-compile-file is to load/compile the current file.)
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
112 ;; c-c c-d lisp-describe-sym Query Lisp for a symbol's description.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
113 ;; c-c c-a lisp-show-arglist Query Lisp for function's arglist.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
114 ;; c-c c-f lisp-show-function-documentation Query Lisp for a function's doc.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
115 ;; c-c c-v lisp-show-variable-documentation Query Lisp for a variable's doc.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
117 ;; cmulisp Fires up the Lisp process.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
118 ;; lisp-compile-region Compile all forms in the current region.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
119 ;;
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
120 ;; CMU Lisp Mode Variables:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
121 ;; cmulisp-filter-regexp Match this => don't get saved on input hist
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
122 ;; inferior-lisp-program Name of Lisp program run-lisp executes
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
123 ;; inferior-lisp-load-command Customises lisp-load-file
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
124 ;; cmulisp-mode-hook
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
125 ;; inferior-lisp-prompt Initialises comint-prompt-regexp.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
126 ;; Backwards compatibility.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
127 ;; lisp-source-modes Anything loaded into a buffer that's in
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
128 ;; one of these modes is considered Lisp
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
129 ;; source by lisp-load/compile-file.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
130
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
131 ;;; Code:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
132
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
133 (require 'comint)
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 ;;; Read the rest of this file for more information.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136
2229
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1368
diff changeset
137
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1368
diff changeset
138 ;;; Code:
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1368
diff changeset
139
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (defvar cmulisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 "*What not to save on inferior Lisp's input history
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 Input matching this regexp is not saved on the input history in cmulisp
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 mode. Default is whitespace followed by 0 or 1 single-letter :keyword
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (as in :a, :c, etc.)")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 (defvar cmulisp-mode-map nil)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (cond ((not cmulisp-mode-map)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (setq cmulisp-mode-map
1368
35a17cd4ae62 (cmulisp-mode): Eliminate compatibility code calling
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
149 (nconc (full-copy-sparse-keymap comint-mode-map)
35a17cd4ae62 (cmulisp-mode): Eliminate compatibility code calling
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
150 shared-lisp-mode-map))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (define-key cmulisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 (define-key cmulisp-mode-map "\C-c\C-l" 'lisp-load-file)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (define-key cmulisp-mode-map "\C-c\C-k" 'lisp-compile-file)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 (define-key cmulisp-mode-map "\C-c\C-a" 'lisp-show-arglist)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (define-key cmulisp-mode-map "\C-c\C-d" 'lisp-describe-sym)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (define-key cmulisp-mode-map "\C-c\C-f" 'lisp-show-function-documentation)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (define-key cmulisp-mode-map "\C-c\C-v" 'lisp-show-variable-documentation)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 ;;; These commands augment Lisp mode, so you can process Lisp code in
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 ;;; the source files.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 (define-key lisp-mode-map "\M-\C-x" 'lisp-eval-defun) ; Gnu convention
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 (define-key lisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp) ; Gnu convention
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (define-key lisp-mode-map "\C-c\C-e" 'lisp-eval-defun)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 (define-key lisp-mode-map "\C-c\C-r" 'lisp-eval-region)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 (define-key lisp-mode-map "\C-c\C-c" 'lisp-compile-defun)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (define-key lisp-mode-map "\C-c\C-z" 'switch-to-lisp)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (define-key lisp-mode-map "\C-c\C-l" 'lisp-load-file)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 (define-key lisp-mode-map "\C-c\C-k" 'lisp-compile-file) ; "kompile" file
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (define-key lisp-mode-map "\C-c\C-a" 'lisp-show-arglist)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (define-key lisp-mode-map "\C-c\C-d" 'lisp-describe-sym)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 (define-key lisp-mode-map "\C-c\C-f" 'lisp-show-function-documentation)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (define-key lisp-mode-map "\C-c\C-v" 'lisp-show-variable-documentation)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173
1368
35a17cd4ae62 (cmulisp-mode): Eliminate compatibility code calling
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
174 (defvar cmulisp-buffer)
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 ;;; This function exists for backwards compatibility.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 ;;; Previous versions of this package bound commands to C-c <letter>
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 ;;; bindings, which is not allowed by the gnumacs standard.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 (defun cmulisp-install-letter-bindings ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 "This function binds many cmulisp commands to C-c <letter> bindings,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 where they are more accessible. C-c <letter> bindings are reserved for the
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 user, so these bindings are non-standard. If you want them, you should
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 have this function called by the cmulisp-load-hook:
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 (setq cmulisp-load-hook '(cmulisp-install-letter-bindings))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 You can modify this function to install just the bindings you want."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 (define-key lisp-mode-map "\C-ce" 'lisp-eval-defun-and-go)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 (define-key lisp-mode-map "\C-cr" 'lisp-eval-region-and-go)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (define-key lisp-mode-map "\C-cc" 'lisp-compile-defun-and-go)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (define-key lisp-mode-map "\C-cz" 'switch-to-lisp)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (define-key lisp-mode-map "\C-cl" 'lisp-load-file)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 (define-key lisp-mode-map "\C-ck" 'lisp-compile-file)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (define-key lisp-mode-map "\C-ca" 'lisp-show-arglist)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 (define-key lisp-mode-map "\C-cd" 'lisp-describe-sym)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 (define-key lisp-mode-map "\C-cf" 'lisp-show-function-documentation)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 (define-key lisp-mode-map "\C-cv" 'lisp-show-variable-documentation)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 (define-key cmulisp-mode-map "\C-cl" 'lisp-load-file)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (define-key cmulisp-mode-map "\C-ck" 'lisp-compile-file)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (define-key cmulisp-mode-map "\C-ca" 'lisp-show-arglist)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (define-key cmulisp-mode-map "\C-cd" 'lisp-describe-sym)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (define-key cmulisp-mode-map "\C-cf" 'lisp-show-function-documentation)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 (define-key cmulisp-mode-map "\C-cv" 'lisp-show-variable-documentation))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (defvar inferior-lisp-program "lisp"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 "*Program name for invoking an inferior Lisp with `cmulisp'.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 (defvar inferior-lisp-load-command "(load \"%s\")\n"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 "*Format-string for building a Lisp expression to load a file.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 This format string should use %s to substitute a file name
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 and should result in a Lisp expression that will command the inferior Lisp
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 to load that file. The default works acceptably on most Lisps.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 The string \"(progn (load \\\"%s\\\" :verbose nil :print t) (values))\\\n\"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 produces cosmetically superior output for this application,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 but it works only in Common Lisp.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 (defvar inferior-lisp-prompt "^[^> ]*>+:? *"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 "Regexp to recognise prompts in the inferior Lisp.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 Defaults to \"^[^> ]*>+:? *\", which works pretty good for Lucid, kcl,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 and franz. This variable is used to initialise comint-prompt-regexp in the
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 cmulisp buffer.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 More precise choices:
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 Lucid Common Lisp: \"^\\(>\\|\\(->\\)+\\) *\"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 franz: \"^\\(->\\|<[0-9]*>:\\) *\"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 kcl: \"^>+ *\"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 This is a fine thing to set in your .emacs file.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 (defvar cmulisp-mode-hook '()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 "*Hook for customising cmulisp mode")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (defun cmulisp-mode ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 "Major mode for interacting with an inferior Lisp process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 Runs a Lisp interpreter as a subprocess of Emacs, with Lisp I/O through an
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 Emacs buffer. Variable inferior-lisp-program controls which Lisp interpreter
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 is run. Variables inferior-lisp-prompt, cmulisp-filter-regexp and
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 inferior-lisp-load-command can customize this mode for different Lisp
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 interpreters.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 For information on running multiple processes in multiple buffers, see
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 documentation for variable cmulisp-buffer.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 \\{cmulisp-mode-map}
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 Customisation: Entry to this mode runs the hooks on comint-mode-hook and
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 cmulisp-mode-hook (in that order).
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 You can send text to the inferior Lisp process from other buffers containing
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 Lisp source.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 switch-to-lisp switches the current buffer to the Lisp process buffer.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 lisp-eval-defun sends the current defun to the Lisp process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 lisp-compile-defun compiles the current defun.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 lisp-eval-region sends the current region to the Lisp process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 lisp-compile-region compiles the current region.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 Prefixing the lisp-eval/compile-defun/region commands with
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 a \\[universal-argument] causes a switch to the Lisp process buffer after sending
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 the text.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 Commands:
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 Return after the end of the process' output sends the text from the
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 end of process to point.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 Return before the end of the process' output copies the sexp ending at point
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 to the end of the process' output, and sends it.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 Delete converts tabs to spaces as it moves back.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 Tab indents for Lisp; with argument, shifts rest
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 of expression rigidly with the current line.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 C-M-q does Tab on each line starting within following expression.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 Paragraphs are separated only by blank lines. Semicolons start comments.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 If you accidentally suspend your process, use \\[comint-continue-subjob]
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 to continue it."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (interactive)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (comint-mode)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (setq comint-prompt-regexp inferior-lisp-prompt)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (setq major-mode 'cmulisp-mode)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (setq mode-name "CMU Lisp")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 (setq mode-line-process '(": %s"))
1368
35a17cd4ae62 (cmulisp-mode): Eliminate compatibility code calling
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
281 (lisp-mode-variables t)
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (use-local-map cmulisp-mode-map) ;c-c c-k for "kompile" file
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (setq comint-get-old-input (function lisp-get-old-input))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 (setq comint-input-filter (function lisp-input-filter))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (setq comint-input-sentinel 'ignore)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (run-hooks 'cmulisp-mode-hook))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (defun lisp-get-old-input ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 "Snarf the sexp ending at point"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (save-excursion
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (let ((end (point)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (backward-sexp)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (buffer-substring (point) end))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (defun lisp-input-filter (str)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 "Don't save anything matching cmulisp-filter-regexp"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 (not (string-match cmulisp-filter-regexp str)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (defun cmulisp (cmd)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 "Run an inferior Lisp process, input and output via buffer *cmulisp*.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 If there is a process already running in *cmulisp*, just switch to that buffer.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 With argument, allows you to edit the command line (default is value
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 of inferior-lisp-program). Runs the hooks from cmulisp-mode-hook (after the
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 comint-mode-hook is run).
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 \(Type \\[describe-mode] in the process buffer for a list of commands.)"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 (interactive (list (if current-prefix-arg
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 (read-string "Run lisp: " inferior-lisp-program)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 inferior-lisp-program)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 (if (not (comint-check-proc "*cmulisp*"))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (let ((cmdlist (cmulisp-args-to-list cmd)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 (set-buffer (apply (function make-comint) "cmulisp" (car cmdlist) nil
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 (cdr cmdlist)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (cmulisp-mode)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 (setq cmulisp-buffer "*cmulisp*")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (switch-to-buffer "*cmulisp*"))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 ;;; Break a string up into a list of arguments.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 ;;; This will break if you have an argument with whitespace, as in
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 ;;; string = "-ab +c -x 'you lose'".
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (defun cmulisp-args-to-list (string)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 (let ((where (string-match "[ \t]" string)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 (cond ((null where) (list string))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 ((not (= where 0))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (cons (substring string 0 where)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (tea-args-to-list (substring string (+ 1 where)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 (length string)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (t (let ((pos (string-match "[^ \t]" string)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (if (null pos)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 nil
1368
35a17cd4ae62 (cmulisp-mode): Eliminate compatibility code calling
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
330 (cmulisp-args-to-list (substring string pos
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 (length string)))))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 (defun lisp-eval-region (start end &optional and-go)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 "Send the current region to the inferior Lisp process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 Prefix argument means switch-to-lisp afterwards."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (interactive "r\nP")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (comint-send-region (cmulisp-proc) start end)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (comint-send-string (cmulisp-proc) "\n")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 (if and-go (switch-to-lisp t)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (defun lisp-eval-defun (&optional and-go)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 "Send the current defun to the inferior Lisp process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 Prefix argument means switch-to-lisp afterwards."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (interactive "P")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (save-excursion
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 (end-of-defun)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 (skip-chars-backward " \t\n\r\f") ; Makes allegro happy
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 (let ((end (point)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (beginning-of-defun)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 (lisp-eval-region (point) end)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 (if and-go (switch-to-lisp t)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (defun lisp-eval-last-sexp (&optional and-go)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 "Send the previous sexp to the inferior Lisp process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 Prefix argument means switch-to-lisp afterwards."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 (interactive "P")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 (lisp-eval-region (save-excursion (backward-sexp) (point)) (point) and-go))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 ;;; Common Lisp COMPILE sux.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 (defun lisp-compile-region (start end &optional and-go)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 "Compile the current region in the inferior Lisp process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 Prefix argument means switch-to-lisp afterwards."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 (interactive "r\nP")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 (comint-send-string (cmulisp-proc)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 (format "(funcall (compile nil `(lambda () (progn 'compile %s))))\n"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 (buffer-substring start end)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 (if and-go (switch-to-lisp t)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 (defun lisp-compile-defun (&optional and-go)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 "Compile the current defun in the inferior Lisp process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 Prefix argument means switch-to-lisp afterwards."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 (interactive "P")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 (save-excursion
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (end-of-defun)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (skip-chars-backward " \t\n\r\f") ; Makes allegro happy
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (let ((e (point)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 (beginning-of-defun)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (lisp-compile-region (point) e)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (if and-go (switch-to-lisp t)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 (defun switch-to-lisp (eob-p)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 "Switch to the inferior Lisp process buffer.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 With argument, positions cursor at end of buffer."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 (interactive "P")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 (if (get-buffer cmulisp-buffer)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 (pop-to-buffer cmulisp-buffer)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (error "No current process buffer. See variable cmulisp-buffer."))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 (cond (eob-p
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (push-mark)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 (goto-char (point-max)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 ;;; Now that lisp-compile/eval-defun/region takes an optional prefix arg,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 ;;; these commands are redundant. But they are kept around for the user
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 ;;; to bind if he wishes, for backwards functionality, and because it's
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 ;;; easier to type C-c e than C-u C-c C-e.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 (defun lisp-eval-region-and-go (start end)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 "Send the current region to the inferior Lisp,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 and switch to the process buffer."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (interactive "r")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (lisp-eval-region start end t))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 (defun lisp-eval-defun-and-go ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 "Send the current defun to the inferior Lisp,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 and switch to the process buffer."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 (interactive)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 (lisp-eval-defun t))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 (defun lisp-compile-region-and-go (start end)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 "Compile the current region in the inferior Lisp,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 and switch to the process buffer."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (interactive "r")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (lisp-compile-region start end t))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (defun lisp-compile-defun-and-go ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 "Compile the current defun in the inferior Lisp,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 and switch to the process buffer."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (interactive)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (lisp-compile-defun t))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 ;;; A version of the form in H. Shevis' soar-mode.el package. Less robust.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 ;(defun lisp-compile-sexp (start end)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 ; "Compile the s-expression bounded by START and END in the inferior lisp.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 ;If the sexp isn't a DEFUN form, it is evaluated instead."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 ; (cond ((looking-at "(defun\\s +")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 ; (goto-char (match-end 0))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 ; (let ((name-start (point)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 ; (forward-sexp 1)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 ; (process-send-string "cmulisp" (format "(compile '%s #'(lambda "
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 ; (buffer-substring name-start
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 ; (point)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 ; (let ((body-start (point)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 ; (goto-char start) (forward-sexp 1) ; Can't use end-of-defun.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 ; (process-send-region "cmulisp" (buffer-substring body-start (point))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 ; (process-send-string "cmulisp" ")\n"))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 ; (t (lisp-eval-region start end)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 ;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 ;(defun lisp-compile-region (start end)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 ; "Each s-expression in the current region is compiled (if a DEFUN)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 ;or evaluated (if not) in the inferior lisp."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 ; (interactive "r")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 ; (save-excursion
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 ; (goto-char start) (end-of-defun) (beginning-of-defun) ; error check
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 ; (if (< (point) start) (error "region begins in middle of defun"))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 ; (goto-char start)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 ; (let ((s start))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 ; (end-of-defun)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 ; (while (<= (point) end) ; Zip through
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 ; (lisp-compile-sexp s (point)) ; compiling up defun-sized chunks.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 ; (setq s (point))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 ; (end-of-defun))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 ; (if (< s end) (lisp-compile-sexp s end)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 ;;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 ;;; End of HS-style code
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 (defvar lisp-prev-l/c-dir/file nil
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 "Saves the (directory . file) pair used in the last lisp-load-file or
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 lisp-compile-file command. Used for determining the default in the
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 next one.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 (defvar lisp-source-modes '(lisp-mode)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 "*Used to determine if a buffer contains Lisp source code.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 If it's loaded into a buffer that is in one of these major modes, it's
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 considered a Lisp source file by lisp-load-file and lisp-compile-file.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 Used by these commands to determine defaults.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (defun lisp-load-file (file-name)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 "Load a Lisp file into the inferior Lisp process."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 (interactive (comint-get-source "Load Lisp file: " lisp-prev-l/c-dir/file
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 lisp-source-modes nil)) ; NIL because LOAD
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 ; doesn't need an exact name
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 (comint-check-source file-name) ; Check to see if buffer needs saved.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 (file-name-nondirectory file-name)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 (comint-send-string (cmulisp-proc)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 (format inferior-lisp-load-command file-name))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 (switch-to-lisp t))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 (defun lisp-compile-file (file-name)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 "Compile a Lisp file in the inferior Lisp process."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 (interactive (comint-get-source "Compile Lisp file: " lisp-prev-l/c-dir/file
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 lisp-source-modes nil)) ; NIL = don't need
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 ; suffix .lisp
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 (comint-check-source file-name) ; Check to see if buffer needs saved.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 (file-name-nondirectory file-name)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 (comint-send-string (cmulisp-proc) (concat "(compile-file \""
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 file-name
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 "\"\)\n"))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 (switch-to-lisp t))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 ;;; Documentation functions: function doc, var doc, arglist, and
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 ;;; describe symbol.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 ;;; ===========================================================================
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 ;;; Command strings
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 ;;; ===============
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 (defvar lisp-function-doc-command
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 "(let ((fn '%s))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 (format t \"Documentation for ~a:~&~a\"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 fn (documentation fn 'function))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 (values))\n"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 "Command to query inferior Lisp for a function's documentation.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 (defvar lisp-var-doc-command
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 "(let ((v '%s))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 (format t \"Documentation for ~a:~&~a\"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 v (documentation v 'variable))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 (values))\n"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 "Command to query inferior Lisp for a variable's documentation.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 (defvar lisp-arglist-command
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 "(let ((fn '%s))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 (format t \"Arglist for ~a: ~a\" fn (arglist fn))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 (values))\n"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 "Command to query inferior Lisp for a function's arglist.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 (defvar lisp-describe-sym-command
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 "(describe '%s)\n"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 "Command to query inferior Lisp for a variable's documentation.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 ;;; Ancillary functions
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 ;;; ===================
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 ;;; Reads a string from the user.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 (defun lisp-symprompt (prompt default)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 (list (let* ((prompt (if default
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 (format "%s (default %s): " prompt default)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 (concat prompt ": ")))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 (ans (read-string prompt)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 (if (zerop (length ans)) default ans))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 ;;; Adapted from function-called-at-point in help.el.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 (defun lisp-fn-called-at-pt ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 "Returns the name of the function called in the current call.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 Nil if it can't find one."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 (condition-case nil
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 (save-excursion
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 (save-restriction
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 (narrow-to-region (max (point-min) (- (point) 1000)) (point-max))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 (backward-up-list 1)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 (forward-char 1)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 (let ((obj (read (current-buffer))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 (and (symbolp obj) obj))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 (error nil)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 ;;; Adapted from variable-at-point in help.el.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (defun lisp-var-at-pt ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 (condition-case ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (save-excursion
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 (forward-sexp -1)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (skip-chars-forward "'")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 (let ((obj (read (current-buffer))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 (and (symbolp obj) obj)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 (error nil)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 ;;; Documentation functions: fn and var doc, arglist, and symbol describe.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 ;;; ======================================================================
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 (defun lisp-show-function-documentation (fn)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 "Send a command to the inferior Lisp to give documentation for function FN.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 See variable lisp-function-doc-command."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 (interactive (lisp-symprompt "Function doc" (lisp-fn-called-at-pt)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 (comint-proc-query (cmulisp-proc) (format lisp-function-doc-command fn)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 (defun lisp-show-variable-documentation (var)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 "Send a command to the inferior Lisp to give documentation for function FN.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 See variable lisp-var-doc-command."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 (interactive (lisp-symprompt "Variable doc" (lisp-var-at-pt)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 (comint-proc-query (cmulisp-proc) (format lisp-var-doc-command var)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 (defun lisp-show-arglist (fn)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 "Sends an query to the inferior Lisp for the arglist for function FN.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 See variable lisp-arglist-command."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (interactive (lisp-symprompt "Arglist" (lisp-fn-called-at-pt)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (comint-proc-query (cmulisp-proc) (format lisp-arglist-command fn)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 (defun lisp-describe-sym (sym)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 "Send a command to the inferior Lisp to describe symbol SYM.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 See variable lisp-describe-sym-command."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 (interactive (lisp-symprompt "Describe" (lisp-var-at-pt)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 (comint-proc-query (cmulisp-proc) (format lisp-describe-sym-command sym)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 (defvar cmulisp-buffer nil "*The current cmulisp process buffer.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 MULTIPLE PROCESS SUPPORT
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 ===========================================================================
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 Cmulisp.el supports, in a fairly simple fashion, running multiple Lisp
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 processes. To run multiple Lisp processes, you start the first up with
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 \\[cmulisp]. It will be in a buffer named *cmulisp*. Rename this buffer
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 with \\[rename-buffer]. You may now start up a new process with another
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 \\[cmulisp]. It will be in a new buffer, named *cmulisp*. You can
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 switch between the different process buffers with \\[switch-to-buffer].
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 Commands that send text from source buffers to Lisp processes --
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 like lisp-eval-defun or lisp-show-arglist -- have to choose a process
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 to send to, when you have more than one Lisp process around. This
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 is determined by the global variable cmulisp-buffer. Suppose you
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 have three inferior lisps running:
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 Buffer Process
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 foo cmulisp
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 bar cmulisp<2>
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 *cmulisp* cmulisp<3>
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 If you do a \\[lisp-eval-defun] command on some Lisp source code,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 what process do you send it to?
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 - If you're in a process buffer (foo, bar, or *cmulisp*),
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 you send it to that process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 - If you're in some other buffer (e.g., a source file), you
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 send it to the process attached to buffer cmulisp-buffer.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 This process selection is performed by function cmulisp-proc.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 Whenever \\[cmulisp] fires up a new process, it resets cmulisp-buffer
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 to be the new process's buffer. If you only run one process, this will
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 do the right thing. If you run multiple processes, you can change
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 cmulisp-buffer to another process buffer with \\[set-variable].
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2307
diff changeset
629 More sophisticated approaches are, of course, possible. If you find yourself
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 needing to switch back and forth between multiple processes frequently,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 you may wish to consider ilisp.el, a larger, more sophisticated package
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 for running inferior Lisp processes. The approach taken here is for a
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 minimal, simple implementation. Feel free to extend it.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 (defun cmulisp-proc ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 "Returns the current cmulisp process. See variable cmulisp-buffer."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 (let ((proc (get-buffer-process (if (eq major-mode 'inferior-lisp-mode)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 (current-buffer)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 cmulisp-buffer))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 (or proc
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 (error "No current process. See variable cmulisp-buffer"))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 ;;; Do the user's customisation...
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 ;;;===============================
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 (defvar cmulisp-load-hook nil
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 "This hook is run when cmulisp is loaded in.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 This is a good place to put keybindings.")
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 (run-hooks 'cmulisp-load-hook)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 ;;; CHANGE LOG
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 ;;; ===========================================================================
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 ;;; 5/24/90 Olin
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 ;;; - Split cmulisp and cmushell modes into separate files.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 ;;; Not only is this a good idea, it's apparently the way it'll be rel 19.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 ;;; - Upgraded process sends to use comint-send-string instead of
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 ;;; process-send-string.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 ;;; - Explicit references to process "cmulisp" have been replaced with
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 ;;; (cmulisp-proc). This allows better handling of multiple process bufs.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 ;;; - Added process query and var/function/symbol documentation
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 ;;; commands. Based on code written by Douglas Roberts.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 ;;; - Added lisp-eval-last-sexp, bound to C-x C-e.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 ;;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 ;;; 9/20/90 Olin
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 ;;; Added a save-restriction to lisp-fn-called-at-pt. This bug and fix
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 ;;; reported by Lennart Staflin.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 ;;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 ;;; 3/12/90 Olin
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 ;;; - lisp-load-file and lisp-compile-file no longer switch-to-lisp.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 ;;; Tale suggested this.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 ;;; - Reversed this decision 7/15/91. You need the visual feedback.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 ;;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 ;;; 7/25/91 Olin
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 ;;; Changed all keybindings of the form C-c <letter>. These are
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 ;;; supposed to be reserved for the user to bind. This affected
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 ;;; mainly the compile/eval-defun/region[-and-go] commands.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 ;;; This was painful, but necessary to adhere to the gnumacs standard.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 ;;; For some backwards compatibility, see the
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 ;;; cmulisp-install-letter-bindings
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 ;;; function.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 ;;;
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 ;;; 8/2/91 Olin
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 ;;; - The lisp-compile/eval-defun/region commands now take a prefix arg,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 ;;; which means switch-to-lisp after sending the text to the Lisp process.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 ;;; This obsoletes all the -and-go commands. The -and-go commands are
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 ;;; kept around for historical reasons, and because the user can bind
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 ;;; them to key sequences shorter than C-u C-c C-<letter>.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 ;;; - If M-x cmulisp is invoked with a prefix arg, it allows you to
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 ;;; edit the command line.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 (provide 'cmulisp)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 ;;; cmulisp.el ends here