Skip to content
Newer
Older
100644 101 lines (80 sloc) 3.59 KB
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
1 #| -*-Scheme-*-
2
52f57b6 @rmloveland Added email address to file headers.
authored Nov 18, 2012
3 Copyright (C) 2012 Rich Loveland <loveland.richard@gmail.com>
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
4
5 This file is NOT part of MIT/GNU Scheme.
6
7 MIT/GNU Scheme is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or (at
10 your option) any later version.
11
12 MIT/GNU Scheme is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with MIT/GNU Scheme; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
20 USA.
21
22 |#
23
e585093 @rmloveland Changing to ``External Scheme REPL'' mode.
authored Nov 4, 2012
24 ;;;; External Scheme subprocess in a buffer
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
25
26 (declare (usual-integrations))
27
01a1298 @rmloveland Updated some variable names and documentation to use the correct mode…
authored Nov 4, 2012
28 (define-variable external-scheme-repl-prompt-pattern
49b1423 @rmloveland Updated documentation.
authored Nov 4, 2012
29 "Regexp to match the external Scheme's REPL prompt."
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
30 (os/default-shell-prompt-pattern)
31 string?)
32
e585093 @rmloveland Changing to ``External Scheme REPL'' mode.
authored Nov 4, 2012
33 (define-variable explicit-external-scheme-file-name
49b1423 @rmloveland Updated documentation.
authored Nov 4, 2012
34 "If not #f, file name to use for the explicitly requested external Scheme."
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
35 #f
36 string-or-false?)
37
a54ec33 @rmloveland Fixed an error: ``exterior'' is supposed to be ``external''.
authored Nov 4, 2012
38 (define-major-mode external-scheme-repl comint "External Scheme REPL"
49b1423 @rmloveland Updated documentation.
authored Nov 4, 2012
39 "Major mode for interacting with an external Scheme REPL.
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
40 Return after the end of the process' output sends the text from the
41 end of process to the end of the current line.
42
43 If you accidentally suspend your process, use \\[comint-continue-subjob]
44 to continue it.
45
46 Customisation: Entry to this mode runs the hooks on comint-mode-hook and
49b1423 @rmloveland Updated documentation.
authored Nov 4, 2012
47 external-scheme-repl-mode-hook (in that order)."
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
48 (lambda (buffer)
49 (local-set-variable! comint-prompt-regexp
01a1298 @rmloveland Updated some variable names and documentation to use the correct mode…
authored Nov 4, 2012
50 (ref-variable external-scheme-repl-prompt-pattern buffer)
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
51 buffer)
52 (local-set-variable! local-abbrev-table
01a1298 @rmloveland Updated some variable names and documentation to use the correct mode…
authored Nov 4, 2012
53 (ref-variable external-scheme-repl-mode-abbrev-table buffer)
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
54 buffer)
55 (event-distributor/invoke!
01a1298 @rmloveland Updated some variable names and documentation to use the correct mode…
authored Nov 4, 2012
56 (ref-variable external-scheme-repl-mode-hook buffer) buffer)))
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
57
01a1298 @rmloveland Updated some variable names and documentation to use the correct mode…
authored Nov 4, 2012
58 (define-variable external-scheme-repl-mode-abbrev-table
59 "Mode-specific abbrev table for External Scheme REPL mode.")
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
60 (define-abbrev-table 'shell-mode-abbrev-table '())
61
01a1298 @rmloveland Updated some variable names and documentation to use the correct mode…
authored Nov 4, 2012
62 (define-variable external-scheme-repl-mode-hook
63 "An event distributor that is invoked when entering External Scheme REPL mode."
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
64 (make-event-distributor))
65
da628c7 @rmloveland Fixed small error in key definitions.
authored Nov 4, 2012
66 (define-key 'external-scheme-repl #\tab 'lisp-indent-line)
67 (define-key 'external-scheme-repl #\) 'lisp-insert-paren)
68 (define-key 'external-scheme-repl #\c-m-q 'indent-sexp)
b107cb9 @rmloveland Use comint's `beginning of line' command to avoid overshooting the pr…
authored Nov 9, 2012
69 (define-key 'external-scheme-repl #\c-a 'comint-bol)
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
70
71
e585093 @rmloveland Changing to ``External Scheme REPL'' mode.
authored Nov 4, 2012
72 (define-command external-scheme-repl
49b1423 @rmloveland Updated documentation.
authored Nov 4, 2012
73 "Run an external Scheme REPL, with I/O through buffer *external-scheme-repl*.
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
74 With prefix argument, unconditionally create a new buffer and process.
11f020c @rmloveland Steal some appropriate keybindings from Scheme mode.
authored Nov 3, 2012
75 If buffer exists but Scheme process is not running, make new shell.
76 If buffer exists and Scheme process is running, just switch to buffer
49b1423 @rmloveland Updated documentation.
authored Nov 4, 2012
77 *external-scheme-repl*.
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
78
49b1423 @rmloveland Updated documentation.
authored Nov 4, 2012
79 The location of the Scheme binary to use comes from one of:
80 (1) the value entered at the prompt
81 (2) the variable `explicit-external-scheme-file-name', or
82 (3) the PREFERRED_SCHEME environment variable.
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
83
01a1298 @rmloveland Updated some variable names and documentation to use the correct mode…
authored Nov 4, 2012
84 The buffer is put in External Scheme REPL mode, giving commands for sending
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
85 input."
86 "sRun Scheme: \nP"
87 (lambda (scheme-program-name new-buffer?)
88 (select-buffer
89 (let ((program
90 (or
91 scheme-program-name
e585093 @rmloveland Changing to ``External Scheme REPL'' mode.
authored Nov 4, 2012
92 (ref-variable explicit-external-scheme-file-name)
93 (get-environment-variable "PREFERRED_SCHEME"))))
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
94 (apply make-comint
a54ec33 @rmloveland Fixed an error: ``exterior'' is supposed to be ``external''.
authored Nov 4, 2012
95 (ref-mode-object external-scheme-repl)
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
96 (if (not new-buffer?)
a54ec33 @rmloveland Fixed an error: ``exterior'' is supposed to be ``external''.
authored Nov 4, 2012
97 "*external-scheme-repl*"
98 (new-buffer "*external-scheme-repl*"))
9ae3de2 @rmloveland Initial commit.
authored Nov 1, 2012
99 program
100 '())))))
Something went wrong with that request. Please try again.