annotate lisp/ilisp/ilisp-hi.el @ 49:b46643e427ac

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