annotate lisp/progmodes/inf-lisp.el @ 1366:ebf903dc2d70

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