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