annotate lisp/xscheme.el @ 45625:28f0b229040c

Initial revision
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Mon, 03 Jun 2002 03:15:34 +0000
parents d1cd5d1c6e77
children 036e57c15cdc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29052
77868152457d Change header line.
Dave Love <fx@gnu.org>
parents: 21088
diff changeset
1 ;;; xscheme.el --- run MIT Scheme under Emacs
656
d74e65773062 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
2
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
3 ;; Copyright (C) 1986, 1987, 1989, 1990, 2001 Free Software Foundation, Inc.
840
113281b361ec *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 812
diff changeset
4
773
9c89fd7ddd41 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 772
diff changeset
5 ;; Maintainer: FSF
5140
9cde7d7fea1f Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 5000
diff changeset
6 ;; Keywords: languages, lisp
772
2b5af16c9af3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 656
diff changeset
7
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
9
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 773
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
13 ;; any later version.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
14
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
19
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14016
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14016
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14016
diff changeset
23 ;; Boston, MA 02111-1307, USA.
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
24
772
2b5af16c9af3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 656
diff changeset
25 ;;; Commentary:
2b5af16c9af3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 656
diff changeset
26
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
27 ;; A major mode for interacting with MIT Scheme.
2319
d98c49df2acd Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 851
diff changeset
28 ;;
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
29 ;; Requires MIT Scheme release 5 or later.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
30 ;; Changes to Control-G handler require runtime version 13.85 or later.
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
31
772
2b5af16c9af3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 656
diff changeset
32 ;;; Code:
2b5af16c9af3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 656
diff changeset
33
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
34 (require 'scheme)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
35
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
36 (defgroup xscheme nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
37 "Major mode for editing Scheme and interacting with MIT's C-Scheme."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
38 :group 'lisp)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
39
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
40 (defcustom scheme-band-name nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
41 "*Band loaded by the `run-scheme' command."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
42 :type '(choice (const nil) string)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
43 :group 'xscheme)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
44
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
45 (defcustom scheme-program-arguments nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
46 "*Arguments passed to the Scheme program by the `run-scheme' command."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
47 :type '(choice (const nil) string)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
48 :group 'xscheme)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
49
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
50 (defcustom xscheme-allow-pipelined-evaluation t
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
51 "If non-nil, an expression may be transmitted while another is evaluating.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
52 Otherwise, attempting to evaluate an expression before the previous expression
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
53 has finished evaluating will signal an error."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
54 :type 'boolean
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
55 :group 'xscheme)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
56
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
57 (defcustom xscheme-startup-message
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
58 "This is the Scheme process buffer.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
59 Type \\[advertised-xscheme-send-previous-expression] to evaluate the expression before point.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
60 Type \\[xscheme-send-control-g-interrupt] to abort evaluation.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
61 Type \\[describe-mode] for more information.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
62
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
63 "
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
64 "String to insert into Scheme process buffer first time it is started.
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
65 Is processed with `substitute-command-keys' first."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
66 :type 'string
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
67 :group 'xscheme)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
68
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
69 (defcustom xscheme-signal-death-message nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
70 "If non-nil, causes a message to be generated when the Scheme process dies."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
71 :type 'boolean
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
72 :group 'xscheme)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
73
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
74 (defcustom xscheme-start-hook nil
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
75 "If non-nil, a procedure to call when the Scheme process is started.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
76 When called, the current buffer will be the Scheme process-buffer."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
77 :type 'hook
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
78 :group 'xscheme
45384
d1cd5d1c6e77 (xscheme-start-hook): Change :version attribute to a string.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 42490
diff changeset
79 :version "20.3")
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
80
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
81 (defun xscheme-evaluation-commands (keymap)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
82 (define-key keymap "\e\C-x" 'xscheme-send-definition)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
83 (define-key keymap "\C-x\C-e" 'advertised-xscheme-send-previous-expression)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
84 (define-key keymap "\eo" 'xscheme-send-buffer)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
85 (define-key keymap "\ez" 'xscheme-send-definition)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
86 (define-key keymap "\e\C-m" 'xscheme-send-previous-expression)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
87 (define-key keymap "\e\C-z" 'xscheme-send-region))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
88
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
89 (defun xscheme-interrupt-commands (keymap)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
90 (define-key keymap "\C-c\C-s" 'xscheme-select-process-buffer)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
91 (define-key keymap "\C-c\C-b" 'xscheme-send-breakpoint-interrupt)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
92 (define-key keymap "\C-c\C-c" 'xscheme-send-control-g-interrupt)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
93 (define-key keymap "\C-c\C-u" 'xscheme-send-control-u-interrupt)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
94 (define-key keymap "\C-c\C-x" 'xscheme-send-control-x-interrupt))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
95
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
96 (xscheme-evaluation-commands scheme-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
97 (xscheme-interrupt-commands scheme-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
98
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
99 (defun run-scheme (command-line)
9590
f84a7b49021d (run-scheme): Delete autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 5140
diff changeset
100 "Run MIT Scheme in an inferior process.
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
101 Output goes to the buffer `*scheme*'.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
102 With argument, asks for a command line."
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
103 (interactive (list (xscheme-read-command-line current-prefix-arg)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
104 (xscheme-start command-line xscheme-process-name xscheme-buffer-name))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
105
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
106 (defun xscheme-start (command-line process-name buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
107 (setq-default xscheme-process-command-line command-line)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
108 (switch-to-buffer
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
109 (xscheme-start-process command-line process-name buffer-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
110 (make-local-variable 'xscheme-process-command-line)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
111 (setq xscheme-process-command-line command-line))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
112
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
113 (defun xscheme-read-command-line (arg)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
114 (let ((default
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
115 (or xscheme-process-command-line
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
116 (xscheme-default-command-line))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
117 (if arg
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
118 (read-string "Run Scheme: " default)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
119 default)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
120
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
121 (defun xscheme-default-command-line ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
122 (concat scheme-program-name " -emacs"
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
123 (if scheme-program-arguments
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
124 (concat " " scheme-program-arguments)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
125 "")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
126 (if scheme-band-name
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
127 (concat " -band " scheme-band-name)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
128 "")))
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
129
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
130 (defun reset-scheme ()
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
131 "Reset the Scheme process."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
132 (interactive)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
133 (let ((process (get-process xscheme-process-name)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
134 (cond ((or (not process)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
135 (not (eq (process-status process) 'run))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
136 (yes-or-no-p
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
137 "The Scheme process is running, are you SURE you want to reset it? "))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
138 (message "Resetting Scheme process...")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
139 (if process
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
140 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
141 (kill-process process t)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
142 (delete-process process)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
143 (xscheme-start-process xscheme-process-command-line
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
144 xscheme-process-name
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
145 xscheme-buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
146 (message "Resetting Scheme process...done")))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
147
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
148 ;;;; Multiple Scheme buffer management commands
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
149
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
150 (defun start-scheme (buffer-name &optional globally)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
151 "Choose a scheme interaction buffer, or create a new one."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
152 ;; (interactive "BScheme interaction buffer: \nP")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
153 (interactive
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
154 (list (read-buffer "Scheme interaction buffer: "
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
155 xscheme-buffer-name
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
156 nil)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
157 current-prefix-arg))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
158 (let ((buffer (get-buffer-create buffer-name)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
159 (let ((process (get-buffer-process buffer)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
160 (if process
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
161 (switch-to-buffer buffer)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
162 (if (or (not (buffer-file-name buffer))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
163 (yes-or-no-p (concat "Buffer "
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
164 (buffer-name buffer)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
165 " contains file "
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
166 (buffer-file-name buffer)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
167 "; start scheme in it? ")))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
168 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
169 (xscheme-start (xscheme-read-command-line t)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
170 buffer-name
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
171 buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
172 (if globally
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
173 (global-set-scheme-interaction-buffer buffer-name)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
174 (message "start-scheme aborted"))))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
175
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
176 (fset 'select-scheme 'start-scheme)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
177
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
178 (defun global-set-scheme-interaction-buffer (buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
179 "Set the default scheme interaction buffer."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
180 (interactive
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
181 (list (read-buffer "Scheme interaction buffer: "
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
182 xscheme-buffer-name
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
183 t)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
184 (let ((process-name (verify-xscheme-buffer buffer-name nil)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
185 (setq-default xscheme-buffer-name buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
186 (setq-default xscheme-process-name process-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
187 (setq-default xscheme-runlight-string
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
188 (save-excursion (set-buffer buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
189 xscheme-runlight-string))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
190 (setq-default xscheme-runlight
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
191 (if (eq (process-status process-name) 'run)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
192 default-xscheme-runlight
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
193 ""))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
194
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
195 (defun local-set-scheme-interaction-buffer (buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
196 "Set the scheme interaction buffer for the current buffer."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
197 (interactive
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
198 (list (read-buffer "Scheme interaction buffer: "
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
199 xscheme-buffer-name
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
200 t)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
201 (let ((process-name (verify-xscheme-buffer buffer-name t)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
202 (make-local-variable 'xscheme-buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
203 (setq xscheme-buffer-name buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
204 (make-local-variable 'xscheme-process-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
205 (setq xscheme-process-name process-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
206 (make-local-variable 'xscheme-runlight)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
207 (setq xscheme-runlight (save-excursion (set-buffer buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
208 xscheme-runlight))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
209
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
210 (defun local-clear-scheme-interaction-buffer ()
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
211 "Make the current buffer use the default scheme interaction buffer."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
212 (interactive)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
213 (if (xscheme-process-buffer-current-p)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
214 (error "Cannot change the interaction buffer of an interaction buffer"))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
215 (kill-local-variable 'xscheme-buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
216 (kill-local-variable 'xscheme-process-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
217 (kill-local-variable 'xscheme-runlight))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
218
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
219 (defun verify-xscheme-buffer (buffer-name localp)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
220 (if (and localp (xscheme-process-buffer-current-p))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
221 (error "Cannot change the interaction buffer of an interaction buffer"))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
222 (let* ((buffer (get-buffer buffer-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
223 (process (and buffer (get-buffer-process buffer))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
224 (cond ((not buffer)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
225 (error "Buffer does not exist" buffer-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
226 ((not process)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
227 (error "Buffer is not a scheme interaction buffer" buffer-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
228 (t
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
229 (save-excursion
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
230 (set-buffer buffer)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
231 (if (not (xscheme-process-buffer-current-p))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
232 (error "Buffer is not a scheme interaction buffer"
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
233 buffer-name)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
234 (process-name process)))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
235
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
236 ;;;; Interaction Mode
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
237
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
238 (defun scheme-interaction-mode (&optional preserve)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
239 "Major mode for interacting with an inferior MIT Scheme process.
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
240 Like scheme-mode except that:
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
241
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
242 \\[advertised-xscheme-send-previous-expression] sends the expression before point to the Scheme process as input
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
243 \\[xscheme-yank-pop] yanks an expression previously sent to Scheme
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
244 \\[xscheme-yank-push] yanks an expression more recently sent to Scheme
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
245
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
246 All output from the Scheme process is written in the Scheme process
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
247 buffer, which is initially named \"*scheme*\". The result of
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
248 evaluating a Scheme expression is also printed in the process buffer,
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
249 preceded by the string \";Value: \" to highlight it. If the process
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
250 buffer is not visible at that time, the value will also be displayed
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
251 in the minibuffer. If an error occurs, the process buffer will
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
252 automatically pop up to show you the error message.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
253
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
254 While the Scheme process is running, the modelines of all buffers in
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
255 scheme-mode are modified to show the state of the process. The
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
256 possible states and their meanings are:
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
257
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
258 input waiting for input
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
259 run evaluating
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
260 gc garbage collecting
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
261
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
262 The process buffer's modeline contains additional information where
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
263 the buffer's name is normally displayed: the command interpreter level
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
264 and type.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
265
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
266 Scheme maintains a stack of command interpreters. Every time an error
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
267 or breakpoint occurs, the current command interpreter is pushed on the
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
268 command interpreter stack, and a new command interpreter is started.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
269 One example of why this is done is so that an error that occurs while
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
270 you are debugging another error will not destroy the state of the
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
271 initial error, allowing you to return to it after the second error has
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
272 been fixed.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
273
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
274 The command interpreter level indicates how many interpreters are in
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
275 the command interpreter stack. It is initially set to one, and it is
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
276 incremented every time that stack is pushed, and decremented every
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
277 time it is popped. The following commands are useful for manipulating
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
278 the command interpreter stack:
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
279
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
280 \\[xscheme-send-breakpoint-interrupt] pushes the stack once
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
281 \\[xscheme-send-control-u-interrupt] pops the stack once
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
282 \\[xscheme-send-control-g-interrupt] pops everything off
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
283 \\[xscheme-send-control-x-interrupt] aborts evaluation, doesn't affect stack
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
284
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
285 Some possible command interpreter types and their meanings are:
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
286
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
287 [Evaluator] read-eval-print loop for evaluating expressions
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
288 [Debugger] single character commands for debugging errors
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
289 [Where] single character commands for examining environments
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
290
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
291 Starting with release 6.2 of Scheme, the latter two types of command
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
292 interpreters will change the major mode of the Scheme process buffer
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
293 to scheme-debugger-mode , in which the evaluation commands are
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
294 disabled, and the keys which normally self insert instead send
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
295 themselves to the Scheme process. The command character ? will list
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
296 the available commands.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
297
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
298 For older releases of Scheme, the major mode will be be
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
299 scheme-interaction-mode , and the command characters must be sent as
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
300 if they were expressions.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
301
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
302 Commands:
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
303 Delete converts tabs to spaces as it moves back.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
304 Blank lines separate paragraphs. Semicolons start comments.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
305 \\{scheme-interaction-mode-map}
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
306
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
307 Entry to this mode calls the value of scheme-interaction-mode-hook
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
308 with no args, if that value is non-nil.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
309 Likewise with the value of scheme-mode-hook.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
310 scheme-interaction-mode-hook is called after scheme-mode-hook."
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
311 (interactive "P")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
312 (if (not preserve)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
313 (let ((previous-mode major-mode))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
314 (kill-all-local-variables)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
315 (make-local-variable 'xscheme-previous-mode)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
316 (make-local-variable 'xscheme-buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
317 (make-local-variable 'xscheme-process-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
318 (make-local-variable 'xscheme-previous-process-state)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
319 (make-local-variable 'xscheme-runlight-string)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
320 (make-local-variable 'xscheme-runlight)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
321 (make-local-variable 'xscheme-last-input-end)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
322 (setq xscheme-previous-mode previous-mode)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
323 (let ((buffer (current-buffer)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
324 (setq xscheme-buffer-name (buffer-name buffer))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
325 (setq xscheme-last-input-end (make-marker))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
326 (let ((process (get-buffer-process buffer)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
327 (if process
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
328 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
329 (setq xscheme-process-name (process-name process))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
330 (setq xscheme-previous-process-state
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
331 (cons (process-filter process)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
332 (process-sentinel process)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
333 (xscheme-process-filter-initialize t)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
334 (xscheme-modeline-initialize xscheme-buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
335 (set-process-sentinel process 'xscheme-process-sentinel)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
336 (set-process-filter process 'xscheme-process-filter))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
337 (setq xscheme-previous-process-state (cons nil nil)))))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
338 (scheme-interaction-mode-initialize)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
339 (scheme-mode-variables)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
340 (run-hooks 'scheme-mode-hook 'scheme-interaction-mode-hook))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
341
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
342 (defun exit-scheme-interaction-mode ()
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
343 "Take buffer out of scheme interaction mode"
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
344 (interactive)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
345 (if (not (eq major-mode 'scheme-interaction-mode))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
346 (error "Buffer not in scheme interaction mode"))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
347 (let ((previous-state xscheme-previous-process-state))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
348 (funcall xscheme-previous-mode)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
349 (let ((process (get-buffer-process (current-buffer))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
350 (if process
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
351 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
352 (if (eq (process-filter process) 'xscheme-process-filter)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
353 (set-process-filter process (car previous-state)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
354 (if (eq (process-sentinel process) 'xscheme-process-sentinel)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
355 (set-process-sentinel process (cdr previous-state))))))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
356
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
357 (defun scheme-interaction-mode-initialize ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
358 (use-local-map scheme-interaction-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
359 (setq major-mode 'scheme-interaction-mode)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
360 (setq mode-name "Scheme Interaction"))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
361
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
362 (defun scheme-interaction-mode-commands (keymap)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
363 (let ((entries scheme-interaction-mode-commands-alist))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
364 (while entries
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
365 (define-key keymap
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
366 (car (car entries))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
367 (car (cdr (car entries))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
368 (setq entries (cdr entries)))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
369
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
370 (defvar scheme-interaction-mode-commands-alist nil)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
371 (setq scheme-interaction-mode-commands-alist
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
372 (append scheme-interaction-mode-commands-alist
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
373 '(("\C-c\C-m" xscheme-send-current-line)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
374 ("\C-c\C-o" xscheme-delete-output)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
375 ("\C-c\C-p" xscheme-send-proceed)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
376 ("\C-c\C-y" xscheme-yank)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
377 ("\ep" xscheme-yank-pop)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
378 ("\en" xscheme-yank-push))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
379
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
380 (defvar scheme-interaction-mode-map nil)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
381 (if (not scheme-interaction-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
382 (progn
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
383 (setq scheme-interaction-mode-map (make-keymap))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
384 (scheme-mode-commands scheme-interaction-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
385 (xscheme-interrupt-commands scheme-interaction-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
386 (xscheme-evaluation-commands scheme-interaction-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
387 (scheme-interaction-mode-commands scheme-interaction-mode-map)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
388
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
389 (defun xscheme-enter-interaction-mode ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
390 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
391 (set-buffer (xscheme-process-buffer))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
392 (if (not (eq major-mode 'scheme-interaction-mode))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
393 (if (eq major-mode 'scheme-debugger-mode)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
394 (scheme-interaction-mode-initialize)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
395 (scheme-interaction-mode t)))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
396
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
397 (fset 'advertised-xscheme-send-previous-expression
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
398 'xscheme-send-previous-expression)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
399
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
400 ;;;; Debugger Mode
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
401
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
402 (defun scheme-debugger-mode ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
403 "Major mode for executing the Scheme debugger.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
404 Like scheme-mode except that the evaluation commands
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
405 are disabled, and characters that would normally be self inserting are
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
406 sent to the Scheme process instead. Typing ? will show you which
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
407 characters perform useful functions.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
408
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
409 Commands:
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
410 \\{scheme-debugger-mode-map}"
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
411 (error "Illegal entry to scheme-debugger-mode"))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
412
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
413 (defun scheme-debugger-mode-initialize ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
414 (use-local-map scheme-debugger-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
415 (setq major-mode 'scheme-debugger-mode)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
416 (setq mode-name "Scheme Debugger"))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
417
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
418 (defun scheme-debugger-mode-commands (keymap)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
419 (let ((char ? ))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
420 (while (< char 127)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
421 (define-key keymap (char-to-string char) 'scheme-debugger-self-insert)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
422 (setq char (1+ char)))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
423
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
424 (defvar scheme-debugger-mode-map nil)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
425 (if (not scheme-debugger-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
426 (progn
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
427 (setq scheme-debugger-mode-map (make-keymap))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
428 (scheme-mode-commands scheme-debugger-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
429 (xscheme-interrupt-commands scheme-debugger-mode-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
430 (scheme-debugger-mode-commands scheme-debugger-mode-map)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
431
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
432 (defun scheme-debugger-self-insert ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
433 "Transmit this character to the Scheme process."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
434 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
435 (xscheme-send-char last-command-char))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
436
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
437 (defun xscheme-enter-debugger-mode (prompt-string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
438 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
439 (set-buffer (xscheme-process-buffer))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
440 (if (not (eq major-mode 'scheme-debugger-mode))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
441 (progn
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
442 (if (not (eq major-mode 'scheme-interaction-mode))
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
443 (scheme-interaction-mode t))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
444 (scheme-debugger-mode-initialize)))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
445
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
446 (defun xscheme-debugger-mode-p ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
447 (let ((buffer (xscheme-process-buffer)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
448 (and buffer
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
449 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
450 (set-buffer buffer)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
451 (eq major-mode 'scheme-debugger-mode)))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
452
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
453 ;;;; Evaluation Commands
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
454
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
455 (defun xscheme-send-string (&rest strings)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
456 "Send the string arguments to the Scheme process.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
457 The strings are concatenated and terminated by a newline."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
458 (cond ((not (xscheme-process-running-p))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
459 (if (yes-or-no-p "The Scheme process has died. Reset it? ")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
460 (progn
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
461 (reset-scheme)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
462 (xscheme-wait-for-process)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
463 (xscheme-send-string-1 strings))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
464 ((xscheme-debugger-mode-p) (error "No sends allowed in debugger mode"))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
465 ((and (not xscheme-allow-pipelined-evaluation)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
466 xscheme-running-p)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
467 (error "No sends allowed while Scheme running"))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
468 (t (xscheme-send-string-1 strings))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
469
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
470 (defun xscheme-send-string-1 (strings)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
471 (let ((string (apply 'concat strings)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
472 (xscheme-send-string-2 string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
473 (if (eq major-mode 'scheme-interaction-mode)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
474 (xscheme-insert-expression string))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
475
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
476 (defun xscheme-send-string-2 (string)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
477 (let ((process (get-process xscheme-process-name)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
478 (process-send-string process (concat string "\n"))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
479 (if (xscheme-process-buffer-current-p)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
480 (set-marker (process-mark process) (point)))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
481
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
482 (defun xscheme-select-process-buffer ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
483 "Select the Scheme process buffer and move to its output point."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
484 (interactive)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
485 (let ((process
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
486 (or (get-process xscheme-process-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
487 (error "No scheme process"))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
488 (let ((buffer (or (process-buffer process) (error "No process buffer"))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
489 (let ((window (get-buffer-window buffer)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
490 (if window
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
491 (select-window window)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
492 (switch-to-buffer buffer))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
493 (goto-char (process-mark process))))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
494
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
495 ;;;; Scheme expressions ring
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
496
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
497 (defun xscheme-insert-expression (string)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
498 (setq xscheme-expressions-ring (cons string xscheme-expressions-ring))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
499 (if (> (length xscheme-expressions-ring) xscheme-expressions-ring-max)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
500 (setcdr (nthcdr (1- xscheme-expressions-ring-max)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
501 xscheme-expressions-ring)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
502 nil))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
503 (setq xscheme-expressions-ring-yank-pointer xscheme-expressions-ring))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
504
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
505 (defun xscheme-rotate-yank-pointer (arg)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
506 "Rotate the yanking point in the kill ring."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
507 (interactive "p")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
508 (let ((length (length xscheme-expressions-ring)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
509 (if (zerop length)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
510 (error "Scheme expression ring is empty")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
511 (setq xscheme-expressions-ring-yank-pointer
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
512 (let ((index
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
513 (% (+ arg
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
514 (- length
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
515 (length xscheme-expressions-ring-yank-pointer)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
516 length)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
517 (nthcdr (if (< index 0)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
518 (+ index length)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
519 index)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
520 xscheme-expressions-ring))))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
521
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
522 (defun xscheme-yank (&optional arg)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
523 "Insert the most recent expression at point.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
524 With just C-U as argument, same but put point in front (and mark at end).
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
525 With argument n, reinsert the nth most recently sent expression.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
526 See also the commands \\[xscheme-yank-pop] and \\[xscheme-yank-push]."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
527 (interactive "*P")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
528 (xscheme-rotate-yank-pointer (if (listp arg) 0
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
529 (if (eq arg '-) -1
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
530 (1- arg))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
531 (push-mark (point))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
532 (insert (car xscheme-expressions-ring-yank-pointer))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
533 (if (consp arg)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
534 (exchange-point-and-mark)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
535
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
536 ;; Old name, to avoid errors in users' init files.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
537 (fset 'xscheme-yank-previous-send
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
538 'xscheme-yank)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
539
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
540 (defun xscheme-yank-pop (arg)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
541 "Insert or replace a just-yanked expression with an older expression.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
542 If the previous command was not a yank, it yanks.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
543 Otherwise, the region contains a stretch of reinserted
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
544 expression. yank-pop deletes that text and inserts in its
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
545 place a different expression.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
546
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
547 With no argument, the next older expression is inserted.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
548 With argument n, the n'th older expression is inserted.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
549 If n is negative, this is a more recent expression.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
550
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
551 The sequence of expressions wraps around, so that after the oldest one
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
552 comes the newest one."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
553 (interactive "*p")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
554 (setq this-command 'xscheme-yank)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
555 (if (not (eq last-command 'xscheme-yank))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
556 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
557 (xscheme-yank)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
558 (setq arg (- arg 1))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
559 (if (not (= arg 0))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
560 (let ((before (< (point) (mark))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
561 (delete-region (point) (mark))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
562 (xscheme-rotate-yank-pointer arg)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
563 (set-mark (point))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
564 (insert (car xscheme-expressions-ring-yank-pointer))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
565 (if before (exchange-point-and-mark)))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
566
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
567 (defun xscheme-yank-push (arg)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
568 "Insert or replace a just-yanked expression with a more recent expression.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
569 If the previous command was not a yank, it yanks.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
570 Otherwise, the region contains a stretch of reinserted
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
571 expression. yank-pop deletes that text and inserts in its
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
572 place a different expression.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
573
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
574 With no argument, the next more recent expression is inserted.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
575 With argument n, the n'th more recent expression is inserted.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
576 If n is negative, a less recent expression is used.
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
577
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
578 The sequence of expressions wraps around, so that after the oldest one
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
579 comes the newest one."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
580 (interactive "*p")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
581 (xscheme-yank-pop (- 0 arg)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
582
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
583 (defun xscheme-send-region (start end)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
584 "Send the current region to the Scheme process.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
585 The region is sent terminated by a newline."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
586 (interactive "r")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
587 (if (xscheme-process-buffer-current-p)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
588 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
589 (goto-char end)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
590 (if (not (bolp))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
591 (insert-before-markers ?\n))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
592 (set-marker (process-mark (get-process xscheme-process-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
593 (point))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
594 (set-marker xscheme-last-input-end (point))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
595 (xscheme-send-string (buffer-substring start end)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
596
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
597 (defun xscheme-send-definition ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
598 "Send the current definition to the Scheme process.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
599 If the current line begins with a non-whitespace character,
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
600 parse an expression from the beginning of the line and send that instead."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
601 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
602 (let ((start nil) (end nil))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
603 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
604 (end-of-defun)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
605 (setq end (point))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
606 (if (re-search-backward "^\\s(" nil t)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
607 (setq start (point))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
608 (error "Can't find definition")))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
609 (xscheme-send-region start end)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
610
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
611 (defun xscheme-send-next-expression ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
612 "Send the expression to the right of `point' to the Scheme process."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
613 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
614 (let ((start (point)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
615 (xscheme-send-region start (save-excursion (forward-sexp) (point)))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
616
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
617 (defun xscheme-send-previous-expression ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
618 "Send the expression to the left of `point' to the Scheme process."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
619 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
620 (let ((end (point)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
621 (xscheme-send-region (save-excursion (backward-sexp) (point)) end)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
622
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
623 (defun xscheme-send-current-line ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
624 "Send the current line to the Scheme process.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
625 Useful for working with debugging Scheme under adb."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
626 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
627 (let ((line
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
628 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
629 (beginning-of-line)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
630 (let ((start (point)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
631 (end-of-line)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
632 (buffer-substring start (point))))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
633 (end-of-line)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
634 (insert ?\n)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
635 (xscheme-send-string-2 line)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
636
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
637 (defun xscheme-send-buffer ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
638 "Send the current buffer to the Scheme process."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
639 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
640 (if (xscheme-process-buffer-current-p)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
641 (error "Not allowed to send this buffer's contents to Scheme"))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
642 (xscheme-send-region (point-min) (point-max)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
643
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
644 (defun xscheme-send-char (char)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
645 "Prompt for a character and send it to the Scheme process."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
646 (interactive "cCharacter to send: ")
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
647 (process-send-string xscheme-process-name (char-to-string char)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
648
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
649 (defun xscheme-delete-output ()
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
650 "Delete all output from interpreter since last input."
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
651 (interactive)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
652 (let ((proc (get-buffer-process (current-buffer))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
653 (save-excursion
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
654 (goto-char (process-mark proc))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
655 (re-search-backward
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
656 "^;\\(Unspecified return value$\\|Value\\( [0-9]+\\)?: \\|\\(Abort\\|Up\\|Quit\\)!$\\)"
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
657 xscheme-last-input-end
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
658 t)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
659 (forward-line 0)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
660 (if (< (marker-position xscheme-last-input-end) (point))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
661 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
662 (delete-region xscheme-last-input-end (point))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
663 (insert-before-markers "*** output flushed ***\n"))))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
664
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
665 ;;;; Interrupts
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
666
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
667 (defun xscheme-send-breakpoint-interrupt ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
668 "Cause the Scheme process to enter a breakpoint."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
669 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
670 (xscheme-send-interrupt ?b nil))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
671
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
672 (defun xscheme-send-proceed ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
673 "Cause the Scheme process to proceed from a breakpoint."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
674 (interactive)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
675 (process-send-string xscheme-process-name "(proceed)\n"))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
676
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
677 (defun xscheme-send-control-g-interrupt ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
678 "Cause the Scheme processor to halt and flush input.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
679 Control returns to the top level rep loop."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
680 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
681 (let ((inhibit-quit t))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
682 (cond ((not xscheme-control-g-synchronization-p)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
683 (interrupt-process xscheme-process-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
684 ((save-excursion
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
685 (set-buffer xscheme-buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
686 xscheme-control-g-disabled-p)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
687 (message "Relax..."))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
688 (t
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
689 (save-excursion
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
690 (set-buffer xscheme-buffer-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
691 (setq xscheme-control-g-disabled-p t))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
692 (message xscheme-control-g-message-string)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
693 (interrupt-process xscheme-process-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
694 (sleep-for 0.1)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
695 (xscheme-send-char 0)))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
696
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
697 (defconst xscheme-control-g-message-string
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
698 "Sending C-G interrupt to Scheme...")
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
699
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
700 (defun xscheme-send-control-u-interrupt ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
701 "Cause the Scheme process to halt, returning to previous rep loop."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
702 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
703 (xscheme-send-interrupt ?u t))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
704
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
705 (defun xscheme-send-control-x-interrupt ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
706 "Cause the Scheme process to halt, returning to current rep loop."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
707 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
708 (xscheme-send-interrupt ?x t))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
709
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
710 ;;; This doesn't really work right -- Scheme just gobbles the first
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
711 ;;; character in the input. There is no way for us to guarantee that
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
712 ;;; the argument to this procedure is the first char unless we put
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
713 ;;; some kind of marker in the input stream.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
714
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
715 (defun xscheme-send-interrupt (char mark-p)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
716 "Send a ^A type interrupt to the Scheme process."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
717 (interactive "cInterrupt character to send: ")
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
718 (quit-process xscheme-process-name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
719 (sleep-for 0.1)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
720 (xscheme-send-char char)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
721 (if (and mark-p xscheme-control-g-synchronization-p)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
722 (xscheme-send-char 0)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
723
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
724 ;;;; Internal Variables
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
725
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
726 (defvar xscheme-process-command-line nil
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
727 "Command used to start the most recent Scheme process.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
728
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
729 (defvar xscheme-process-name "scheme"
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
730 "Name of xscheme process that we're currently interacting with.")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
731
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
732 (defvar xscheme-buffer-name "*scheme*"
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
733 "Name of xscheme buffer that we're currently interacting with.")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
734
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
735 (defvar xscheme-expressions-ring-max 30
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
736 "*Maximum length of Scheme expressions ring.")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
737
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
738 (defvar xscheme-expressions-ring nil
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
739 "List of expressions recently transmitted to the Scheme process.")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
740
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
741 (defvar xscheme-expressions-ring-yank-pointer nil
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
742 "The tail of the Scheme expressions ring whose car is the last thing yanked.")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
743
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
744 (defvar xscheme-last-input-end)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
745
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
746 (defvar xscheme-process-filter-state 'idle
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
747 "State of scheme process escape reader state machine:
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
748 idle waiting for an escape sequence
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
749 reading-type received an altmode but nothing else
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
750 reading-string reading prompt string")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
751
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
752 (defvar xscheme-running-p nil
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
753 "This variable, if nil, indicates that the scheme process is
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
754 waiting for input. Otherwise, it is busy evaluating something.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
755
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
756 (defconst xscheme-control-g-synchronization-p t
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
757 "If non-nil, insert markers in the scheme input stream to indicate when
14016
cc69bd626089 (xscheme-control-g-synchronization-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 12866
diff changeset
758 control-g interrupts were signaled. Do not allow more control-g's to be
cc69bd626089 (xscheme-control-g-synchronization-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 12866
diff changeset
759 signaled until the scheme process acknowledges receipt.")
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
760
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
761 (defvar xscheme-control-g-disabled-p nil
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
762 "This variable, if non-nil, indicates that a control-g is being processed
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
763 by the scheme process, so additional control-g's are to be ignored.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
764
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
765 (defvar xscheme-allow-output-p t
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
766 "This variable, if nil, prevents output from the scheme process
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
767 from being inserted into the process-buffer.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
768
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
769 (defvar xscheme-prompt ""
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
770 "The current scheme prompt string.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
771
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
772 (defvar xscheme-string-accumulator ""
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
773 "Accumulator for the string being received from the scheme process.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
774
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
775 (defvar xscheme-string-receiver nil
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
776 "Procedure to send the string argument from the scheme process.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
777
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
778 (defconst default-xscheme-runlight
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
779 '(": " xscheme-runlight-string)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
780 "Default global (shared) xscheme-runlight modeline format.")
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
781
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
782 (defvar xscheme-runlight "")
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
783 (defvar xscheme-runlight-string nil)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
784 (defvar xscheme-mode-string nil)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
785 (setq-default scheme-mode-line-process
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
786 '("" xscheme-runlight))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
787
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
788 (mapcar 'make-variable-buffer-local
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
789 '(xscheme-expressions-ring
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
790 xscheme-expressions-ring-yank-pointer
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
791 xscheme-process-filter-state
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
792 xscheme-running-p
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
793 xscheme-control-g-disabled-p
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
794 xscheme-allow-output-p
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
795 xscheme-prompt
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
796 xscheme-string-accumulator
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
797 xscheme-mode-string
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
798 scheme-mode-line-process))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
799
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
800 ;;;; Basic Process Control
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
801
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
802 (defun xscheme-start-process (command-line the-process the-buffer)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
803 (let ((buffer (get-buffer-create the-buffer)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
804 (let ((process (get-buffer-process buffer)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
805 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
806 (set-buffer buffer)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
807 (if (and process (memq (process-status process) '(run stop)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
808 (set-marker (process-mark process) (point-max))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
809 (progn (if process (delete-process process))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
810 (goto-char (point-max))
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
811 (scheme-interaction-mode nil)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
812 (setq xscheme-process-name the-process)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
813 (if (bobp)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
814 (insert-before-markers
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
815 (substitute-command-keys xscheme-startup-message)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
816 (setq process
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
817 (let ((process-connection-type nil))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
818 (apply 'start-process
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
819 (cons the-process
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
820 (cons buffer
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
821 (xscheme-parse-command-line
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
822 command-line))))))
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
823 (if (not (equal (process-name process) the-process))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
824 (setq xscheme-process-name (process-name process)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
825 (if (not (equal (buffer-name buffer) the-buffer))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
826 (setq xscheme-buffer-name (buffer-name buffer)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
827 (message "Starting process %s in buffer %s"
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
828 xscheme-process-name
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
829 xscheme-buffer-name)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
830 (set-marker (process-mark process) (point-max))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
831 (xscheme-process-filter-initialize t)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
832 (xscheme-modeline-initialize xscheme-buffer-name)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
833 (set-process-sentinel process 'xscheme-process-sentinel)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
834 (set-process-filter process 'xscheme-process-filter)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
835 (run-hooks 'xscheme-start-hook)))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
836 buffer))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
837
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
838 (defun xscheme-parse-command-line (string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
839 (setq string (substitute-in-file-name string))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
840 (let ((start 0)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
841 (result '()))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
842 (while start
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
843 (let ((index (string-match "[ \t]" string start)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
844 (setq start
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
845 (cond ((not index)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
846 (setq result
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
847 (cons (substring string start)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
848 result))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
849 nil)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
850 ((= index start)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
851 (string-match "[^ \t]" string start))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
852 (t
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
853 (setq result
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
854 (cons (substring string start index)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
855 result))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
856 (1+ index))))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
857 (nreverse result)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
858
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
859 (defun xscheme-wait-for-process ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
860 (sleep-for 2)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
861 (while xscheme-running-p
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
862 (sleep-for 1)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
863
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
864 (defun xscheme-process-running-p ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
865 "True iff there is a Scheme process whose status is `run'."
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
866 (let ((process (get-process xscheme-process-name)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
867 (and process
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
868 (eq (process-status process) 'run))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
869
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
870 (defun xscheme-process-buffer ()
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
871 (let ((process (get-process xscheme-process-name)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
872 (and process (process-buffer process))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
873
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
874 (defun xscheme-process-buffer-window ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
875 (let ((buffer (xscheme-process-buffer)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
876 (and buffer (get-buffer-window buffer))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
877
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
878 (defun xscheme-process-buffer-current-p ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
879 "True iff the current buffer is the Scheme process buffer."
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
880 (eq (xscheme-process-buffer) (current-buffer)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
881
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
882 ;;;; Process Filter
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
883
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
884 (defun xscheme-process-sentinel (proc reason)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
885 (let* ((buffer (process-buffer proc))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
886 (name (buffer-name buffer)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
887 (save-excursion
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
888 (set-buffer buffer)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
889 (xscheme-process-filter-initialize (eq reason 'run))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
890 (if (not (eq reason 'run))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
891 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
892 (setq scheme-mode-line-process "")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
893 (setq xscheme-mode-string "no process")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
894 (if (equal name (default-value 'xscheme-buffer-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
895 (setq-default xscheme-runlight ""))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
896 (if (and (not (memq reason '(run stop)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
897 xscheme-signal-death-message)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
898 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
899 (beep)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
900 (message
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
901 "The Scheme process has died! Do M-x reset-scheme to restart it"))))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
902
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
903 (defun xscheme-process-filter-initialize (running-p)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
904 (setq xscheme-process-filter-state 'idle)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
905 (setq xscheme-running-p running-p)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
906 (setq xscheme-control-g-disabled-p nil)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
907 (setq xscheme-allow-output-p t)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
908 (setq xscheme-prompt "")
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
909 (if running-p
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
910 (let ((name (buffer-name (current-buffer))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
911 (setq scheme-mode-line-process '(": " xscheme-runlight-string))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
912 (xscheme-modeline-initialize name)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
913 (if (equal name (default-value 'xscheme-buffer-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
914 (setq-default xscheme-runlight default-xscheme-runlight))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
915 (if (or (eq xscheme-runlight default-xscheme-runlight)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
916 (equal xscheme-runlight ""))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
917 (setq xscheme-runlight (list ": " 'xscheme-buffer-name ": " "?")))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
918 (rplaca (nthcdr 3 xscheme-runlight)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
919 (if running-p "?" "no process")))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
920
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
921 (defun xscheme-process-filter (proc string)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
922 (let ((xscheme-filter-input string)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
923 (call-noexcursion nil))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
924 (while xscheme-filter-input
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
925 (setq call-noexcursion nil)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
926 (save-excursion
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
927 (set-buffer (process-buffer proc))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
928 (cond ((eq xscheme-process-filter-state 'idle)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
929 (let ((start (string-match "\e" xscheme-filter-input)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
930 (if start
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
931 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
932 (xscheme-process-filter-output
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
933 (substring xscheme-filter-input 0 start))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
934 (setq xscheme-filter-input
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
935 (substring xscheme-filter-input (1+ start)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
936 (setq xscheme-process-filter-state 'reading-type))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
937 (let ((string xscheme-filter-input))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
938 (setq xscheme-filter-input nil)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
939 (xscheme-process-filter-output string)))))
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
940 ((eq xscheme-process-filter-state 'reading-type)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
941 (if (zerop (length xscheme-filter-input))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
942 (setq xscheme-filter-input nil)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
943 (let ((char (aref xscheme-filter-input 0)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
944 (setq xscheme-filter-input
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
945 (substring xscheme-filter-input 1))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
946 (let ((entry (assoc char xscheme-process-filter-alist)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
947 (if entry
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
948 (funcall (nth 2 entry) (nth 1 entry))
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
949 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
950 (xscheme-process-filter-output ?\e char)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
951 (setq xscheme-process-filter-state 'idle)))))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
952 ((eq xscheme-process-filter-state 'reading-string)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
953 (let ((start (string-match "\e" xscheme-filter-input)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
954 (if start
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
955 (let ((string
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
956 (concat xscheme-string-accumulator
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
957 (substring xscheme-filter-input 0 start))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
958 (setq xscheme-filter-input
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
959 (substring xscheme-filter-input (1+ start)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
960 (setq xscheme-process-filter-state 'idle)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
961 (if (listp xscheme-string-receiver)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
962 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
963 (setq xscheme-string-receiver
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
964 (car xscheme-string-receiver))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
965 (setq call-noexcursion string))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
966 (funcall xscheme-string-receiver string)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
967 (progn
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
968 (setq xscheme-string-accumulator
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
969 (concat xscheme-string-accumulator
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
970 xscheme-filter-input))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
971 (setq xscheme-filter-input nil)))))
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
972 (t
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
973 (error "Scheme process filter -- bad state"))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
974 (if call-noexcursion
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
975 (funcall xscheme-string-receiver call-noexcursion)))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
976
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
977 ;;;; Process Filter Output
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
978
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
979 (defun xscheme-process-filter-output (&rest args)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
980 (if xscheme-allow-output-p
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
981 (let ((string (apply 'concat args)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
982 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
983 (xscheme-goto-output-point)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
984 (let ((old-point (point)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
985 (while (string-match "\\(\007\\|\f\\)" string)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
986 (let ((start (match-beginning 0))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
987 (end (match-end 0)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
988 (insert-before-markers (substring string 0 start))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
989 (if (= ?\f (aref string start))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
990 (progn
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
991 (if (not (bolp))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
992 (insert-before-markers ?\n))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
993 (insert-before-markers ?\f))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
994 (beep))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
995 (setq string (substring string (1+ start)))))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
996 (insert-before-markers string)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
997 (if (and xscheme-last-input-end
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
998 (equal (marker-position xscheme-last-input-end) (point)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
999 (set-marker xscheme-last-input-end old-point)))))))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1000
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1001 (defun xscheme-guarantee-newlines (n)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1002 (if xscheme-allow-output-p
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1003 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1004 (xscheme-goto-output-point)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1005 (let ((stop nil))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1006 (while (and (not stop)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1007 (bolp))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1008 (setq n (1- n))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1009 (if (bobp)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1010 (setq stop t)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1011 (backward-char))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1012 (xscheme-goto-output-point)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1013 (while (> n 0)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1014 (insert-before-markers ?\n)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1015 (setq n (1- n))))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1016
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1017 (defun xscheme-goto-output-point ()
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1018 (let ((process (get-process xscheme-process-name)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1019 (set-buffer (process-buffer process))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1020 (goto-char (process-mark process))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1021
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1022 (defun xscheme-modeline-initialize (name)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1023 (setq xscheme-runlight-string "")
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1024 (if (equal name (default-value 'xscheme-buffer-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1025 (setq-default xscheme-runlight-string ""))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1026 (setq xscheme-mode-string "")
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1027 (setq mode-line-buffer-identification
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1028 (list (concat name ": ")
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1029 'xscheme-mode-string)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1030
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1031 (defun xscheme-set-runlight (runlight)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1032 (setq xscheme-runlight-string runlight)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1033 (if (equal (buffer-name (current-buffer))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1034 (default-value 'xscheme-buffer-name))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1035 (setq-default xscheme-runlight-string runlight))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1036 (rplaca (nthcdr 3 xscheme-runlight) runlight)
11565
61cdc55737fb (xscheme-set-runlight, xscheme-set-prompt): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents: 9590
diff changeset
1037 (force-mode-line-update t))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1038
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1039 ;;;; Process Filter Operations
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1040
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1041 (defvar xscheme-process-filter-alist
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1042 '((?A xscheme-eval
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1043 xscheme-process-filter:string-action-noexcursion)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1044 (?D xscheme-enter-debugger-mode
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1045 xscheme-process-filter:string-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1046 (?E xscheme-eval
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1047 xscheme-process-filter:string-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1048 (?P xscheme-set-prompt-variable
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1049 xscheme-process-filter:string-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1050 (?R xscheme-enter-interaction-mode
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1051 xscheme-process-filter:simple-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1052 (?b xscheme-start-gc
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1053 xscheme-process-filter:simple-action)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1054 (?c xscheme-unsolicited-read-char
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1055 xscheme-process-filter:simple-action)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1056 (?e xscheme-finish-gc
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1057 xscheme-process-filter:simple-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1058 (?f xscheme-exit-input-wait
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1059 xscheme-process-filter:simple-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1060 (?g xscheme-enable-control-g
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1061 xscheme-process-filter:simple-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1062 (?i xscheme-prompt-for-expression
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1063 xscheme-process-filter:string-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1064 (?m xscheme-message
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1065 xscheme-process-filter:string-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1066 (?n xscheme-prompt-for-confirmation
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1067 xscheme-process-filter:string-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1068 (?o xscheme-output-goto
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1069 xscheme-process-filter:simple-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1070 (?p xscheme-set-prompt
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1071 xscheme-process-filter:string-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1072 (?s xscheme-enter-input-wait
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1073 xscheme-process-filter:simple-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1074 (?v xscheme-write-value
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1075 xscheme-process-filter:string-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1076 (?w xscheme-cd
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1077 xscheme-process-filter:string-action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1078 (?z xscheme-display-process-buffer
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1079 xscheme-process-filter:simple-action))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1080 "Table used to decide how to handle process filter commands.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1081 Value is a list of entries, each entry is a list of three items.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1082
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1083 The first item is the character that the process filter dispatches on.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1084 The second item is the action to be taken, a function.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1085 The third item is the handler for the entry, a function.
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1086
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1087 When the process filter sees a command whose character matches a
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1088 particular entry, it calls the handler with two arguments: the action
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1089 and the string containing the rest of the process filter's input
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1090 stream. It is the responsibility of the handler to invoke the action
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1091 with the appropriate arguments, and to reenter the process filter with
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1092 the remaining input.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1093
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1094 (defun xscheme-process-filter:simple-action (action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1095 (setq xscheme-process-filter-state 'idle)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1096 (funcall action))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1097
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1098 (defun xscheme-process-filter:string-action (action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1099 (setq xscheme-string-receiver action)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1100 (setq xscheme-string-accumulator "")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1101 (setq xscheme-process-filter-state 'reading-string))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1102
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1103 (defun xscheme-process-filter:string-action-noexcursion (action)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1104 (xscheme-process-filter:string-action (cons action nil)))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1105
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1106 (defconst xscheme-runlight:running "run"
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1107 "The character displayed when the Scheme process is running.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1108
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1109 (defconst xscheme-runlight:input "input"
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1110 "The character displayed when the Scheme process is waiting for input.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1111
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1112 (defconst xscheme-runlight:gc "gc"
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1113 "The character displayed when the Scheme process is garbage collecting.")
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1114
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1115 (defun xscheme-start-gc ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1116 (xscheme-set-runlight xscheme-runlight:gc))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1117
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1118 (defun xscheme-finish-gc ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1119 (xscheme-set-runlight
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1120 (if xscheme-running-p xscheme-runlight:running xscheme-runlight:input)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1121
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1122 (defun xscheme-enter-input-wait ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1123 (xscheme-set-runlight xscheme-runlight:input)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1124 (setq xscheme-control-g-disabled-p nil)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1125 (setq xscheme-running-p nil))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1126
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1127 (defun xscheme-exit-input-wait ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1128 (xscheme-set-runlight xscheme-runlight:running)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1129 (setq xscheme-running-p t))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1130
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1131 (defun xscheme-enable-control-g ()
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1132 (setq xscheme-control-g-disabled-p nil)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1133 (if (string= (current-message) xscheme-control-g-message-string)
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1134 (message nil)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1135
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1136 (defun xscheme-display-process-buffer ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1137 (let ((window (or (xscheme-process-buffer-window)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1138 (display-buffer (xscheme-process-buffer)))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1139 (save-window-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1140 (select-window window)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1141 (xscheme-goto-output-point)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1142 (if (xscheme-debugger-mode-p)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1143 (xscheme-enter-interaction-mode)))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1144
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1145 (defun xscheme-unsolicited-read-char ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1146 nil)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1147
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1148 (defun xscheme-eval (string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1149 (eval (car (read-from-string string))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1150
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1151 (defun xscheme-message (string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1152 (if (not (zerop (length string)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1153 (xscheme-write-message-1 string (format ";%s" string))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1154
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1155 (defun xscheme-write-value (string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1156 (if (zerop (length string))
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1157 (xscheme-write-message-1 "(no value)" ";Unspecified return value")
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1158 (xscheme-write-message-1 string (format ";Value: %s" string))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1159
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1160 (defun xscheme-write-message-1 (message-string output-string)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1161 (let* ((process (get-process xscheme-process-name))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1162 (window (get-buffer-window (process-buffer process))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1163 (if (or (not window)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1164 (not (pos-visible-in-window-p (process-mark process)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1165 window)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1166 (message "%s" message-string)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1167 (xscheme-guarantee-newlines 1)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1168 (xscheme-process-filter-output output-string))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1169
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1170 (defun xscheme-set-prompt-variable (string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1171 (setq xscheme-prompt string))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1172
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1173 (defun xscheme-set-prompt (string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1174 (setq xscheme-prompt string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1175 (xscheme-guarantee-newlines 2)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1176 (setq xscheme-mode-string (xscheme-coerce-prompt string))
11565
61cdc55737fb (xscheme-set-runlight, xscheme-set-prompt): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents: 9590
diff changeset
1177 (force-mode-line-update t))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1178
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1179 (defun xscheme-output-goto ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1180 (xscheme-goto-output-point)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1181 (xscheme-guarantee-newlines 2))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1182
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1183 (defun xscheme-coerce-prompt (string)
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1184 (if (string-match "^[0-9]+ \\[[^]]+\\] " string)
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1185 (let ((end (match-end 0)))
42490
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1186 (xscheme-process-filter-output (substring string end))
0715d86d229c Extensive changes to support multiple xscheme buffers:
Richard M. Stallman <rms@gnu.org>
parents: 33481
diff changeset
1187 (substring string 0 (- end 1)))
91
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1188 string))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1189
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1190 (defun xscheme-cd (directory-string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1191 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1192 (set-buffer (xscheme-process-buffer))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1193 (cd directory-string)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1194
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1195 (defun xscheme-prompt-for-confirmation (prompt-string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1196 (xscheme-send-char (if (y-or-n-p prompt-string) ?y ?n)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1197
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1198 (defun xscheme-prompt-for-expression (prompt-string)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1199 (xscheme-send-string-2
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1200 (read-from-minibuffer prompt-string nil xscheme-prompt-for-expression-map)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1201
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1202 (defvar xscheme-prompt-for-expression-map nil)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1203 (if (not xscheme-prompt-for-expression-map)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1204 (progn
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1205 (setq xscheme-prompt-for-expression-map
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1206 (copy-keymap minibuffer-local-map))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1207 (substitute-key-definition 'exit-minibuffer
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1208 'xscheme-prompt-for-expression-exit
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1209 xscheme-prompt-for-expression-map)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1210
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1211 (defun xscheme-prompt-for-expression-exit ()
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1212 (interactive)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1213 (if (eq (xscheme-region-expression-p (point-min) (point-max)) 'one)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1214 (exit-minibuffer)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1215 (error "input must be a single, complete expression")))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1216
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1217 (defun xscheme-region-expression-p (start end)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1218 (save-excursion
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1219 (let ((old-syntax-table (syntax-table)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1220 (unwind-protect
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1221 (progn
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1222 (set-syntax-table scheme-mode-syntax-table)
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1223 (let ((state (parse-partial-sexp start end)))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1224 (and (zerop (car state)) ;depth = 0
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1225 (nth 2 state) ;last-sexp exists, i.e. >= 1 sexps
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1226 (let ((state (parse-partial-sexp start (nth 2 state))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1227 (if (nth 2 state) 'many 'one)))))
d805392d61e7 Initial revision
Chris Hanson <cph@gnu.org>
parents:
diff changeset
1228 (set-syntax-table old-syntax-table)))))
656
d74e65773062 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
1229
5000
719f0190c04a Add a provide call.
Richard M. Stallman <rms@gnu.org>
parents: 2319
diff changeset
1230 (provide 'xscheme)
719f0190c04a Add a provide call.
Richard M. Stallman <rms@gnu.org>
parents: 2319
diff changeset
1231
656
d74e65773062 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
1232 ;;; xscheme.el ends here