aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog26
-rw-r--r--lisp/progmodes/xscheme.el292
2 files changed, 175 insertions, 143 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b6e89b0c9ad..b92c234700c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,4 +1,28 @@
12005-08-23 Ed Swarthout <ed.swarthout@gmail.com> (tiny change) 12005-08-23 Juanma Barranquero <lekktu@gmail.com>
2
3 * progmodes/xscheme.el: Trivial changes to silence warnings.
4 (xscheme-previous-mode, xscheme-previous-process-state):
5 Add defvars.
6 (xscheme-last-input-end, xscheme-process-command-line)
7 (xscheme-process-name, xscheme-buffer-name)
8 (xscheme-expressions-ring-max, xscheme-expressions-ring)
9 (xscheme-expressions-ring-yank-pointer, xscheme-running-p)
10 (xscheme-control-g-synchronization-p)
11 (xscheme-control-g-disabled-p, xscheme-string-receiver)
12 (default-xscheme-runlight, xscheme-runlight)
13 (xscheme-runlight-string, xscheme-process-filter-state)
14 (xscheme-allow-output-p, xscheme-prompt, xscheme-mode-string):
15 Move to beginning of file.
16 (scheme-interaction-mode-commands-alist)
17 (scheme-interaction-mode-map, scheme-debugger-mode-map): Declare
18 them before use. Note: the initialization code for the variables
19 has not been moved because it uses functions that reference the
20 variables.
21 (xscheme-control-g-message-string, xscheme-process-filter-alist)
22 (xscheme-prompt-for-expression-map): Declare them before use.
23 (scheme-debugger-mode-commands): "?\ " -> "?\s".
24
252005-08-23 Ed Swarthout <ed.swarthout@gmail.com> (tiny change)
2 26
3 * hexl.el (hexl-print-current-point-info): Fix simple spelling 27 * hexl.el (hexl-print-current-point-info): Fix simple spelling
4 error. 28 error.
diff --git a/lisp/progmodes/xscheme.el b/lisp/progmodes/xscheme.el
index f53653a306d..d568bca5b75 100644
--- a/lisp/progmodes/xscheme.el
+++ b/lisp/progmodes/xscheme.el
@@ -33,6 +33,85 @@
33;;; Code: 33;;; Code:
34 34
35(require 'scheme) 35(require 'scheme)
36
37;;;; Internal Variables
38
39(defvar xscheme-previous-mode)
40(defvar xscheme-previous-process-state)
41(defvar xscheme-last-input-end)
42
43(defvar xscheme-process-command-line nil
44 "Command used to start the most recent Scheme process.")
45
46(defvar xscheme-process-name "scheme"
47 "Name of xscheme process that we're currently interacting with.")
48
49(defvar xscheme-buffer-name "*scheme*"
50 "Name of xscheme buffer that we're currently interacting with.")
51
52(defvar xscheme-expressions-ring-max 30
53 "*Maximum length of Scheme expressions ring.")
54
55(defvar xscheme-expressions-ring nil
56 "List of expressions recently transmitted to the Scheme process.")
57
58(defvar xscheme-expressions-ring-yank-pointer nil
59 "The tail of the Scheme expressions ring whose car is the last thing yanked.")
60
61(defvar xscheme-running-p nil
62 "This variable, if nil, indicates that the scheme process is
63waiting for input. Otherwise, it is busy evaluating something.")
64
65(defconst xscheme-control-g-synchronization-p t
66 "If non-nil, insert markers in the scheme input stream to indicate when
67control-g interrupts were signaled. Do not allow more control-g's to be
68signaled until the scheme process acknowledges receipt.")
69
70(defvar xscheme-control-g-disabled-p nil
71 "This variable, if non-nil, indicates that a control-g is being processed
72by the scheme process, so additional control-g's are to be ignored.")
73
74(defvar xscheme-string-receiver nil
75 "Procedure to send the string argument from the scheme process.")
76
77(defconst default-xscheme-runlight
78 '(": " xscheme-runlight-string)
79 "Default global (shared) xscheme-runlight modeline format.")
80
81(defvar xscheme-runlight "")
82(defvar xscheme-runlight-string nil)
83
84(defvar xscheme-process-filter-state 'idle
85 "State of scheme process escape reader state machine:
86idle waiting for an escape sequence
87reading-type received an altmode but nothing else
88reading-string reading prompt string")
89
90(defvar xscheme-allow-output-p t
91 "This variable, if nil, prevents output from the scheme process
92from being inserted into the process-buffer.")
93
94(defvar xscheme-prompt ""
95 "The current scheme prompt string.")
96
97(defvar xscheme-string-accumulator ""
98 "Accumulator for the string being received from the scheme process.")
99
100(defvar xscheme-mode-string nil)
101(setq-default scheme-mode-line-process
102 '("" xscheme-runlight))
103
104(mapcar 'make-variable-buffer-local
105 '(xscheme-expressions-ring
106 xscheme-expressions-ring-yank-pointer
107 xscheme-process-filter-state
108 xscheme-running-p
109 xscheme-control-g-disabled-p
110 xscheme-allow-output-p
111 xscheme-prompt
112 xscheme-string-accumulator
113 xscheme-mode-string
114 scheme-mode-line-process))
36 115
37(defgroup xscheme nil 116(defgroup xscheme nil
38 "Major mode for editing Scheme and interacting with MIT's C-Scheme." 117 "Major mode for editing Scheme and interacting with MIT's C-Scheme."
@@ -355,6 +434,9 @@ with no args, if that value is non-nil.
355 (if (eq (process-sentinel process) 'xscheme-process-sentinel) 434 (if (eq (process-sentinel process) 'xscheme-process-sentinel)
356 (set-process-sentinel process (cdr previous-state)))))))) 435 (set-process-sentinel process (cdr previous-state))))))))
357 436
437(defvar scheme-interaction-mode-commands-alist nil)
438(defvar scheme-interaction-mode-map nil)
439
358(defun scheme-interaction-mode-initialize () 440(defun scheme-interaction-mode-initialize ()
359 (use-local-map scheme-interaction-mode-map) 441 (use-local-map scheme-interaction-mode-map)
360 (setq major-mode 'scheme-interaction-mode) 442 (setq major-mode 'scheme-interaction-mode)
@@ -368,7 +450,7 @@ with no args, if that value is non-nil.
368 (car (cdr (car entries)))) 450 (car (cdr (car entries))))
369 (setq entries (cdr entries))))) 451 (setq entries (cdr entries)))))
370 452
371(defvar scheme-interaction-mode-commands-alist nil) 453;; Initialize the command alist
372(setq scheme-interaction-mode-commands-alist 454(setq scheme-interaction-mode-commands-alist
373 (append scheme-interaction-mode-commands-alist 455 (append scheme-interaction-mode-commands-alist
374 '(("\C-c\C-m" xscheme-send-current-line) 456 '(("\C-c\C-m" xscheme-send-current-line)
@@ -378,7 +460,7 @@ with no args, if that value is non-nil.
378 ("\ep" xscheme-yank-pop) 460 ("\ep" xscheme-yank-pop)
379 ("\en" xscheme-yank-push)))) 461 ("\en" xscheme-yank-push))))
380 462
381(defvar scheme-interaction-mode-map nil) 463;; Initialize the mode map
382(if (not scheme-interaction-mode-map) 464(if (not scheme-interaction-mode-map)
383 (progn 465 (progn
384 (setq scheme-interaction-mode-map (make-keymap)) 466 (setq scheme-interaction-mode-map (make-keymap))
@@ -411,18 +493,20 @@ Commands:
411\\{scheme-debugger-mode-map}" 493\\{scheme-debugger-mode-map}"
412 (error "Invalid entry to scheme-debugger-mode")) 494 (error "Invalid entry to scheme-debugger-mode"))
413 495
496(defvar scheme-debugger-mode-map nil)
497
414(defun scheme-debugger-mode-initialize () 498(defun scheme-debugger-mode-initialize ()
415 (use-local-map scheme-debugger-mode-map) 499 (use-local-map scheme-debugger-mode-map)
416 (setq major-mode 'scheme-debugger-mode) 500 (setq major-mode 'scheme-debugger-mode)
417 (setq mode-name "Scheme Debugger")) 501 (setq mode-name "Scheme Debugger"))
418 502
419(defun scheme-debugger-mode-commands (keymap) 503(defun scheme-debugger-mode-commands (keymap)
420 (let ((char ? )) 504 (let ((char ?\s))
421 (while (< char 127) 505 (while (< char 127)
422 (define-key keymap (char-to-string char) 'scheme-debugger-self-insert) 506 (define-key keymap (char-to-string char) 'scheme-debugger-self-insert)
423 (setq char (1+ char))))) 507 (setq char (1+ char)))))
424 508
425(defvar scheme-debugger-mode-map nil) 509;; Initialize the debugger mode map
426(if (not scheme-debugger-mode-map) 510(if (not scheme-debugger-mode-map)
427 (progn 511 (progn
428 (setq scheme-debugger-mode-map (make-keymap)) 512 (setq scheme-debugger-mode-map (make-keymap))
@@ -675,6 +759,9 @@ Useful for working with debugging Scheme under adb."
675 (interactive) 759 (interactive)
676 (process-send-string xscheme-process-name "(proceed)\n")) 760 (process-send-string xscheme-process-name "(proceed)\n"))
677 761
762(defconst xscheme-control-g-message-string
763 "Sending C-G interrupt to Scheme...")
764
678(defun xscheme-send-control-g-interrupt () 765(defun xscheme-send-control-g-interrupt ()
679 "Cause the Scheme processor to halt and flush input. 766 "Cause the Scheme processor to halt and flush input.
680Control returns to the top level rep loop." 767Control returns to the top level rep loop."
@@ -695,9 +782,6 @@ Control returns to the top level rep loop."
695 (sleep-for 0.1) 782 (sleep-for 0.1)
696 (xscheme-send-char 0))))) 783 (xscheme-send-char 0)))))
697 784
698(defconst xscheme-control-g-message-string
699 "Sending C-G interrupt to Scheme...")
700
701(defun xscheme-send-control-u-interrupt () 785(defun xscheme-send-control-u-interrupt ()
702 "Cause the Scheme process to halt, returning to previous rep loop." 786 "Cause the Scheme process to halt, returning to previous rep loop."
703 (interactive) 787 (interactive)
@@ -722,82 +806,6 @@ Control returns to the top level rep loop."
722 (if (and mark-p xscheme-control-g-synchronization-p) 806 (if (and mark-p xscheme-control-g-synchronization-p)
723 (xscheme-send-char 0))) 807 (xscheme-send-char 0)))
724 808
725;;;; Internal Variables
726
727(defvar xscheme-process-command-line nil
728 "Command used to start the most recent Scheme process.")
729
730(defvar xscheme-process-name "scheme"
731 "Name of xscheme process that we're currently interacting with.")
732
733(defvar xscheme-buffer-name "*scheme*"
734 "Name of xscheme buffer that we're currently interacting with.")
735
736(defvar xscheme-expressions-ring-max 30
737 "*Maximum length of Scheme expressions ring.")
738
739(defvar xscheme-expressions-ring nil
740 "List of expressions recently transmitted to the Scheme process.")
741
742(defvar xscheme-expressions-ring-yank-pointer nil
743 "The tail of the Scheme expressions ring whose car is the last thing yanked.")
744
745(defvar xscheme-last-input-end)
746
747(defvar xscheme-process-filter-state 'idle
748 "State of scheme process escape reader state machine:
749idle waiting for an escape sequence
750reading-type received an altmode but nothing else
751reading-string reading prompt string")
752
753(defvar xscheme-running-p nil
754 "This variable, if nil, indicates that the scheme process is
755waiting for input. Otherwise, it is busy evaluating something.")
756
757(defconst xscheme-control-g-synchronization-p t
758 "If non-nil, insert markers in the scheme input stream to indicate when
759control-g interrupts were signaled. Do not allow more control-g's to be
760signaled until the scheme process acknowledges receipt.")
761
762(defvar xscheme-control-g-disabled-p nil
763 "This variable, if non-nil, indicates that a control-g is being processed
764by the scheme process, so additional control-g's are to be ignored.")
765
766(defvar xscheme-allow-output-p t
767 "This variable, if nil, prevents output from the scheme process
768from being inserted into the process-buffer.")
769
770(defvar xscheme-prompt ""
771 "The current scheme prompt string.")
772
773(defvar xscheme-string-accumulator ""
774 "Accumulator for the string being received from the scheme process.")
775
776(defvar xscheme-string-receiver nil
777 "Procedure to send the string argument from the scheme process.")
778
779(defconst default-xscheme-runlight
780 '(": " xscheme-runlight-string)
781 "Default global (shared) xscheme-runlight modeline format.")
782
783(defvar xscheme-runlight "")
784(defvar xscheme-runlight-string nil)
785(defvar xscheme-mode-string nil)
786(setq-default scheme-mode-line-process
787 '("" xscheme-runlight))
788
789(mapcar 'make-variable-buffer-local
790 '(xscheme-expressions-ring
791 xscheme-expressions-ring-yank-pointer
792 xscheme-process-filter-state
793 xscheme-running-p
794 xscheme-control-g-disabled-p
795 xscheme-allow-output-p
796 xscheme-prompt
797 xscheme-string-accumulator
798 xscheme-mode-string
799 scheme-mode-line-process))
800
801;;;; Basic Process Control 809;;;; Basic Process Control
802 810
803(defun xscheme-start-process (command-line the-process the-buffer) 811(defun xscheme-start-process (command-line the-process the-buffer)
@@ -880,6 +888,61 @@ from being inserted into the process-buffer.")
880 "True iff the current buffer is the Scheme process buffer." 888 "True iff the current buffer is the Scheme process buffer."
881 (eq (xscheme-process-buffer) (current-buffer))) 889 (eq (xscheme-process-buffer) (current-buffer)))
882 890
891;;;; Process Filter Operations
892
893(defvar xscheme-process-filter-alist
894 '((?A xscheme-eval
895 xscheme-process-filter:string-action-noexcursion)
896 (?D xscheme-enter-debugger-mode
897 xscheme-process-filter:string-action)
898 (?E xscheme-eval
899 xscheme-process-filter:string-action)
900 (?P xscheme-set-prompt-variable
901 xscheme-process-filter:string-action)
902 (?R xscheme-enter-interaction-mode
903 xscheme-process-filter:simple-action)
904 (?b xscheme-start-gc
905 xscheme-process-filter:simple-action)
906 (?c xscheme-unsolicited-read-char
907 xscheme-process-filter:simple-action)
908 (?e xscheme-finish-gc
909 xscheme-process-filter:simple-action)
910 (?f xscheme-exit-input-wait
911 xscheme-process-filter:simple-action)
912 (?g xscheme-enable-control-g
913 xscheme-process-filter:simple-action)
914 (?i xscheme-prompt-for-expression
915 xscheme-process-filter:string-action)
916 (?m xscheme-message
917 xscheme-process-filter:string-action)
918 (?n xscheme-prompt-for-confirmation
919 xscheme-process-filter:string-action)
920 (?o xscheme-output-goto
921 xscheme-process-filter:simple-action)
922 (?p xscheme-set-prompt
923 xscheme-process-filter:string-action)
924 (?s xscheme-enter-input-wait
925 xscheme-process-filter:simple-action)
926 (?v xscheme-write-value
927 xscheme-process-filter:string-action)
928 (?w xscheme-cd
929 xscheme-process-filter:string-action)
930 (?z xscheme-display-process-buffer
931 xscheme-process-filter:simple-action))
932 "Table used to decide how to handle process filter commands.
933Value is a list of entries, each entry is a list of three items.
934
935The first item is the character that the process filter dispatches on.
936The second item is the action to be taken, a function.
937The third item is the handler for the entry, a function.
938
939When the process filter sees a command whose character matches a
940particular entry, it calls the handler with two arguments: the action
941and the string containing the rest of the process filter's input
942stream. It is the responsibility of the handler to invoke the action
943with the appropriate arguments, and to reenter the process filter with
944the remaining input.")
945
883;;;; Process Filter 946;;;; Process Filter
884 947
885(defun xscheme-process-sentinel (proc reason) 948(defun xscheme-process-sentinel (proc reason)
@@ -1037,61 +1100,6 @@ from being inserted into the process-buffer.")
1037 (rplaca (nthcdr 3 xscheme-runlight) runlight) 1100 (rplaca (nthcdr 3 xscheme-runlight) runlight)
1038 (force-mode-line-update t)) 1101 (force-mode-line-update t))
1039 1102
1040;;;; Process Filter Operations
1041
1042(defvar xscheme-process-filter-alist
1043 '((?A xscheme-eval
1044 xscheme-process-filter:string-action-noexcursion)
1045 (?D xscheme-enter-debugger-mode
1046 xscheme-process-filter:string-action)
1047 (?E xscheme-eval
1048 xscheme-process-filter:string-action)
1049 (?P xscheme-set-prompt-variable
1050 xscheme-process-filter:string-action)
1051 (?R xscheme-enter-interaction-mode
1052 xscheme-process-filter:simple-action)
1053 (?b xscheme-start-gc
1054 xscheme-process-filter:simple-action)
1055 (?c xscheme-unsolicited-read-char
1056 xscheme-process-filter:simple-action)
1057 (?e xscheme-finish-gc
1058 xscheme-process-filter:simple-action)
1059 (?f xscheme-exit-input-wait
1060 xscheme-process-filter:simple-action)
1061 (?g xscheme-enable-control-g
1062 xscheme-process-filter:simple-action)
1063 (?i xscheme-prompt-for-expression
1064 xscheme-process-filter:string-action)
1065 (?m xscheme-message
1066 xscheme-process-filter:string-action)
1067 (?n xscheme-prompt-for-confirmation
1068 xscheme-process-filter:string-action)
1069 (?o xscheme-output-goto
1070 xscheme-process-filter:simple-action)
1071 (?p xscheme-set-prompt
1072 xscheme-process-filter:string-action)
1073 (?s xscheme-enter-input-wait
1074 xscheme-process-filter:simple-action)
1075 (?v xscheme-write-value
1076 xscheme-process-filter:string-action)
1077 (?w xscheme-cd
1078 xscheme-process-filter:string-action)
1079 (?z xscheme-display-process-buffer
1080 xscheme-process-filter:simple-action))
1081 "Table used to decide how to handle process filter commands.
1082Value is a list of entries, each entry is a list of three items.
1083
1084The first item is the character that the process filter dispatches on.
1085The second item is the action to be taken, a function.
1086The third item is the handler for the entry, a function.
1087
1088When the process filter sees a command whose character matches a
1089particular entry, it calls the handler with two arguments: the action
1090and the string containing the rest of the process filter's input
1091stream. It is the responsibility of the handler to invoke the action
1092with the appropriate arguments, and to reenter the process filter with
1093the remaining input.")
1094
1095(defun xscheme-process-filter:simple-action (action) 1103(defun xscheme-process-filter:simple-action (action)
1096 (setq xscheme-process-filter-state 'idle) 1104 (setq xscheme-process-filter-state 'idle)
1097 (funcall action)) 1105 (funcall action))
@@ -1196,10 +1204,6 @@ the remaining input.")
1196(defun xscheme-prompt-for-confirmation (prompt-string) 1204(defun xscheme-prompt-for-confirmation (prompt-string)
1197 (xscheme-send-char (if (y-or-n-p prompt-string) ?y ?n))) 1205 (xscheme-send-char (if (y-or-n-p prompt-string) ?y ?n)))
1198 1206
1199(defun xscheme-prompt-for-expression (prompt-string)
1200 (xscheme-send-string-2
1201 (read-from-minibuffer prompt-string nil xscheme-prompt-for-expression-map)))
1202
1203(defvar xscheme-prompt-for-expression-map nil) 1207(defvar xscheme-prompt-for-expression-map nil)
1204(if (not xscheme-prompt-for-expression-map) 1208(if (not xscheme-prompt-for-expression-map)
1205 (progn 1209 (progn
@@ -1209,6 +1213,10 @@ the remaining input.")
1209 'xscheme-prompt-for-expression-exit 1213 'xscheme-prompt-for-expression-exit
1210 xscheme-prompt-for-expression-map))) 1214 xscheme-prompt-for-expression-map)))
1211 1215
1216(defun xscheme-prompt-for-expression (prompt-string)
1217 (xscheme-send-string-2
1218 (read-from-minibuffer prompt-string nil xscheme-prompt-for-expression-map)))
1219
1212(defun xscheme-prompt-for-expression-exit () 1220(defun xscheme-prompt-for-expression-exit ()
1213 (interactive) 1221 (interactive)
1214 (if (eq (xscheme-region-expression-p (point-min) (point-max)) 'one) 1222 (if (eq (xscheme-region-expression-p (point-min) (point-max)) 'one)