annotate lisp/ilisp/ilisp-hi.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-hi.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 ;;; ILISP high level interface functions Lisp <-> Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;%Eval/compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defun lisp-send-region (start end switch message status format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 &optional handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 "Given START, END, SWITCH, MESSAGE, STATUS, FORMAT and optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 HANDLER send the region between START and END to the lisp buffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 execute the command defined by FORMAT on the region, its package and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 filename. If called with a positive prefix, the results will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 inserted at the end of the region. If SWITCH is T, the command will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 be sent and the buffer switched to the inferior LISP buffer. if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 SWITCH is 'call, a call will be inserted. If SWITCH is 'result the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 result will be returned without being displayed. Otherwise the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 results will be displayed in a popup window if lisp-wait-p is T and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 the current-prefix-arg is not '- or if lisp-wait-p is nil and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 current-prefix-arg is '-. If not displayed in a pop-up window then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 comint-handler will display the results in a pop-up window if they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 more than one line long, or they are from an error. STATUS will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 the process status when the command is actually executing. MESSAGE is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 a message to let the user know what is going on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (if (= start end) (error "Region is empty"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (let ((sexp (lisp-count-pairs start end ?\( ?\)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (string (buffer-substring start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (setq string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (format (ilisp-value format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (lisp-slashify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (if (= sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (format (ilisp-value 'ilisp-block-command) string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (lisp-buffer-package) (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (let ((result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 string message status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (cond ((memq switch '(t call)) switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ((or (not (eq lisp-wait-p (lisp-minus-prefix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (eq switch 'result)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (t 'dispatch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (insert result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; Display the output in the usual way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (lisp-display-output result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;;%%Eval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defun eval-region-lisp (start end &optional switch message status handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 "Evaluate the current region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq message (or message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (concat "Evaluate " (lisp-region-name start end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (let ((defvar (ilisp-value 'ilisp-defvar-regexp t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (if (and defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (and (let ((case-fold-search t)) (looking-at defvar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (progn (forward-sexp) (skip-chars-forward " \t\n" end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (= (point) end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (lisp-send-region start end switch message (or status 'defvar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 'ilisp-defvar-command handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (lisp-send-region start end switch message (or status 'eval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 'ilisp-eval-command handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defun eval-next-sexp-lisp (&optional switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "Evaluate the next sexp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (let (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (setq end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (eval-region-lisp start end switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (format "Evaluate %s" (buffer-substring start end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defun eval-defun-lisp (&optional switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "Evaluate the current form."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (let* ((form (lisp-defun-region-and-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (eval-region-lisp (car form) (car (cdr form)) (or switch 'result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (format "Evaluating %s" (car (cdr (cdr form)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; Display the returned value. -fmw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (lisp-display-output result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;;%%%And go
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defun eval-region-and-go-lisp (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 "Evaluate the current region and switch to the current ILISP buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (eval-region-lisp start end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defun eval-next-sexp-and-go-lisp (&optional switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 "Evaluate the next sexp and switch to the current ILISP buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (eval-next-sexp-lisp t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defun eval-defun-and-go-lisp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 "Evaluate the current defun and switch to the current ILISP buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 With prefix, insert a call as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (eval-defun-lisp (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq current-prefix-arg nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 'call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;;%%Compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (defun compile-region-lisp (start end &optional switch message status handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 "Compile the current region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (lisp-send-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (or switch 'result) ; Default to return the result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (or message (concat "Compile " (lisp-region-name start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (or status 'compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 'ilisp-compile-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defun compile-defun-lisp (&optional switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 "Compile the current defun or the last command in the input-ring of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 an ILISP buffer if no current defun."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (let* ((form (lisp-defun-region-and-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (start (car form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (end (car (cdr form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (if (and (= start end) (memq major-mode ilisp-modes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (let ((form (ring-ref (ilisp-get-input-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (ilisp-input-ring-index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (set-buffer "*ilisp-send*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (delete-region (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (insert form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (compile-defun-lisp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; Display the value returned by the compilation. -fmw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (let* ((thing (car (cdr (cdr form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (result (compile-region-lisp start end (or switch 'result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (format "Compiling %s" thing))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (lisp-display-output result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;;%%%And-go
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (defun compile-region-and-go-lisp (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "Compile the current region and switch to the current ILISP buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (compile-region-lisp start end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defun compile-defun-and-go-lisp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "Compile the current defun and switch to the current ILISP buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (compile-defun-lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (setq current-prefix-arg nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 'call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defun compile-file-lisp (file-name &optional extension)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "Compile a Lisp file in the current inferior LISP and go there."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (interactive (comint-get-source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 "Compile Lisp file: " lisp-prev-l/c-dir/file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 lisp-source-modes nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (comint-check-source file-name) ; Check to see if buffer needs saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (file-name-nondirectory file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (ilisp-init t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; Ivan's hack for ange-ftp pathnames...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (let ((file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (if (string-match "/.*?@.*:" file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (substring file-name (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (format (ilisp-value 'ilisp-compile-file-command) file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (or extension (ilisp-value 'ilisp-binary-extension)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (concat "Compile " file-name) 'compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (defun ilisp-compile-inits ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 "Compile the initialization files for the current inferior LISP dialect."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (ilisp-init t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (let ((files (ilisp-value 'ilisp-load-inits t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (while files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (compile-file-lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (expand-file-name (cdr (car files)) ilisp-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (ilisp-value 'ilisp-init-binary-extension t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (setq files (cdr files)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defun close-and-send-lisp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "Close and indent the current sexp then send it to the inferior
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 LISP."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (reindent-lisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (if (memq major-mode ilisp-modes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (return-ilisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (eval-defun-lisp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;;;%Special commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defun describe-lisp (sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 "Describe the current sexp using ilisp-describe-command. With a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 negative prefix, prompt for the expression. If in an ILISP buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 and there is no current sexp, describe ilisp-last-command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (if (lisp-minus-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (ilisp-read "Describe: " (lisp-previous-sexp t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (if (memq major-mode ilisp-modes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (if (= (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (process-mark (get-buffer-process (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (or (ilisp-value 'ilisp-last-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (error "No sexp to describe."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (lisp-previous-sexp t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (lisp-previous-sexp t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (let ((result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (format (ilisp-value 'ilisp-describe-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (lisp-slashify sexp) (lisp-buffer-package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (concat "Describe " sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 'describe)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (lisp-display-output result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defun inspect-lisp (sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "Inspect the current sexp using ilisp-inspect-command. With a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 prefix, prompt for the expression. If in an ILISP buffer, and there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 is no current sexp, inspect ilisp-last-command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (ilisp-read "Inspect: " (lisp-previous-sexp t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (if (memq major-mode ilisp-modes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (if (= (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (process-mark (get-buffer-process (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (or (ilisp-value 'ilisp-last-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (error "No sexp to inspect."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (lisp-previous-sexp t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (lisp-previous-sexp t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (format (ilisp-value 'ilisp-inspect-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (lisp-slashify sexp) (lisp-buffer-package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (concat "Inspect " sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 'inspect t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defun arglist-lisp (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 "Return the arglist of the currently looked at function. With a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 numeric prefix, the arglist will be inserted. With a negative one,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 the symbol will be prompted for."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (let* ((function (lisp-function-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (list (if (lisp-minus-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (ilisp-read-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (format "Arglist [%s]: " (lisp-buffer-symbol function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 function t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (if (null symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (error "No symbol")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (let* ((arglist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (format (ilisp-value 'ilisp-arglist-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (lisp-symbol-name symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (lisp-symbol-package symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 'args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (position (string-match "(" arglist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;; Insert just the stuff after the open paren,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; but display everything the inferior lisp prints.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (cond ((and (not (ilisp-value 'comint-errorp t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 current-prefix-arg position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (let ((temp (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (insert (substring arglist (1+ position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (goto-char temp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (lisp-display-output arglist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (defun documentation-lisp (symbol type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "Return the documentation of the previous symbol using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ilisp-documentation-command. If the symbol is at the start of a list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 it is assumed to be a function, otherwise variable documentation is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 searched for. With a minus prefix, prompt for the symbol and type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 With a numeric prefix always return the current function call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 documentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (if (lisp-minus-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (let* ((symbol-info (lisp-previous-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (symbol (car symbol-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (doc (ilisp-read-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (format "Documentation [%s]: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (lisp-buffer-symbol symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (default (if (car (cdr symbol-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 'function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 'variable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (types (ilisp-value 'ilisp-documentation-types t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (if types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (ilisp-completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (if default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (format "Type [%s]: " default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 "Type: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (list doc (if (stringp type) (read type) type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (list (lisp-function-name) 'function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (let* ((symbol-info (lisp-previous-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (list (car symbol-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (if (car (cdr symbol-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 'function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 'variable))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (lisp-display-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (format (ilisp-value 'ilisp-documentation-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (lisp-symbol-name symbol) (lisp-symbol-package symbol) type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (format "Documentation %s %s" type (lisp-buffer-symbol symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 'doc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ;;;%%Macroexpand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (defun lisp-macroexpand-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 "Return the next form for macroexpanding."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (let* ((begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (end (progn (forward-sexp) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (form (buffer-substring begin end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (if (lisp-minus-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (ilisp-read "Macroexpand: " form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 form)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defun macroexpand-lisp (form &optional top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "Macroexpand the next sexp until it is no longer a macro. With a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 prefix, insert into buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (interactive (lisp-macroexpand-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (if (string-match "(\\([^ \t\n)]*\\)" form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (let ((message (concat "Macroexpand"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (if top "-1 " " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (substring form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (ilisp-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (if top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 'ilisp-macroexpand-1-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 'ilisp-macroexpand-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (lisp-slashify form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (lisp-buffer-package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 message 'expand))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (save-excursion (forward-sexp) (insert ?\n) (insert result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (lisp-display-output result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (error "Not a form: %s" form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (defun macroexpand-1-lisp (form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 "Macroexpand the next sexp once. With a prefix, insert into buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (interactive (lisp-macroexpand-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (macroexpand-lisp form t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;;;%%Trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (defun trace-defun-lisp-break (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 "Trace FUNCTION without arg, untrace with. Prompt for function with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 negative prefix. Default function is the current defun.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 Trace with :break set."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (let ((function (lisp-defun-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (if (lisp-minus-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (list (ilisp-read-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (format (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 "Untrace [%s]: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "Trace [%s]: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (lisp-buffer-symbol function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (list function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (trace-defun-lisp-internal function (not current-prefix-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (defun trace-defun-lisp (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 "Trace FUNCTION without arg, untrace with. Prompt for function with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 negative prefix. Default function is the current defun."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (let ((function (lisp-defun-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (if (lisp-minus-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (list (ilisp-read-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (format (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 "Untrace [%s]: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 "Trace [%s]: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (lisp-buffer-symbol function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (list function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (trace-defun-lisp-internal function nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (defun trace-defun-lisp-internal (function breakp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (cond (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (let ((result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (format (ilisp-value 'ilisp-untrace-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (lisp-symbol-name function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (lisp-symbol-package function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (format (ilisp-value 'ilisp-trace-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (lisp-symbol-name function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (lisp-symbol-package function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 breakp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (format "%srace %s" (if current-prefix-arg "Unt" "T")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (lisp-buffer-symbol function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (if current-prefix-arg 'untrace 'trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;; Change to always wait, so we can see the result. -fmw, 10/13/93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;; (if lisp-wait-p nil 'dispatch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; Display the value returned -fmw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (lisp-display-output result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (error "No function to %strace" (if current-prefix-arg "un" "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ;;;%%Default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (defun default-directory-lisp (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 "Set the inferior LISP default directory to the default directory of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 optional BUFFER. If you are in an inferior LISP buffer, set the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 default directory to the current directory of the LISP."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (if (and (not buffer) (memq major-mode ilisp-modes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (let ((dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (ilisp-value 'ilisp-directory-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (format "Getting LISP directory")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 'dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (if (ilisp-value 'comint-errorp t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (lisp-display-output dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (error "Error getting directory"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (setq default-directory (read dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 lisp-prev-l/c-dir/file (cons default-directory nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (message "Default directory is %s" default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (let ((directory (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (set-buffer (or buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (format (ilisp-value 'ilisp-set-directory-command) directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (format "Set %s's directory to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (buffer-name (ilisp-buffer)) directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 'dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; (if lisp-wait-p nil 'dispatch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; The above line might cause problems with Lispworks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; I just set the default to 'nil'. It shouldn't harm.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;; Marco Antoniotti: Jan 2 1995.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (defun load-file-lisp (file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 "Load a lisp file into the current inferior LISP and go there."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (interactive (comint-get-source "Load Lisp file: " lisp-prev-l/c-dir/file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 lisp-source-modes nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (comint-check-source file-name) ; Check to see if buffer needs saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (file-name-nondirectory file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (ilisp-init t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (let* ((extension (ilisp-value 'ilisp-binary-extension t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (binary (lisp-file-extension file-name extension)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (set-buffer (ilisp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (if (not (eq comint-send-queue comint-end-queue))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (if (y-or-n-p "Abort commands before loading? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (abort-commands-lisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (message "Waiting for commands to finish")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (while (not (eq comint-send-queue comint-end-queue))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (accept-process-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (sit-for 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (if (and (car (comint-send-variables (car comint-send-queue)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (y-or-n-p "Interrupt top level? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (let ((result (comint-send-results (car comint-send-queue))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (interrupt-subjob-ilisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (while (not (cdr result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (accept-process-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (sit-for 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (if (file-newer-than-file-p file-name binary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (if (and (not ilisp-load-no-compile-query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 extension (y-or-n-p "Compile first? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;; Load binary if just compiled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (compile-file-lisp file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (setq file-name binary)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ;; Load binary if it is current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (if (file-readable-p binary) (setq file-name binary)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (switch-to-lisp t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; Ivan's hack for ange-ftp pathnames...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (let ((file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (if (string-match "/.*?@.*:" file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (substring file-name (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (comint-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (ilisp-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (format (ilisp-value 'ilisp-load-command) file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (message "Loading %s" file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 ;;;%Source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ;;;%File operations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (defun lisp-find-file (file &optional pop no-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 "Find FILE, optionally POPping.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 If optional NO-NAME is nil, and there is a buffer with a name that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 the same as the final pathname component, select that instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 reading the file associated with the full path name. If the expanded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 name of FILE and buffer match, select that buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (let* ((buffers (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (position 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (expand-symlinks t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (expanded (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (if (not no-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (progn (while (string-match "/" file position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (setq position (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (setq filename (substring file position))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (while buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (set-buffer (car buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (let* ((name (and (not no-name) (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (buffer-file (buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (buffer-expanded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (if (string-equal buffer-file (car lisp-buffer-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 lisp-buffer-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (setq lisp-buffer-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (cons buffer-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (expand-file-name buffer-file)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (if (or (and name (string-equal filename name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (string-equal expanded buffer-expanded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (setq file buffer-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 buffers nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (setq buffers (cdr buffers)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (if pop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (lisp-pop-to-buffer (find-file-noselect file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (find-file file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defun find-file-lisp (file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 "Find a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 If point is on a string that points to an existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 file, that will be the default. If the buffer is one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 lisp-source-modes, the buffer file will be the default. Otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 the last file used in a lisp-source-mode will be used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (comint-get-source "Find file: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 lisp-prev-l/c-dir/file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 lisp-source-modes nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (file-name-nondirectory file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (lisp-find-file file-name nil t))