comparison lisp/ilisp/ilisp-xfr.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 ;;; -*- Mode: Emacs-Lisp -*-
2
3 ;;; ilisp-xfr.el --
4
5 ;;; This file is part of ILISP.
6 ;;; Version: 5.7
7 ;;;
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
9 ;;; 1993, 1994 Ivan Vasquez
10 ;;; 1994, 1995 Marco Antoniotti and Rick Busdiecker
11 ;;;
12 ;;; Other authors' names for which this Copyright notice also holds
13 ;;; may appear later in this file.
14 ;;;
15 ;;; Send mail to 'ilisp-request@lehman.com' to be included in the
16 ;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP
17 ;;; mailing list were bugs and improvements are discussed.
18 ;;;
19 ;;; ILISP is freely redistributable under the terms found in the file
20 ;;; COPYING.
21
22
23
24 ;;;
25 ;;; ILISP transfer commands Lisp <-> Emacs
26 ;;;
27
28
29 ;; It's too bad that this function copies so much code from comint-send-input.
30 ;; It ought to be a wrapper around it, instead.
31
32 (defun return-ilisp ()
33 "Grab the current expression with comint-get-old-input. If we have
34 a complete sexp, send it. Otherwise, indent appropriately."
35 (interactive)
36 (let ((proc (get-buffer-process (current-buffer))))
37 (if (not proc) (error "Current buffer has no process")
38 (let* ((pmark (process-mark proc))
39 (input (ilisp-get-old-input)))
40 (if input
41 (progn
42 (if (>= (point) pmark)
43 (goto-char (point-max))
44 (goto-char pmark)
45 (insert input))
46 (if (not ilisp-no-newline) (insert ?\n))
47 (if (and (funcall comint-input-filter input)
48 (or (ring-empty-p (ilisp-get-input-ring))
49 (not (string= (ring-ref (ilisp-get-input-ring) 0)
50 input))))
51 (ilisp-ring-insert (ilisp-get-input-ring) input))
52 (funcall comint-input-sentinel input)
53 ;; Ugh, comint changing under my feet....
54 ;; Note: This used to be
55 ;; (eq ilisp-emacs-version-id 'gnu-19)
56 ;; 25/11/94 Marco Antoniotti
57 (if (eq +ilisp-emacs-version-id+ 'fsf-19)
58 (setq comint-input-ring-index nil))
59 ;; Nuke symbol table
60 (setq ilisp-original nil)
61 (funcall comint-input-sender proc input)
62 (set-marker (process-mark proc) (point))
63 (set-marker comint-last-input-end (point))
64 (goto-char (point-max)))
65 (if (= pmark (point-max))
66 (let ((comint-send-newline t))
67 (if (not ilisp-no-newline) (insert ?\n))
68 (set-marker (process-mark proc) (point))
69 (funcall comint-input-sender proc ""))
70 (insert ?\n)
71 (save-restriction
72 (narrow-to-region pmark (point-max))
73 (funcall indent-line-function))))))))
74
75 ;;;%%Keyboard mode
76 (defun raw-keys-ilisp ()
77 "Start using raw keyboard mode to send each character typed to the
78 inferior LISP until a key bound to interactive-keys-ilisp is
79 encountered. See also io-bridge-ilisp."
80 (interactive)
81 (if (not ilisp-raw-map)
82 (let ((map (make-keymap)))
83 (fillarray map 'ilisp-send-char)
84 (if (string-match "Lucid" emacs-version)
85 ;; not necessary, but friendlier.
86 (progn
87 (setq ilisp-completion-map (make-keymap))
88 ;; (set-keymap-name ilisp-completion-map 'ilisp-completion-map)
89 ;; (set-keymap-parent ilisp-completion-map lisp-mode-map)
90 ))
91 (define-key map "\C-g" 'interactive-keys-ilisp)
92 (setq ilisp-raw-map map)))
93 (use-local-map ilisp-raw-map)
94 (message ilisp-raw-message))
95
96 ;;;
97 (defun interactive-keys-ilisp ()
98 "Go back to interactive keyboard interactions in the inferior LISP."
99 (interactive)
100 (use-local-map ilisp-use-map)
101 (message "Interactive keyboard mode"))
102
103 ;;;
104 (defun ilisp-send-char ()
105 "Send the last typed character to the current inferior LISP echoing
106 if ilisp-raw-echo is T."
107 (interactive)
108 (if (ilisp-value 'ilisp-raw-echo t)
109 (progn
110 (goto-char (point-max))
111 (insert last-input-char)
112 (set-marker (process-mark (ilisp-process)) (point))
113 (set-marker comint-last-input-end (point))))
114 (process-send-string (ilisp-process)
115 (make-string 1 last-input-char))
116 (message ilisp-raw-message))
117
118 ;;;
119 (defun ilisp-raw-handler (process output)
120 "Turn on raw keyboard mode."
121 (raw-keys-ilisp))
122 (defun ilisp-interactive-handler (process output)
123 "Turn on interactive keyboard mode."
124 (interactive-keys-ilisp))
125
126 ;;;
127 (defun io-bridge-ilisp ()
128 "Set up so that the inferior LISP can turn on EMACS raw mode by
129 sending ^[1^] and turn it off by sending ^[0^]."
130 (interactive)
131 (require 'bridge)
132 (install-bridge)
133 (setq bridge-handlers (cons '("1" . ilisp-raw-handler)
134 (cons '("0" . ilisp-interactive-handler)
135 bridge-handlers))))
136
137 ;;;%%Debugger interface
138 (defun delete-char-or-pop-ilisp (arg &optional killflag)
139 "Delete ARG characters, or pop break level if at end of buffer.
140 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
141 Interactively, ARG is the prefix arg, and KILLFLAG is set if
142 ARG was explicitly specified."
143 (interactive "p")
144 (if (eobp)
145 (progn
146 (message "Pop LISP one level")
147 (comint-simple-send (ilisp-process) (ilisp-value 'comint-fix-error)))
148 (call-interactively 'delete-char (list arg killflag))))