annotate lisp/progmodes/inf-lisp.el @ 474:c3bbd755b7da

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