annotate lisp/ilisp/ilisp-xfr.el @ 164:4e0740e5aab2

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