annotate lisp/ilisp/ilisp-snd.el @ 9:6f2bbbbbe05a

Added tag r19-15b5 for changeset 4b173ad71786
author cvs
date Mon, 13 Aug 2007 08:47:36 +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-snd.el --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; This file is part of ILISP.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
6 ;;; Version: 5.8
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; 1993, 1994 Ivan Vasquez
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
10 ;;; 1994, 1995, 1996 Marco Antoniotti and Rick Busdiecker
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
11 ;;; 1996 Marco Antoniotti and Rick Campbell
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; Other authors' names for which this Copyright notice also holds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; may appear later in this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
16 ;;; Send mail to 'ilisp-request@naggum.no' to be included in the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
17 ;;; ILISP mailing list. 'ilisp@naggum.no' is the general ILISP
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; mailing list were bugs and improvements are discussed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; ILISP is freely redistributable under the terms found in the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; COPYING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; ILISP send and support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;;%% Package / Symbol support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defun lisp-buffer-package ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 "Return the package for this buffer. The package name is a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 If there is none, return NIL. This caches the package unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ilisp-dont-cache-package is non-nil, so calling this more than once
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 is cheap."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (cond ((and (not (eq buffer-package 'not-yet-computed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (null lisp-dont-cache-package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 buffer-package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (ilisp-completion-package ilisp-completion-package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (lisp-dont-cache-package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; Refind the package each time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (let ((package (lisp-buffer-package-internal nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (setq buffer-package 'not-yet-computed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (if package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (setq mode-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (or buffer-mode-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (setq buffer-mode-name mode-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ":" package)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ((or lisp-buffer-package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (memq major-mode ilisp-modes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (not (memq major-mode lisp-source-modes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (make-local-variable 'buffer-package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (make-local-variable 'buffer-mode-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (let ((package (lisp-buffer-package-internal t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (setq buffer-package package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; Display package in mode line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (if package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (setq mode-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (concat (or buffer-mode-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (setq buffer-mode-name mode-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ":" buffer-package)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 buffer-package))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defun lisp-buffer-package-internal (search-from-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "Returns the package of the buffer. If SEARCH-FROM-START is T then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 will search from the beginning of the buffer, otherwise will search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 backwards from current point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (setq mode-line-process 'ilisp-status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (let* ((lisp-buffer-package t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (regexp (ilisp-value 'ilisp-package-regexp t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (if (or (and search-from-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (re-search-forward regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (re-search-backward regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (str (format (ilisp-value 'ilisp-package-command) spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (if spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 str
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "Finding buffer package"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 'pkg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (if (ilisp-value 'comint-errorp t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (lisp-display-output package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (error "No package"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (if (and package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; There was a bug here, used to have the second *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; outside of the parens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (string-match "[ \n\t:\"]*\\([^ \n\t\"]*\\)" package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (setq package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (substring package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (match-beginning 1) (match-end 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defun package-lisp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 "Show current inferior LISP package."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (message "Inferior LISP package is %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (ilisp-send (ilisp-value 'ilisp-package-name-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 "Finding inferior LISP package" 'pkg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defun set-package-lisp (package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "Set inferior LISP to package of buffer or a named package with prefix."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (let ((default (lisp-buffer-package)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (if (or current-prefix-arg (null default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (let ((name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (format "Package [%s]: " (lisp-buffer-package)) "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (list (if (equal name "") default name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (list default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (ilisp-send (format (ilisp-value 'ilisp-in-package-command) package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (format "Set %s's package to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (buffer-name (ilisp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 'pkg 'dispatch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (error "No package")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defun set-buffer-package-lisp (package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "Reset the current package of the current buffer. With prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 specify manually."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (interactive (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (list (read-from-minibuffer "Package: " ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (list nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (if package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (setq buffer-package package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 mode-name (concat (or buffer-mode-name mode-name) ":" package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (setq buffer-package 'not-yet-computed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (lisp-buffer-package)))
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 ;;;%Interface functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;;%%Symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defun lisp-string-to-symbol (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "Convert STRING to a symbol, (package delimiter symbol) where the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 package is either package:symbol or from the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (let* ((start (string-match ":+" string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (end (if start (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (if start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (lisp-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (if (= start 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (substring string 0 start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (substring string start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (substring string end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (let ((package (lisp-buffer-package)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (lisp-symbol package (if package "::") string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (defun lisp-symbol-to-string (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 "Convert SYMBOL to a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (apply 'concat symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (defun lisp-buffer-symbol (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 "Return SYMBOL as a string qualified for the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (let ((symbol-name (lisp-symbol-name symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (pkg (lisp-symbol-package symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (delimiter (lisp-symbol-delimiter symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (cond ((string= pkg (lisp-buffer-package)) symbol-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ((string= pkg "") (concat ":" symbol-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (pkg (concat pkg delimiter symbol-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (t symbol-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defun lisp-previous-symbol (&optional stay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "Return the immediately preceding symbol as ((package delimiter symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 function-p start end). If STAY is T, the end of the symbol will be point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (if (or (and (memq major-mode ilisp-modes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (= (point) (process-mark (get-buffer-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (skip-chars-backward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (or (bobp) (memq (char-after (1- (point))) '(?\) ?\")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (let* ((delimiters (ilisp-value 'ilisp-symbol-delimiters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (end (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (if (not stay) (skip-chars-forward delimiters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (start (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (skip-chars-backward delimiters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (prefix (if (not (bobp)) (1- start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (function-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (and prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (or (eq (char-after prefix) ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (and (eq (char-after prefix) ?')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (not (bobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (eq (char-after (1- prefix)) ?#)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (not (looking-at "[^: \t\n]*:*\\*[^ \t\n]")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (cons (lisp-string-to-symbol (buffer-substring start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (list function-p start end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defun lisp-function-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 "Return the previous function symbol. This is either after a #' or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 at the start of the current sexp. If there is no current sexp, return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (let ((symbol (lisp-previous-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (if (car (cdr symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (car symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (if (and (memq major-mode ilisp-modes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (= (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (process-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (get-buffer-process (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (backward-up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (down-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (lisp-string-to-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (progn (forward-sexp 1) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (error nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (defun lisp-defun-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 "Return the name of the current defun."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (lisp-defun-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (lisp-string-to-symbol (lisp-def-name t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;;;%% ILISP initializations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (defun ilisp-initialized ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 "Return T if the current inferior LISP has been initialized."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (memq (buffer-name (ilisp-buffer)) ilisp-initialized))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (defun ilisp-load-init (dialect file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 "Add FILE to the files to be loaded into the inferior LISP when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 dialect is initialized. If FILE is NIL, the entry will be removed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (let ((old (assoc dialect ilisp-load-inits)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (if old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (rplacd old file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (setq ilisp-load-inits (nconc ilisp-load-inits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (list (cons dialect file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (if old (setq ilisp-load-inits (delq old ilisp-load-inits))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (defun ilisp-binary (init var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "Initialize VAR to the result of INIT if VAR is NIL."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (if (not (ilisp-value var t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (let ((binary (ilisp-value init t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (if binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (comint-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (ilisp-process) binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 t nil 'binary nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (` (lambda (error wait message output last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (if (or error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (not (string-match "\"[^\"]*\"" output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (lisp-display-output output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (abort-commands-lisp "No binary"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (setq (, var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (substring output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (1+ (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (1- (match-end 0))))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (defun ilisp-done-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "Make sure that initialization is done and if not dispatch another check."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (if ilisp-load-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (comint-send-code (get-buffer-process (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 'ilisp-done-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (if ilisp-initializing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (message "Finished initializing %s" (car ilisp-dialect))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq ilisp-initializing nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ilisp-initialized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (cons (buffer-name (current-buffer)) ilisp-initialized))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defun ilisp-init-internal (&optional sync)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "Send all of the stuff necessary to initialize."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (if sync
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (comint-sync
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (ilisp-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 "\"Start sync\"" "[ \t\n]*\"Start sync\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "\"End sync\"" "\"End sync\""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (ilisp-binary 'ilisp-binary-command 'ilisp-binary-extension)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (ilisp-binary 'ilisp-init-binary-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 'ilisp-init-binary-extension)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; This gets executed in the process buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (comint-send-code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (ilisp-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (let ((files ilisp-load-inits)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (if (not ilisp-init-binary-extension)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (setq ilisp-init-binary-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ilisp-binary-extension))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (while files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (ilisp-load-or-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (cdr (car files)) ilisp-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (setq files (cdr files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (comint-send-code (ilisp-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 'ilisp-done-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (setq done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (if (not done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (setq ilisp-initializing nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (abort-commands-lisp))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (set-ilisp-value 'ilisp-initializing t)) ; progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (if (not (ilisp-value 'ilisp-initializing t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (abort-commands-lisp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (defun ilisp-init (&optional waitp forcep sync)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 "Initialize the current inferior LISP if necessary by loading the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 files in ilisp-load-inits. Optional WAITP waits for initialization to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 finish. When called interactively, force reinitialization. With a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 prefix, get the binary extensions again."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (list (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (set-ilisp-value 'ilisp-init-binary-extension nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (set-ilisp-value 'ilisp-binary-extension nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (if (or forcep (not (ilisp-initialized)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (message "Started initializing ILISP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (if (not ilisp-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (setq ilisp-directory (or (ilisp-directory "ilisp.elc" load-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (ilisp-directory "ilisp.el" load-path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (if (not (ilisp-value 'ilisp-initializing t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (ilisp-init-internal sync))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (if waitp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (while (ilisp-value 'ilisp-initializing t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (accept-process-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (sit-for 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defun ilisp-init-and-sync ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 "Synchronize with the inferior LISP and then initialize."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (ilisp-init nil nil t))
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defun call-defun-lisp (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 "Put a call of the current defun in the inferior LISP and go there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 If it is a \(def* name form, look up reasonable forms of name in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 input history unless called with prefix ARG. If not found, use \(name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 or *name* as the call. If is not a def* form, put the whole form in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 the buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (if (save-excursion (lisp-defun-begin) (looking-at "(def"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (let* ((symbol (lisp-defun-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (name (lisp-symbol-name symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (package (if (lisp-symbol-package symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (concat "\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (lisp-symbol-package symbol) ":+\\)?")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (variablep (string-match "^\\*" name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (setfp (string-match "(setf \\([^\)]+\\)" name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (switch-to-lisp t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (cond (setfp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (setq name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (substring name (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (lisp-match-ring (if (not arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (concat "(setf[ \t\n]*("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 package name "[ \t\n]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (concat "(setf (" name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (variablep (lisp-match-ring (if (not arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (concat package name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (let ((fun (concat "(" name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (setq name (regexp-quote name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (or (lisp-match-ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (if (not arg) (concat "(" package name "[ \t\n\)]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (not arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (lisp-match-ring (concat "(" package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 "[^ \t\n]*-*" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 fun))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (let ((form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (buffer-substring (lisp-defun-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (lisp-end-defun-text t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (switch-to-lisp t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (comint-kill-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (insert form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (defun ilisp-send (string &optional message status and-go handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 "Send STRING to the ILISP buffer, print MESSAGE set STATUS and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 return the result if AND-GO is NIL, otherwise switch to ilisp if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 and-go is T and show message and results. If AND-GO is 'dispatch,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 then the command will be executed without waiting for results. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 AND-GO is 'call, then a call will be generated. If this is the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 time an ilisp command has been executed, the lisp will also be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 initialized from the files in ilisp-load-inits. If there is an error,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 comint-errorp will be T and it will be handled by HANDLER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (ilisp-init t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (let ((process (ilisp-process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (dispatch (eq and-go 'dispatch)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (if message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (message "%s" (if dispatch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (concat "Started " message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;; No completion table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setq ilisp-original nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (if (memq and-go '(t call))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (progn (comint-send process string nil nil status message handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (if (eq and-go 'call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (call-defun-lisp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (switch-to-lisp t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (let* ((save (ilisp-value 'ilisp-save-command t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (comint-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (if save (format save string) string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; Interrupt without waiting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 t (if (not dispatch) 'wait) status message handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (comint-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (ilisp-value 'ilisp-restore-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 t nil 'restore "Restore" t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (not dispatch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (while (not (cdr result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (accept-process-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (comint-remove-whitespace (car result))))))))
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (defun ilisp-load-or-send (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 "Try to load FILE into the inferior LISP. If the file is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 accessible in the inferior LISP as determined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ilisp-load-or-send-command, then visit the file and send the file over
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 the process interface."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (let* ((command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (format (ilisp-value 'ilisp-load-or-send-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (lisp-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (ilisp-value 'ilisp-init-binary-extension t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (set-ilisp-value 'ilisp-load-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (nconc (ilisp-value 'ilisp-load-files t) (list file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (comint-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (ilisp-process) command t nil 'load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (format "Loading %s" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (function (lambda (error wait message output last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (let* ((file (lisp-last ilisp-load-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (process (get-buffer-process (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (if (and output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (string-match "nil" (car (lisp-last-line output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (let* ((old-buffer (get-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (buffer (find-file-noselect file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (string (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (buffer-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (if (not old-buffer) (kill-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (if (string= "" string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (abort-commands-lisp (format "Can't find file %s" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (comint-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (format ilisp-block-command string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 t nil 'send (format "Sending %s" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (function (lambda (error wait message output last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (if error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (comint-display-error output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (abort-commands-lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (format "Error sending %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (lisp-last ilisp-load-files))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (setq ilisp-load-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (delq (lisp-last ilisp-load-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ilisp-load-files))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (if error (ilisp-handler error wait message output last))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (setq ilisp-load-files (delq file ilisp-load-files)))))))))