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