Mercurial > hg > xemacs-beta
comparison lisp/edebug/edebug-cl-read.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 ;; edebug-cl-read.el - Edebug reader macros for use with cl-read. | |
2 | |
3 ;; Copyright (C) 1993 Daniel LaLiberte | |
4 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> | |
5 ;; Keywords: lisp, tools, maint | |
6 | |
7 ;; LCD Archive Entry: | |
8 ;; edebug-cl-read.el|Daniel LaLiberte|liberte@cs.uiuc.edu | |
9 ;; |Edebug reader macros for cl-read.el | |
10 ;; |$Date: 1996/12/18 03:33:27 $|$Revision: 1.1.1.1 $|~/modes/edebug-cl-read.el| | |
11 | |
12 ;; This file is not yet part of GNU Emacs. | |
13 | |
14 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
15 ;; it under the terms of the GNU General Public License as published by | |
16 ;; the Free Software Foundation; either version 2, or (at your option) | |
17 ;; any later version. | |
18 | |
19 ;; GNU Emacs is distributed in the hope that it will be useful, | |
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
25 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
26 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
27 | |
28 ;;;; Commentary: | |
29 | |
30 ;; If you use cl-read.el and want to use edebug with any code | |
31 ;; in a file written with CL read syntax, then you need to use this | |
32 ;; package. | |
33 | |
34 ;; To Do: | |
35 ;; Handle shared structures, but this is not normally used in executable code. | |
36 | |
37 ;; Read-time evaluation shouldn't be used in a form argument since | |
38 ;; there is no way to instrument the result of the evaluation, and | |
39 ;; no way to tell Edebug not to try. | |
40 | |
41 ;; Need to mangle all local variable names that might be visible to | |
42 ;; eval, e.g. stream, char. Alternatively, packages could hide them. | |
43 | |
44 (require 'cl) | |
45 ;; For byte compiling cl-read is needed. | |
46 ;; But edebug-cl-read should not even be loaded unless cl-read already is. | |
47 (require 'cl-read) | |
48 | |
49 (provide 'edebug-cl-read) | |
50 ;; Do the above provide before the following require to avoid load loop. | |
51 (require 'edebug) | |
52 | |
53 (defvar reader::stack) | |
54 | |
55 ;; The following modifications of reader functions | |
56 ;; could be done via advice. But we need to switch between | |
57 ;; edebug versions and originals frequently. Also advice.el | |
58 ;; doesn't support advising anonymous functions. | |
59 | |
60 (defun edebug-reader::read-sexp-func (point func) | |
61 ;; dummy def | |
62 ) | |
63 | |
64 (defvar edebug-read-dotted-list) | |
65 | |
66 (defun edebug-read-sexp-func (point func) | |
67 "Edebug offset storing is happening." | |
68 (edebug-storing-offsets point | |
69 (let (edebug-read-dotted-list) | |
70 (edebug-reader::read-sexp-func point func)))) | |
71 | |
72 (defun edebug-end-list-handler (stream char) | |
73 ;; If the dotted form is a list, signal to offset routines. | |
74 (setq edebug-read-dotted-list (listp (car reader::stack))) | |
75 (edebug-reader::end-list-handler stream char)) | |
76 | |
77 | |
78 ;;========================================================================= | |
79 ;; Redefine the edebug reader to check whether CL syntax is active. | |
80 ;; This might be a little cleaner using advice. | |
81 | |
82 (defvar edebug-reading-with-cl-read nil) | |
83 | |
84 (or (fboundp 'edebug-original-read-storing-offsets) | |
85 (defalias 'edebug-original-read-storing-offsets | |
86 (symbol-function 'edebug-read-storing-offsets))) | |
87 | |
88 (defun edebug-read-storing-offsets (stream) | |
89 ;; Read a sexp from STREAM. | |
90 ;; STREAM is limited to the current buffer. | |
91 ;; Create a parallel offset structure as described in doc for edebug-offsets. | |
92 ;; This version, from edebug-cl-read, uses cl-read. | |
93 (if (not cl-read-active) | |
94 ;; Use the reader for standard Emacs Lisp. | |
95 (edebug-original-read-storing-offsets stream) | |
96 | |
97 ;; Use cl-read with edebug hooks. | |
98 (if edebug-reading-with-cl-read nil | |
99 ;; Only do this if it's not already been done, else it loops. | |
100 (fset 'edebug-reader::read-sexp-func | |
101 (symbol-function 'reader::read-sexp-func)) | |
102 (fset 'reader::read-sexp-func 'edebug-read-sexp-func) | |
103 (fset 'edebug-reader::end-list-handler (get-macro-character ?\))) | |
104 (set-macro-character ?\) 'edebug-end-list-handler))) | |
105 (unwind-protect | |
106 (let ((edebug-reading-with-cl-read t)) | |
107 (reader::read stream)) | |
108 (if edebug-reading-with-cl-read nil | |
109 (set-macro-character | |
110 ?\) (symbol-function 'edebug-reader::end-list-handler)) | |
111 (fset 'reader::read-sexp-func | |
112 (symbol-function 'edebug-reader::read-sexp-func))))) | |
113 |