annotate lisp/progmodes/inf-lisp.el @ 669:4c64c671426f

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