comparison lisp/edebug/cl-read.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents ec9a17fef872
children b9518feda344
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
1 ;; Customizable, Common Lisp like reader for Emacs Lisp. 1 ;; Customizable, Common Lisp like reader for Emacs Lisp.
2 ;; 2 ;;
3 ;; Copyright (C) 1993 by Guido Bosch <Guido.Bosch@loria.fr> 3 ;; Copyright (C) 1993 by Guido Bosch <Guido.Bosch@loria.fr>
4 4
5 ;; This file is part of XEmacs 5 ;; This file is written in GNU Emacs Lisp, but not (yet) part of GNU Emacs.
6 6
7 ;; XEmacs is free software; you can redistribute it and/or modify it 7 ;; The software contained in this file is free software; you can
8 ;; under the terms of the GNU General Public License as published by 8 ;; redistribute it and/or modify it under the terms of the GNU General
9 ;; the Free Software Foundation; either version 2, or (at your option) 9 ;; Public License as published by the Free Software Foundation; either
10 ;; any later version. 10 ;; version 2, or (at your option) any later version.
11 11
12 ;; XEmacs is distributed in the hope that it will be useful, but 12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of 13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; General Public License for more details. 15 ;; GNU General Public License for more details.
16 16
17 ;; You should have received a copy of the GNU General Public License 17 ;; You should have received a copy of the GNU General Public License
18 ;; along with XEmacs; see the file COPYING. If not, write to the Free 18
19 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 ;; along with GNU Emacs; see the file COPYING. If not, write to
20 ;; 02111-1307, USA. 20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 21 ;;
22 ;;; Synched up with: Not in FSF
23
24 ;;; Commentary:
25
26 ;; Please send bugs and comments to the author. 22 ;; Please send bugs and comments to the author.
27 ;; 23 ;;
28 ;; <DISCLAIMER> 24 ;; <DISCLAIMER>
29 ;; This program is still under development. Neither the author nor 25 ;; This program is still under development. Neither the author nor
30 ;; his employer accepts responsibility to anyone for the consequences of 26 ;; his employer accepts responsibility to anyone for the consequences of
81 ;; 77 ;;
82 ;; 78 ;;
83 ;; Dispatch Character Macro" `#' 79 ;; Dispatch Character Macro" `#'
84 ;; 80 ;;
85 ;; #'<function> function quoting 81 ;; #'<function> function quoting
86 ;; #\<character> character syntax 82 ;; #\<charcter> character syntax
87 ;; #.<form> read time evaluation 83 ;; #.<form> read time evaluation
88 ;; #p<path>, #P<path> paths 84 ;; #p<path>, #P<path> paths
89 ;; #+<feature>, #-<feature> conditional reading 85 ;; #+<feature>, #-<feature> conditional reading
90 ;; #<n>=, #<n># tags for shared structure reading 86 ;; #<n>=, #<n># tags for shared structure reading
91 ;; 87 ;;
206 202
207 203
208 ; Change History 204 ; Change History
209 ; 205 ;
210 ; $Log: cl-read.el,v $ 206 ; $Log: cl-read.el,v $
211 ; Revision 1.2 1997/03/09 02:36:46 steve 207 ; Revision 1.1.1.1 1996/12/18 22:43:07 steve
212 ; Patches to beta98 208 ; XEmacs 20.0 -- Beta 30
213 ; 209 ;
214 ; Revision 1.19 94/03/21 19:59:24 liberte 210 ; Revision 1.19 94/03/21 19:59:24 liberte
215 ; Add invalid-cl-read-syntax error symbol. 211 ; Add invalid-cl-read-syntax error symbol.
216 ; Add reader::read-sexp and reader::read-sexp-func to allow customization 212 ; Add reader::read-sexp and reader::read-sexp-func to allow customization
217 ; based on the results of reading. 213 ; based on the results of reading.
304 ; Revision 1.1 1993/03/29 19:37:21 bosch 300 ; Revision 1.1 1993/03/29 19:37:21 bosch
305 ; Initial revision 301 ; Initial revision
306 ; 302 ;
307 ; 303 ;
308 304
309 ;;; Code: 305 ;;
310
311 (require 'cl) 306 (require 'cl)
312 ;; Thou shalt evaluate a defadvice only once, or thou shalt surely lose. -sb 307
313 (require 'advise-eval-region) 308 (provide 'cl-read)
314
315 ;; load before compiling 309 ;; load before compiling
316 ;; This is ugly, but apparently the only way to do it :-( -sb
317 (provide 'cl-read)
318 (require 'cl-read) 310 (require 'cl-read)
319 311
320 ;; bootstrapping with cl-packages 312 ;; bootstrapping with cl-packages
321 ;; defpackage and in-package are ignored until cl-read is installed. 313 ;; defpackage and in-package are ignored until cl-read is installed.
322 '(defpackage reader 314 '(defpackage reader
380 ;; 2. A function (i.e., a symbol with a function definition, a byte 372 ;; 2. A function (i.e., a symbol with a function definition, a byte
381 ;; compiled function or an uncompiled lambda expression). It means the 373 ;; compiled function or an uncompiled lambda expression). It means the
382 ;; character is a macro character. 374 ;; character is a macro character.
383 ;; 375 ;;
384 ;; 3. A vector of length `reader::readtable-size'. Elements of this vector 376 ;; 3. A vector of length `reader::readtable-size'. Elements of this vector
385 ;; may be `nil' or a function (see 2.). It means the character is a 377 ;; may be `nil' or a function (see 2.). It means the charater is a
386 ;; dispatch character, and the vector its dispatch function table. 378 ;; dispatch character, and the vector its dispatch fucntion table.
387 379
388 (defvar *readtable*) 380 (defvar *readtable*)
389 (defvar reader::internal-standard-readtable) 381 (defvar reader::internal-standard-readtable)
390 382
391 (defun* copy-readtable 383 (defun* copy-readtable
1298 ;; evals) in the current buffer. Alternatively, this could be fixed 1290 ;; evals) in the current buffer. Alternatively, this could be fixed
1299 ;; in C. In Lemacs 19.6 and later, this function is already written 1291 ;; in C. In Lemacs 19.6 and later, this function is already written
1300 ;; in lisp, and based on more primitive read functions we already 1292 ;; in lisp, and based on more primitive read functions we already
1301 ;; replaced. The reading happens during the interactive parameter 1293 ;; replaced. The reading happens during the interactive parameter
1302 ;; retrieval, which is written in lisp, too. So this replacement of 1294 ;; retrieval, which is written in lisp, too. So this replacement of
1303 ;; eval-expression is only required for (FSF) Emacs 18 (and 19?). 1295 ;; eval-expresssion is only required fro (FSF) Emacs 18 (and 19?).
1304 1296
1305 (or (fboundp 'reader::original-eval-expression) 1297 (or (fboundp 'reader::original-eval-expression)
1306 (fset 'reader::original-eval-expression 1298 (fset 'reader::original-eval-expression
1307 (symbol-function 'eval-expression))) 1299 (symbol-function 'eval-expression)))
1308 1300
1321 ))))) 1313 )))))
1322 (setq values (cons (eval reader::expression) values)) 1314 (setq values (cons (eval reader::expression) values))
1323 (prin1 (car values) t)) 1315 (prin1 (car values) t))
1324 1316
1325 (require 'eval-reg "eval-reg") 1317 (require 'eval-reg "eval-reg")
1326 ; (require 'advice) 1318 (require 'advice)
1327 1319
1328 1320
1329 ;; installing/uninstalling the cl reader 1321 ;; installing/uninstalling the cl reader
1330 ;; These two should always be used in pairs, or just install once and 1322 ;; These two should always be used in pairs, or just install once and
1331 ;; never uninstall. 1323 ;; never uninstall.
1350 ;; for buffers without cl read syntax. The buffer local variable 1342 ;; for buffers without cl read syntax. The buffer local variable
1351 ;; `cl-read-active' controls whether the replacement funtions of this 1343 ;; `cl-read-active' controls whether the replacement funtions of this
1352 ;; package or the original ones are actually called. 1344 ;; package or the original ones are actually called.
1353 (cl-reader-install) 1345 (cl-reader-install)
1354 (cl-reader-uninstall) 1346 (cl-reader-uninstall)
1347
1348 ;; Advise the redefined eval-region
1349 (defadvice eval-region (around cl-read activate)
1350 "Use the reader::read instead of the original read if cl-read-active."
1351 (with-elisp-eval-region (not cl-read-active)
1352 (ad-do-it)))
1353 ;;(ad-unadvise 'eval-region)
1354
1355 1355
1356 (add-hook 'emacs-lisp-mode-hook 'cl-reader-autoinstall-function) 1356 (add-hook 'emacs-lisp-mode-hook 'cl-reader-autoinstall-function)
1357 1357
1358 '(defvar read-syntax) 1358 '(defvar read-syntax)
1359 1359
1395 (make-local-variable 'cl-read-active) 1395 (make-local-variable 'cl-read-active)
1396 (setq cl-read-active t)))))) 1396 (setq cl-read-active t))))))
1397 1397
1398 1398
1399 (run-hooks 'cl-read-load-hooks) 1399 (run-hooks 'cl-read-load-hooks)
1400 1400 ;; end cl-read.el
1401 ;; cl-read.el ends here