annotate lisp/edebug/edebug.el @ 48:56c54cf7c5b6 r19-16b90

Import from CVS: tag r19-16b90
author cvs
date Mon, 13 Aug 2007 08:56:04 +0200
parents 441bb1e64a06
children 131b0175ea99
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 ;;; edebug.el --- a source-level debugger for 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 ;; Copyright (C) 1988,'89,'90,'91,'92,'93,'94,'95 Free Software Foundation, Inc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: lisp, tools, maint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
8 ;; This file is part of XEmacs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
9
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
11 ;; under the terms of the GNU General Public License as published by
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
13 ;; any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
14
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
18 ;; General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
19
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
20 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
23 ;; 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
24
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
25 ;;; Synched up with: FSF 19.34.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
26
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
27 ;;; Commentary:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
28
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; edebug|Daniel LaLiberte|liberte@cs.uiuc.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; |A source level debugger for Emacs Lisp.
48
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 26
diff changeset
32 ;; |$Date: 1997/08/21 06:23:41 $|$Revision: 1.3 $|~/modes/edebug.el|
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
33
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
34 ;; This minor mode allows programmers to step through Emacs Lisp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
35 ;; source code while executing functions. You can also set
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
36 ;; breakpoints, trace (stopping at each expression), evaluate
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
37 ;; expressions as if outside Edebug, reevaluate and display a list of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
38 ;; expressions, trap errors normally caught by debug, and display a
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
39 ;; debug style backtrace.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
40
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
41 ;;; Installation
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
42 ;; =============
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
43
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
44 ;; Put edebug.el in some directory in your load-path and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
45 ;; byte-compile it. Also read the beginning of edebug-epoch.el,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
46 ;; cl-specs.el, and edebug-cl-read.el if they apply to you.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
47
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
48 ;; Unless you are using Emacs 19 which is already set up to use Edebug,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
49 ;; put the following forms in your .emacs file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
50 ;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
51 ;; (autoload 'edebug-eval-top-level-form "edebug")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
52
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
53 ;; If you wish to change the default edebug global command prefix, change:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
54 ;; (setq edebug-global-prefix "\C-xX")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
55
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
56 ;; Other options, are described in the manual.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
57
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
58 ;; In previous versions of Edebug, users were directed to set
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
59 ;; `debugger' to `edebug-debug'. This is no longer necessary
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
60 ;; since Edebug automatically sets it whenever Edebug is active.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
61
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
62 ;;; Minimal Instructions
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
63 ;; =====================
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
64
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
65 ;; First evaluate a defun with C-xx, then run the function. Step
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
66 ;; through the code with SPC, mark breakpoints with b, go until a
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
67 ;; breakpoint is reached with g, and quit execution with q. Use the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
68 ;; "?" command in edebug to describe other commands. See edebug.tex
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
69 ;; or the Emacs 19 Lisp Reference Manual for more instructions.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
70
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
71 ;; Send me your enhancements, ideas, bugs, or fixes.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
72 ;; For bugs, you can call edebug-submit-bug-report if you have reporter.el.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
73 ;; There is an edebug mailing list if you want to keep up
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
74 ;; with the latest developments. Requests to: edebug-request@cs.uiuc.edu
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
75
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
76 ;; Daniel LaLiberte 217-398-4114
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
77 ;; University of Illinois, Urbana-Champaign
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
78 ;; Department of Computer Science
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
79 ;; 1304 W Springfield
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
80 ;; Urbana, IL 61801
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
81
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
82 ;; uiucdcs!liberte
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
83 ;; liberte@cs.uiuc.edu
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
84
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
85 ;; For the early revision history, see edebug-history.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
86
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
87 ;;; Code:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defconst edebug-version
48
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 26
diff changeset
90 (let ((raw-version "$Revision: 1.3 $"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (substring raw-version (string-match "[0-9.]*" raw-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (require 'backquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
96 ;; Emacs 18 doesn't have defalias.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (or (fboundp 'defalias) (fset 'defalias 'fset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
101 ;;; Bug reporting
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defconst edebug-maintainer-address "liberte@cs.uiuc.edu")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defun edebug-submit-bug-report ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "Submit, via mail, a bug report on edebug."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (require 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (and (y-or-n-p "Do you really want to submit a report on edebug? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 edebug-maintainer-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (concat "edebug.el " edebug-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (list 'edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 'edebug-all-defs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 'edebug-all-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 'edebug-eval-macro-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 'edebug-stop-before-symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 'edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 'edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 'edebug-initial-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 'edebug-trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 'edebug-test-coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 'edebug-continue-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 'edebug-print-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 'edebug-print-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 'edebug-print-circle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
129 ;;; Options
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defvar edebug-setup-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 "*Functions to call before edebug is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 Each time it is set to a new value, Edebug will call those functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 once and then `edebug-setup-hook' is reset to nil. You could use this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 to load up Edebug specifications associated with a package you are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 using but only when you also use Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defvar edebug-all-defs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "*If non-nil, evaluation of any defining forms will instrument for Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 This applies to `eval-defun', `eval-region', `eval-buffer', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 `eval-current-buffer'. `eval-region' is also called by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 `eval-last-sexp', and `eval-print-last-sexp'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 You can use the command `edebug-all-defs' to toggle the value of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 variable. You may wish to make it local to each buffer with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 \(make-local-variable 'edebug-all-defs) in your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 `emacs-lisp-mode-hook'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defvar edebug-all-forms nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 "*Non-nil evaluation of all forms will instrument for Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 This doesn't apply to loading or evaluations in the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 Use the command `edebug-all-forms' to toggle the value of this option.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defvar edebug-eval-macro-args nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "*Non-nil means all macro call arguments may be evaluated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 If this variable is nil, the default, Edebug will *not* wrap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 macro call arguments as if they will be evaluated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 For each macro, a `edebug-form-spec' overrides this option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 So to specify exceptions for macros that have some arguments evaluated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 and some not, you should specify an `edebug-form-spec'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 This option is going away soon.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defvar edebug-stop-before-symbols nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "*Non-nil causes Edebug to stop before symbols as well as after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 In any case, a breakpoint or interrupt may stop before a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 This option is going away soon.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defvar edebug-save-windows t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "*If non-nil, Edebug saves and restores the window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 That takes some time, so if your program does not care what happens to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 the window configurations, it is better to set this variable to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 If the value is a list, only the listed windows are saved and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 restored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 `edebug-toggle-save-windows' may be used to change this variable.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defvar edebug-save-displayed-buffer-points nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "*If non-nil, save and restore point in all displayed buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 Saving and restoring point in other buffers is necessary if you are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 debugging code that changes the point of a buffer which is displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 in a non-selected window. If Edebug or the user then selects the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 window, the buffer's point will be changed to the window's point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 Saving and restoring point in all buffers is expensive, since it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 requires selecting each window twice, so enable this only if you need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (defvar edebug-initial-mode 'step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 "*Initial execution mode for Edebug, if non-nil. If this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 is non-@code{nil}, it specifies the initial execution mode for Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 when it is first activated. Possible values are step, next, go,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 Go-nonstop, trace, Trace-fast, continue, and Continue-fast.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (defvar edebug-trace nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 "*Non-nil means display a trace of function entry and exit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 Tracing output is displayed in a buffer named `*edebug-trace*', one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 function entry or exit per line, indented by the recursion level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 You can customize by replacing functions `edebug-print-trace-before'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 and `edebug-print-trace-after'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defvar edebug-test-coverage nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 "*If non-nil, Edebug tests coverage of all expressions debugged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 This is done by comparing the result of each expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 with the previous result. Coverage is considered OK if two different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 results are found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 Use `edebug-display-freq-count' to display the frequency count and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 coverage information for a definition.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defvar edebug-continue-kbd-macro nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "*If non-nil, continue defining or executing any keyboard macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 Use this with caution since it is not debugged.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (defvar edebug-print-length 50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "*Default value of `print-length' to use while printing results in Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (defvar edebug-print-level 50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 "*Default value of `print-level' to use while printing results in Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (defvar edebug-print-circle t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 "*Default value of `print-circle' to use while printing results in Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (defvar edebug-unwrap-results nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 "*Non-nil if Edebug should unwrap results of expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 This is useful when debugging macros where the results of expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 are instrumented expressions. But don't do this when results might be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 circular or an infinite loop will result.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defvar edebug-on-error t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "*Value bound to `debug-on-error' while Edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 If `debug-on-error' is non-nil, that value is still used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 If the value is a list of signal names, Edebug will stop when any of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 these errors are signaled from Lisp code whether or not the signal is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 handled by a `condition-case'. This option is useful for debugging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 signals that *are* handled since they would otherwise be missed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 After execution is resumed, the error is signaled again.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defvar edebug-on-quit t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "*Value bound to `debug-on-quit' while Edebug is active.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defvar edebug-global-break-condition nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "*If non-nil, an expression to test for at every stop point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 If the result is non-nil, then break. Errors are ignored.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
251 ;;; Form spec utilities.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defmacro def-edebug-spec (symbol spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "Set the edebug-form-spec property of SYMBOL according to SPEC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 Both SYMBOL and SPEC are unevaluated. The SPEC can be 0, t, a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 \(naming a function), or a list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (` (put (quote (, symbol)) 'edebug-form-spec (quote (, spec)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defmacro def-edebug-form-spec (symbol spec-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "For compatibility with old version. Use `def-edebug-spec' instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (message "Obsolete: use def-edebug-spec instead.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (def-edebug-spec symbol (eval spec-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defun get-edebug-spec (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; Get the spec of symbol resolving all indirection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (let ((edebug-form-spec (get symbol 'edebug-form-spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 indirect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (while (and (symbolp edebug-form-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (setq indirect (get edebug-form-spec 'edebug-form-spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; (edebug-trace "indirection: %s" edebug-form-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (setq edebug-form-spec indirect))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 edebug-form-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
276 ;;; Utilities
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; Define edebug-gensym - from old cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defvar edebug-gensym-index 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "Integer used by `edebug-gensym' to produce new names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defun edebug-gensym (&optional prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 "Generate a fresh uninterned symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 There is an optional argument, PREFIX. PREFIX is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 string that begins the new name. Most people take just the default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 except when debugging needs suggest otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (if (null prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq prefix "G"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (let ((newsymbol nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (newname ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (while (not newsymbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (setq newname (concat prefix (int-to-string edebug-gensym-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (setq edebug-gensym-index (+ edebug-gensym-index 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (not (intern-soft newname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq newsymbol (make-symbol newname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 newsymbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; Only used by CL-like code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defun edebug-keywordp (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 "Return t if OBJECT is a keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 A keyword is a symbol that starts with `:'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (and (symbolp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (= ?: (aref (symbol-name object) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (defun edebug-lambda-list-keywordp (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 "Return t if OBJECT is a lambda list keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 A lambda list keyword is a symbol that starts with `&'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (and (symbolp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (= ?& (aref (symbol-name object) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (defun edebug-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; Return the last sexp before point in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;; Assumes Emacs Lisp syntax is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (read-from-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (forward-sexp -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (defun edebug-window-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 "Return a list of windows, in order of `next-window'."
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
325 ;; This doesn't work for epoch.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (let* ((first-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (window-list (list first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (next (next-window first-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (while (not (eq next first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (setq window-list (cons next window-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (setq next (next-window next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (nreverse window-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defun edebug-window-live-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 "Return non-nil if WINDOW is visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (let* ((first-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (next (next-window first-window t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (while (not (or (eq next window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (eq next first-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (setq next (next-window next t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (eq next window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;; Not used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 '(defun edebug-two-window-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 "Return t if there are two windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (and (not (one-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (eq (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (next-window (next-window (selected-window))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (defsubst edebug-lookup-function (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (while (and (symbolp object) (fboundp object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (setq object (symbol-function object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (defun edebug-macrop (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 "Return the macro named by OBJECT, or nil if it is not a macro."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq object (edebug-lookup-function object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (if (and (listp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (eq 'macro (car object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (edebug-functionp (cdr object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defun edebug-functionp (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "Returns the function named by OBJECT, or nil if it is not a function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (setq object (edebug-lookup-function object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (if (or (subrp object)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
367 (compiled-function-p object) ; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (and (listp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (eq (car object) 'lambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (listp (car (cdr object)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 object))
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 edebug-sort-alist (alist function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ;; Return the ALIST sorted with comparison function FUNCTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;; This uses 'sort so the sorting is destructive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (sort alist (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (lambda (e1 e2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (funcall function (car e1) (car e2))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;;(def-edebug-spec edebug-save-restriction t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;; Not used. If it is used, def-edebug-spec must be defined before use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 '(defmacro edebug-save-restriction (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 "Evaluate BODY while saving the current buffers restriction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 BODY may change buffer outside of current restriction, unlike
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 save-restriction. BODY may change the current buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 and the restriction will be restored to the original buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 and the current buffer remains current.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 Return the result of the last expression in BODY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (` (let ((edebug:s-r-beg (point-min-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (edebug:s-r-end (point-max-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (progn (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (set-buffer (marker-buffer edebug:s-r-beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (narrow-to-region edebug:s-r-beg edebug:s-r-end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
398 ;;; Display
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (defconst edebug-trace-buffer "*edebug-trace*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 "Name of the buffer to put trace info in.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defun edebug-pop-to-buffer (buffer &optional window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; Like pop-to-buffer, but select window where BUFFER was last shown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;; Select WINDOW if it provided and it still exists. Otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;; if buffer is currently shown in several windows, choose one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;; Otherwise, find a new window, possibly splitting one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (setq window (if (and (windowp window) (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (eq (window-buffer window) buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (if (eq (window-buffer (selected-window)) buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (edebug-get-buffer-window buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (if (one-window-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (split-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;; (message "next window: %s" (next-window)) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (if (eq (get-buffer-window edebug-trace-buffer) (next-window))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
420 ;; Don't select trace window
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (select-window (next-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (set-window-buffer (selected-window) buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (set-window-hscroll (selected-window) 0);; should this be??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;; Selecting the window does not set the buffer until command loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;;(set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (defun edebug-get-displayed-buffer-points ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;; Return a list of buffer point pairs, for all displayed buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let* ((first-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (next (next-window first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (buffer-point-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (while (not (eq next first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (set-buffer (setq buffer (window-buffer next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setq buffer-point-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (cons (cons buffer (point)) buffer-point-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (setq next (next-window next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 buffer-point-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (defun edebug-set-buffer-points (buffer-points)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;; Restore the buffer-points created by edebug-get-displayed-buffer-points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (let ((current-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (mapcar (function (lambda (buf-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (if (buffer-name (car buf-point)) ; still exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (set-buffer (car buf-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (goto-char (cdr buf-point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 buffer-points)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (set-buffer current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (defun edebug-current-windows (which-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ;; Get either a full window configuration or some window information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (listp which-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (mapcar (function (lambda (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (if (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (list window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (window-buffer window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (window-point window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (window-start window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (window-hscroll window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 which-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (defun edebug-set-windows (window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; Set either a full window configuration or some window information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (if (listp window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (lambda (one-window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (if one-window-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (apply (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (lambda (window buffer point start hscroll)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (if (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (set-window-buffer window buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (set-window-point window point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (set-window-start window start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (set-window-hscroll window hscroll)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 one-window-info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (set-window-configuration window-info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (defalias 'edebug-get-buffer-window 'get-buffer-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (defalias 'edebug-sit-for 'sit-for)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (defalias 'edebug-input-pending-p 'input-pending-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
492 ;;; Redefine read and eval functions
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
493 ;; read is redefined to maybe instrument forms.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
494 ;; eval-defun is redefined to check edebug-all-forms and edebug-all-defs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
495
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
496 ;; Use the Lisp version of eval-region.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (require 'eval-reg "eval-reg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; Save the original read function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (or (fboundp 'edebug-original-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (defalias 'edebug-original-read (symbol-function 'read)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (defun edebug-read (&optional stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 "Read one Lisp expression as text from STREAM, return as Lisp object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 If STREAM is nil, use the value of `standard-input' (which see).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 STREAM or the value of `standard-input' may be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 a buffer (read from point and advance it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 a marker (read from where it points and advance it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 a function (call it with no arguments for each character,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 call it with a char as argument to push a char back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 a string (takes text from string, starting at the beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 t (read text line using minibuffer and use it).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 This version, from Edebug, maybe instruments the expression. But the
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
515 STREAM must be the current buffer to do so. Whether it instruments is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 also dependent on the values of `edebug-all-defs' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 `edebug-all-forms'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (or stream (setq stream standard-input))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (if (eq stream (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (edebug-read-and-maybe-wrap-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (edebug-original-read stream)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (or (fboundp 'edebug-original-eval-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defalias 'edebug-original-eval-defun (symbol-function 'eval-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
526 ;; We should somehow arrange to be able to do this
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
527 ;; without actually replacing the eval-defun command.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (defun edebug-eval-defun (edebug-it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 "Evaluate the top-level form containing point, or after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 This version, from Edebug, has the following differences: With a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 prefix argument instrument the code for Edebug. If `edebug-all-defs' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 non-nil, then the code is instrumented *unless* there is a prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 argument. If instrumenting, it prints: `Edebug: FUNCTIONNAME'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 Otherwise, it prints in the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (interactive "P")
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
537 (let* ((edebugging (not (eq (not edebug-it) (not edebug-all-defs))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
538 (edebug-result)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
539 (form
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
540 (let ((edebug-all-forms edebugging)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
541 (edebug-all-defs (eq edebug-all-defs (not edebug-it))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
542 (edebug-read-top-level-form))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
543 (if (and (eq (car form) 'defvar)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
544 (cdr-safe (cdr-safe form)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
545 (setq form (cons 'defconst (cdr form))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
546 (setq edebug-result (eval form))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (if (not edebugging)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (princ edebug-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 edebug-result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (defalias 'edebug-defun 'edebug-eval-top-level-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (defun edebug-eval-top-level-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 "Evaluate a top level form, such as a defun or defmacro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 This is like `eval-defun', but the code is always instrumented for Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 Print its name in the minibuffer and leave point where it is,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 or if an error occurs, leave point after it with mark at the original point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (eval
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
563 ;; Bind edebug-all-forms only while reading, not while evalling
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;; but this causes problems while edebugging edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (let ((edebug-all-forms t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (edebug-all-defs t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (edebug-read-top-level-form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (defun edebug-read-top-level-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (let ((starting-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (end-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (edebug-read-and-maybe-wrap-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ;; Recover point, but only if no error occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (goto-char starting-point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; Compatibility with old versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (defalias 'edebug-all-defuns 'edebug-all-defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (defun edebug-all-defs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 "Toggle edebugging of all definitions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (setq edebug-all-defs (not edebug-all-defs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (message "Edebugging all definitions is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (if edebug-all-defs "on" "off")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defun edebug-all-forms ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 "Toggle edebugging of all forms."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (setq edebug-all-forms (not edebug-all-forms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (message "Edebugging all forms is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (if edebug-all-forms "on" "off")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (defun edebug-install-read-eval-functions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; Don't install if already installed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (if (eq (symbol-function 'read) 'edebug-read) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (elisp-eval-region-install)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (defalias 'read 'edebug-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (defalias 'eval-defun 'edebug-eval-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (defun edebug-uninstall-read-eval-functions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (elisp-eval-region-uninstall)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (defalias 'read (symbol-function 'edebug-original-read))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (defalias 'eval-defun (symbol-function 'edebug-original-eval-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
614 ;;; Edebug internal data
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
615
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
616 ;; The internal data that is needed for edebugging is kept in the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
617 ;; buffer-local variable `edebug-form-data'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ;; XEmacs change?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (defconst edebug-form-data nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (make-variable-buffer-local 'edebug-form-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;; A list of entries associating symbols with buffer regions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;; This is an automatic buffer local variable. Each entry looks like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ;; @code{(@var{symbol} @var{begin-marker} @var{end-marker}). The markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; are at the beginning and end of an entry level form and @var{symbol} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;; a symbol that holds all edebug related information for the form on its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;; property list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;; In the future, the symbol will be irrelevant and edebug data will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;; be stored in the definitions themselves rather than in the property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;; list of a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (defun edebug-make-form-data-entry (symbol begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (list symbol begin end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (defsubst edebug-form-data-name (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (car entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (defsubst edebug-form-data-begin (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (nth 1 entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (defsubst edebug-form-data-end (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (nth 2 entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (defsubst edebug-set-form-data-entry (entry name begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setcar entry name);; in case name is changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (set-marker (nth 1 entry) begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (set-marker (nth 2 entry) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (defun edebug-get-form-data-entry (pnt &optional end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; Find the edebug form data entry which is closest to PNT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;; If END-POINT is supplied, match must be exact.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;; Return `nil' if none found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (let ((rest edebug-form-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 closest-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (closest-dist 999999)) ;; need maxint here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (while (and rest (< 0 closest-dist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (let* ((entry (car rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (begin (edebug-form-data-begin entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (dist (- pnt begin)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (setq rest (cdr rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (if (and (<= 0 dist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (< dist closest-dist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (or (not end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (= end-point (edebug-form-data-end entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (<= pnt (edebug-form-data-end entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (setq closest-dist dist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 closest-entry entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 closest-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;; Also need to find all contained entries,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;; and find an entry given a symbol, which should be just assq.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (defun edebug-form-data-symbol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ;; Return the edebug data symbol of the form where point is in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;; If point is not inside a edebuggable form, cause error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (or (edebug-form-data-name (edebug-get-form-data-entry (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (error "Not inside instrumented form")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (defun edebug-make-top-form-data-entry (new-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ;; Make NEW-ENTRY the first element in the `edebug-form-data' list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (edebug-clear-form-data-entry new-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (setq edebug-form-data (cons new-entry edebug-form-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (defun edebug-clear-form-data-entry (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ;; If non-nil, clear ENTRY out of the form data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;; Maybe clear the markers and delete the symbol's edebug property?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (if entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 ;; Instead of this, we could just find all contained forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 ;; (put (car entry) 'edebug nil) ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 ;; (mapcar 'edebug-clear-form-data-entry ; dangerous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ;; (get (car entry) 'edebug-dependents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;; (set-marker (nth 1 entry) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ;; (set-marker (nth 2 entry) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (setq edebug-form-data (delq entry edebug-form-data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
699 ;;; Parser utilities
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (defun edebug-syntax-error (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 ;; Signal an invalid-read-syntax with ARGS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (signal 'invalid-read-syntax args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (defconst edebug-read-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;; Lookup table for significant characters indicating the class of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ;; token that follows. This is not a \"real\" syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (let ((table (make-vector 256 'symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (while (< i ?!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (aset table i 'space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (aset table ?\( 'lparen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (aset table ?\) 'rparen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (aset table ?\' 'quote)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
717 (aset table ?\` 'backquote)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
718 (aset table ?\, 'comma)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (aset table ?\" 'string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (aset table ?\? 'char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (aset table ?\[ 'lbracket)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (aset table ?\] 'rbracket)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (aset table ?\. 'dot)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (aset table ?\# 'hash)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 ;; We treat numbers as symbols, because of confusion with -, -1, and 1-.
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
726 ;; We don't care about any other chars since they won't be seen.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (defun edebug-next-token-class ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 ;; Move to the next token and return its class. We only care about
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
731 ;; lparen, rparen, dot, quote, backquote, comma, string, char, vector,
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
732 ;; or symbol.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (edebug-skip-whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (aref edebug-read-syntax-table (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (defun edebug-skip-whitespace ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;; Leave point before the next token, skipping white space and comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (skip-chars-forward " \t\r\n\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (while (= (following-char) ?\;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 ;; \r is counted as a comment terminator to support selective display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (skip-chars-forward "^\n\r") ; skip the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (skip-chars-forward " \t\r\n\f")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 ;; Mostly obsolete reader; still used in one case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (defun edebug-read-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 ;; Read one sexp from the current buffer starting at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;; Leave point immediately after it. A sexp can be a list or atom.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ;; An atom is a symbol (or number), character, string, or vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 ;; This works for reading anything legitimate, but it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 ;; is gummed up by parser inconsistencies (bugs?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (let ((class (edebug-next-token-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 ;; read goes one too far if a (possibly quoted) string or symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ;; is immediately followed by non-whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ((eq class 'symbol) (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (edebug-original-read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (if (not (eq (aref edebug-read-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (preceding-char)) 'symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 ((eq class 'string) (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (edebug-original-read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (if (/= (preceding-char) ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ((eq class 'quote) (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (list 'quote (edebug-read-sexp)))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
769 ((eq class 'backquote)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
770 (list '\` (edebug-read-sexp)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
771 ((eq class 'comma)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
772 (list '\, (edebug-read-sexp)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (t ; anything else, just read it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (edebug-original-read (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
776 ;;; Offsets for reader
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 ;; Define a structure to represent offset positions of expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 ;; Each offset structure looks like: (before . after) for constituents,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;; or for structures that have elements: (before <subexpressions> . after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 ;; where the <subexpressions> are the offset structures for subexpressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 ;; including the head of a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (defconst edebug-offsets nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ;; Stack of offset structures in reverse order of the nesting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 ;; This is used to get back to previous levels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (defconst edebug-offsets-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (defconst edebug-current-offset nil) ; Top of the stack, for convenience.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 ;; We must store whether we just read a list with a dotted form that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;; is itself a list. This structure will be condensed, so the offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ;; must also be condensed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (defconst edebug-read-dotted-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (defsubst edebug-initialize-offsets ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; Reinitialize offset recording.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (setq edebug-current-offset nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (defun edebug-store-before-offset (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ;; Add a new offset pair with POINT as the before offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (let ((new-offset (list point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (if edebug-current-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (setcdr edebug-current-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (cons new-offset (cdr edebug-current-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 ;; Otherwise, we are at the top level, so initialize.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (setq edebug-offsets new-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 edebug-offsets-stack nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 edebug-read-dotted-list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ;; Cons the new offset to the front of the stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (setq edebug-offsets-stack (cons new-offset edebug-offsets-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 edebug-current-offset new-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (defun edebug-store-after-offset (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ;; Finalize the current offset struct by reversing it and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ;; store POINT as the after offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (if (not edebug-read-dotted-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 ;; Just reverse the offsets of all subexpressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (setcdr edebug-current-offset (nreverse (cdr edebug-current-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 ;; We just read a list after a dot, which will be abbreviated out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (setq edebug-read-dotted-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 ;; Drop the corresponding offset pair.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; That is, nconc the reverse of the rest of the offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; with the cdr of last offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (setcdr edebug-current-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (nconc (nreverse (cdr (cdr edebug-current-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (cdr (car (cdr edebug-current-offset))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 ;; Now append the point using nconc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (setq edebug-current-offset (nconc edebug-current-offset point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; Pop the stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (setq edebug-offsets-stack (cdr edebug-offsets-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 edebug-current-offset (car edebug-offsets-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (defun edebug-ignore-offset ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;; Ignore the last created offset pair.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (setcdr edebug-current-offset (cdr (cdr edebug-current-offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (def-edebug-spec edebug-storing-offsets (form body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (put 'edebug-storing-offsets 'lisp-indent-hook 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (defmacro edebug-storing-offsets (point &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (` (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (edebug-store-before-offset (, point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (edebug-store-after-offset (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
851 ;;; Reader for Emacs Lisp.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
852
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ;; Uses edebug-next-token-class (and edebug-skip-whitespace) above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (defconst edebug-read-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 '((symbol . edebug-read-symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (lparen . edebug-read-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (string . edebug-read-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (quote . edebug-read-quote)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
860 (backquote . edebug-read-backquote)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
861 (comma . edebug-read-comma)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (lbracket . edebug-read-vector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (hash . edebug-read-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (defun edebug-read-storing-offsets (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (let ((class (edebug-next-token-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 edebug-read-dotted-list) ; see edebug-store-after-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (edebug-storing-offsets (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (if (setq func (assq class edebug-read-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (funcall (cdr func) stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ;; anything else, just read it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (edebug-original-read stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (defun edebug-read-symbol (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (edebug-original-read stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ;; loses for escaped chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (if (not (eq (aref edebug-read-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (preceding-char)) 'symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (defun edebug-read-string (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (edebug-original-read stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (if (/= (preceding-char) ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (defun edebug-read-quote (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ;; Turn 'thing into (quote thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (edebug-storing-offsets (point) 'quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (edebug-read-storing-offsets stream)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
898 (defun edebug-read-backquote (stream)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
899 ;; Turn `thing into (\` thing)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
900 (let ((opoint (point)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
901 (forward-char 1)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
902 ;; Generate the same structure of offsets we would have
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
903 ;; if the resulting list appeared verbatim in the input text.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
904 (edebug-storing-offsets opoint
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
905 (list
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
906 (edebug-storing-offsets opoint '\`)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
907 (edebug-read-storing-offsets stream)))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
908
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
909 (defvar edebug-read-backquote-new nil
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
910 "Non-nil if reading the inside of a new-style backquote with no parens around it.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
911 Value of nil means reading the inside of an old-style backquote construct
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
912 which is surrounded by an extra set of parentheses.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
913 This controls how we read comma constructs.")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
914
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
915 (defun edebug-read-comma (stream)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
916 ;; Turn ,thing into (\, thing). Handle ,@ and ,. also.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
917 (let ((opoint (point)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
918 (forward-char 1)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
919 (let ((symbol '\,))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
920 (cond ((eq (following-char) ?\.)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
921 (setq symbol '\,\.)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
922 (forward-char 1))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
923 ((eq (following-char) ?\@)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
924 (setq symbol '\,@)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
925 (forward-char 1)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
926 ;; Generate the same structure of offsets we would have
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
927 ;; if the resulting list appeared verbatim in the input text.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
928 (if edebug-read-backquote-new
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
929 (list
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
930 (edebug-storing-offsets opoint symbol)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
931 (edebug-read-storing-offsets stream))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
932 (edebug-storing-offsets opoint symbol)))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
933
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (defun edebug-read-function (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;; Turn #'thing into (function thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (if (/= ?\' (following-char)) (edebug-syntax-error "Bad char"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (edebug-storing-offsets (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (if (featurep 'cl) 'function* 'function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (edebug-read-storing-offsets stream)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (defun edebug-read-list (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (forward-char 1) ; skip \(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (let ((elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (while (not (memq (edebug-next-token-class) '(rparen dot)))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
949 (if (eq (edebug-next-token-class) 'backquote)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
950 (let ((edebug-read-backquote-new (not (null elements)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
951 (opoint (point)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
952 (if edebug-read-backquote-new
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
953 (setq elements (cons (edebug-read-backquote stream) elements))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
954 (forward-char 1) ; Skip backquote.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
955 ;; Call edebug-storing-offsets here so that we
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
956 ;; produce the same offsets we would have had
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
957 ;; if the backquote were an ordinary symbol.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
958 (setq elements (cons (edebug-storing-offsets opoint '\`)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
959 elements))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
960 (setq elements (cons (edebug-read-storing-offsets stream) elements))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (setq elements (nreverse elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (if (eq 'dot (edebug-next-token-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (let (dotted-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (forward-char 1) ; skip \.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (setq dotted-form (edebug-read-storing-offsets stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 elements (nconc elements dotted-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (if (not (eq (edebug-next-token-class) 'rparen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (edebug-syntax-error "Expected `)'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (setq edebug-read-dotted-list (listp dotted-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 elements)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (forward-char 1) ; skip \)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (defun edebug-read-vector (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (forward-char 1) ; skip \[
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (let ((elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (while (not (eq 'rbracket (edebug-next-token-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (setq elements (cons (edebug-read-storing-offsets stream) elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (apply 'vector (nreverse elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (forward-char 1) ; skip \]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
985 ;;; Cursors for traversal of list and vector elements with offsets.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (defvar edebug-dotted-spec nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (defun edebug-new-cursor (expressions offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 ;; Return a new cursor for EXPRESSIONS with OFFSETS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (if (vectorp expressions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (setq expressions (append expressions nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (cons expressions offsets))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (defsubst edebug-set-cursor (cursor expressions offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 ;; Set the CURSOR's EXPRESSIONS and OFFSETS to the given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ;; Return the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (setcar cursor expressions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (setcdr cursor offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 '(defun edebug-copy-cursor (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 ;; Copy the cursor using the same object and offsets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (cons (car cursor) (cdr cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (defsubst edebug-cursor-expressions (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (car cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (defsubst edebug-cursor-offsets (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (cdr cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (defsubst edebug-empty-cursor (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 ;; Return non-nil if CURSOR is empty - meaning no more elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (null (car cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (defsubst edebug-top-element (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 ;; Return the top element at the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ;; Assumes not empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (car (car cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (defun edebug-top-element-required (cursor &rest error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ;; Check if a dotted form is required.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (if edebug-dotted-spec (edebug-no-match cursor "Dot expected."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 ;; Check if there is at least one more argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (if (edebug-empty-cursor cursor) (apply 'edebug-no-match cursor error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 ;; Return that top element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (edebug-top-element cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (defsubst edebug-top-offset (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 ;; Return the top offset pair corresponding to the top element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (car (cdr cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (defun edebug-move-cursor (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 ;; Advance and return the cursor to the next element and offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 ;; throw no-match if empty before moving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ;; This is a violation of the cursor encapsulation, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 ;; there is plenty of that going on while matching.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 ;; The following test should always fail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (if (edebug-empty-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (edebug-no-match cursor "Not enough arguments."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (setcar cursor (cdr (car cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (setcdr cursor (cdr (cdr cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (defun edebug-before-offset (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 ;; Return the before offset of the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 ;; If there is nothing left in the offsets,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 ;; return one less than the offset itself,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 ;; which is the after offset for a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (let ((offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (if (consp offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (car (car offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (1- offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (defun edebug-after-offset (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 ;; Return the after offset of the cursor object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (let ((offset (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (while (consp offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (setq offset (cdr offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1062 ;;; The Parser
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1063
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1064 ;; The top level function for parsing forms is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1065 ;; edebug-read-and-maybe-wrap-form; it calls all the rest. It checks the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1066 ;; syntax a bit and leaves point at any error it finds, but otherwise
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1067 ;; should appear to work like eval-defun.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1068
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1069 ;; The basic plan is to surround each expression with a call to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1070 ;; the edebug debugger together with indexes into a table of positions of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1071 ;; all expressions. Thus an expression "exp" becomes:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1072
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1073 ;; (edebug-after (edebug-before 1) 2 exp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1074
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1075 ;; When this is evaluated, first point is moved to the beginning of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1076 ;; exp at offset 1 of the current function. The expression is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1077 ;; evaluated, which may cause more edebug calls, and then point is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1078 ;; moved to offset 2 after the end of exp.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1079
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1080 ;; The highest level expressions of the function are wrapped in a call to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1081 ;; edebug-enter, which supplies the function name and the actual
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1082 ;; arguments to the function. See functions edebug-enter, edebug-before,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
1083 ;; and edebug-after for more details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 ;; Dynamically bound vars, left unbound, but globally declared.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 ;; This is to quiet the byte compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 ;; Window data of the highest definition being wrapped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 ;; This data is shared by all embedded definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (defvar edebug-top-window-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (defvar edebug-&optional)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (defvar edebug-&rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (defvar edebug-gate nil) ;; whether no-match forces an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (defconst edebug-def-name nil) ; name of definition, used by interactive-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (defconst edebug-old-def-name nil) ; previous name of containing definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (defconst edebug-error-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (defconst edebug-best-error nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (defun edebug-read-and-maybe-wrap-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 ;; Read a form and wrap it with edebug calls, if the conditions are right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 ;; Here we just catch any no-match not caught below and signal an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 ;; Run the setup hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (run-hooks 'edebug-setup-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (setq edebug-setup-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (let (result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 edebug-top-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 edebug-def-name;; make sure it is locally nil
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1114 ;; I don't like these here!!
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 edebug-&optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 edebug-&rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 edebug-gate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ;; Do this once here instead of several times.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (max-lisp-eval-depth (+ 800 max-lisp-eval-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (max-specpdl-size (+ 2000 max-specpdl-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (setq no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (setq result (edebug-read-and-maybe-wrap-form1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (if no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (apply 'edebug-syntax-error no-match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (defun edebug-read-and-maybe-wrap-form1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (let (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 def-kind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 defining-form-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 def-name
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1138 ;; These offset things don't belong here, but to support recursive
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 ;; calls to edebug-read, they need to be here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 edebug-offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 edebug-offsets-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 edebug-current-offset ; reset to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (if (and (eq 'lparen (edebug-next-token-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (eq 'symbol (progn (forward-char 1) (edebug-next-token-class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 ;; Find out if this is a defining form from first symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (setq def-kind (edebug-original-read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 spec (and (symbolp def-kind) (get-edebug-spec def-kind))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 defining-form-p (and (listp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (eq '&define (car spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 ;; This is incorrect in general!! But OK most of the time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 def-name (if (and defining-form-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (eq 'name (car (cdr spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (eq 'symbol (edebug-next-token-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (edebug-original-read (current-buffer))))))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1157 ;;;(message "all defs: %s all forms: %s" edebug-all-defs edebug-all-forms)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (defining-form-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (if (or edebug-all-defs edebug-all-forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 ;; If it is a defining form and we are edebugging defs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 ;; then let edebug-list-form start it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (let ((cursor (edebug-new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (list (edebug-read-storing-offsets (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (list edebug-offsets))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (edebug-before-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (1- (edebug-after-offset cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (list (cons (symbol-name def-kind) (cdr spec))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 ;; Not edebugging this form, so reset the symbol's edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;; property to be just a marker at the definition's source code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;; This only works for defs with simple names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (put def-name 'edebug (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 ;; Also nil out dependent defs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 '(mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (lambda (def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (put def-name 'edebug nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (get def-name 'edebug-dependents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (edebug-read-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 ;; If all forms are being edebugged, explicitly wrap it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (edebug-all-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (let ((cursor (edebug-new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (list (edebug-read-storing-offsets (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (list edebug-offsets))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (edebug-before-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (edebug-after-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;; Not a defining form, and not edebugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (t (edebug-read-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (defvar edebug-def-args) ; args of defining form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (defvar edebug-def-interactive) ; is it an emacs interactive function?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (defvar edebug-inside-func) ;; whether code is inside function context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 ;; Currently def-form sets this to nil; def-body sets it to t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (defun edebug-interactive-p-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 ;; Return a unique symbol for the variable used to store the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 ;; status of interactive-p for this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (intern (format "edebug-%s-interactive-p" edebug-def-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (defun edebug-wrap-def-body (forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 "Wrap the FORMS of a definition body."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (if edebug-def-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (` (let (((, (edebug-interactive-p-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (interactive-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (, (edebug-make-enter-wrapper forms))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (edebug-make-enter-wrapper forms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (defun edebug-make-enter-wrapper (forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 ;; Generate the enter wrapper for some forms of a definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ;; This is not to be used for the body of other forms, e.g. `while',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 ;; since it wraps the list of forms with a call to `edebug-enter'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 ;; Uses the dynamically bound vars edebug-def-name and edebug-def-args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 ;; Do this after parsing since that may find a name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (` (edebug-enter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (quote (, edebug-def-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (, (if edebug-inside-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (` (list (,@
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1232 ;; Doesn't work with more than one def-body!!
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ;; But the list will just be reversed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (nreverse edebug-def-args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 'nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (function (lambda () (,@ forms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (defvar edebug-form-begin-marker) ; the mark for def being instrumented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (defvar edebug-offset-index) ; the next available offset index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (defvar edebug-offset-list) ; the list of offset positions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (defun edebug-inc-offset (offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 ;; modifies edebug-offset-index and edebug-offset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 ;; accesses edebug-func-marc and buffer point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 edebug-offset-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (setq edebug-offset-list (cons (- offset edebug-form-begin-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 edebug-offset-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 edebug-offset-index (1+ edebug-offset-index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (defun edebug-make-before-and-after-form (before-index form after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 ;; Return the edebug form for the current function at offset BEFORE-INDEX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 ;; given FORM. Looks like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 ;; (edebug-after (edebug-before BEFORE-INDEX) AFTER-INDEX FORM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 ;; Also increment the offset index for subsequent use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 ;; if (not edebug-stop-before-symbols) and form is a symbol,
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1261 ;; then don't call edebug-before.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (list 'edebug-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (list 'edebug-before before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 after-index form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (defun edebug-make-after-form (form after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ;; Like edebug-make-before-and-after-form, but only after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (list 'edebug-after 0 after-index form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (defun edebug-unwrap (sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 "Return the unwrapped SEXP or return it as is if it is not wrapped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 The SEXP might be the result of wrapping a body, which is a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 expressions; a `progn' form will be returned enclosing these forms."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (if (consp sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 ((eq 'edebug-after (car sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (nth 3 sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ((eq 'edebug-enter (car sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (let ((forms (nthcdr 2 (nth 1 (nth 3 sexp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (if (> (length forms) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (cons 'progn forms) ;; could return (values forms) instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (car forms))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (t sexp);; otherwise it is not wrapped, so just return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (defun edebug-unwrap* (sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 "Return the sexp recursively unwrapped."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (let ((new-sexp (edebug-unwrap sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (while (not (eq sexp new-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (setq sexp new-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 new-sexp (edebug-unwrap sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (if (consp new-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (mapcar 'edebug-unwrap* new-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 new-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (defun edebug-defining-form (cursor form-begin form-end speclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 ;; Process the defining form, starting outside the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 ;; The speclist is a generated list spec that looks like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 ;; (("def-symbol" defining-form-spec-sans-&define))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ;; Skip the first offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (edebug-set-cursor cursor (edebug-cursor-expressions cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (cdr (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 form-begin (1- form-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 speclist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (defun edebug-make-form-wrapper (cursor form-begin form-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 &optional speclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 ;; Wrap a form, usually a defining form, but any evaluated one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 ;; If speclist is non-nil, this is being called by edebug-defining-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 ;; Otherwise it is being called from edebug-read-and-maybe-wrap-form1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 ;; This is a hack, but I havent figured out a simpler way yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (let* ((form-data-entry (edebug-get-form-data-entry form-begin form-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ;; Set this marker before parsing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (edebug-form-begin-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (if form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (edebug-form-data-begin form-data-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 ;; Buffer must be current-buffer for this to work:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (set-marker (make-marker) form-begin))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (let (edebug-offset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (edebug-offset-index 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 ;; For definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 ;; (edebug-containing-def-name edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 ;; Get name from form-data, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (edebug-old-def-name (edebug-form-data-name form-data-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 edebug-def-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 edebug-def-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 edebug-inside-func;; whether wrapped code executes inside a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (if speclist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (edebug-match cursor speclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 ;; else wrap as an enter-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (edebug-make-enter-wrapper (list (edebug-form cursor)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 ;; Set the name here if it was not set by edebug-make-enter-wrapper.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 ;; Add this def as a dependent of containing def. Buggy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 '(if (and edebug-containing-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (not (get edebug-containing-def-name 'edebug-dependents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (put edebug-containing-def-name 'edebug-dependents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (cons edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (get edebug-containing-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 'edebug-dependents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 ;; Create a form-data-entry or modify existing entry's markers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 ;; In the latter case, pointers to the entry remain eq.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (if (not form-data-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (setq form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (edebug-make-form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 edebug-form-begin-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 ;; Buffer must be current-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (set-marker (make-marker) form-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (edebug-set-form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 form-data-entry edebug-def-name ;; in case name is changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 form-begin form-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 ;; (message "defining: %s" edebug-def-name) (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (edebug-make-top-form-data-entry form-data-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (message "Edebug: %s" edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 ;;(debug edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 ;; Destructively reverse edebug-offset-list and make vector from it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (setq edebug-offset-list (vconcat (nreverse edebug-offset-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 ;; Side effects on the property list of edebug-def-name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (edebug-clear-frequency-count edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (edebug-clear-coverage edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 ;; Set up the initial window data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (if (not edebug-top-window-data) ;; if not already set, do it now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (let ((window ;; Find the best window for this buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (or (get-buffer-window (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (setq edebug-top-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (cons window (window-start window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 ;; Store the edebug data in symbol's property list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (put edebug-def-name 'edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 ;; A struct or vector would be better here!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (list edebug-form-begin-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 nil ; clear breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 edebug-offset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 edebug-top-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (defun edebug-clear-frequency-count (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 ;; Create initial frequency count vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 ;; For each stop point, the counter is incremented each time it is visited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (put name 'edebug-freq-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (make-vector (length edebug-offset-list) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (defun edebug-clear-coverage (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 ;; Create initial coverage vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 ;; Only need one per expression, but it is simpler to use stop points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (put name 'edebug-coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (make-vector (length edebug-offset-list) 'unknown)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (defun edebug-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 ;; Return the instrumented form for the following form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 ;; Add the point offsets to the edebug-offset-list for the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (let* ((form (edebug-top-element-required cursor "Expected form"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (offset (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 ((consp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 ;; The first offset for a list form is for the list form itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (if (eq 'quote (car form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (let* ((head (car form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (spec (and (symbolp head) (get-edebug-spec head)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (new-cursor (edebug-new-cursor form offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 ;; Find out if this is a defining form from first symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 ;; An indirect spec would not work here, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (if (and (consp spec) (eq '&define (car spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (edebug-defining-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (car offset);; before the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (edebug-after-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (cons (symbol-name head) (cdr spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 ;; Wrap a regular form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (edebug-make-before-and-after-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (edebug-inc-offset (car offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (edebug-list-form new-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 ;; After processing the list form, the new-cursor is left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 ;; with the offset after the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (edebug-inc-offset (edebug-cursor-offsets new-cursor))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 ((symbolp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (cond
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1450 ;; Check for constant symbols that don't get wrapped.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 ((or (memq form '(t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (and (fboundp 'edebug-keywordp) (edebug-keywordp form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 ;; This option may go away.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (edebug-stop-before-symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (edebug-make-before-and-after-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (edebug-inc-offset (car offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (edebug-inc-offset (cdr offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (t ;; just a variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (edebug-make-after-form form (edebug-inc-offset (cdr offset))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 ;; Anything else is self-evaluating.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (t form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (edebug-move-cursor cursor))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (defsubst edebug-forms (cursor) (edebug-match cursor '(&rest form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (defsubst edebug-sexps (cursor) (edebug-match cursor '(&rest sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (defsubst edebug-list-form-args (head cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 ;; Process the arguments of a list form given that head of form is a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 ;; Helper for edebug-list-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (let ((spec (get-edebug-spec head)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 ((consp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 ;; It is a speclist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (let (edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 edebug-error-point);; This may not be needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (edebug-match-sublist cursor spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 ((eq t spec) (edebug-forms cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 ((eq 0 spec) (edebug-sexps cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 ((symbolp spec) (funcall spec cursor));; Not used by edebug,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ; but leave it in for compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 ;; No edebug-form-spec provided.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 ((edebug-macrop head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (if edebug-eval-macro-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (edebug-forms cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (edebug-sexps cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (t ;; Otherwise it is a function call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (edebug-forms cursor)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (defun edebug-list-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 ;; Return an instrumented form built from the list form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 ;; The after offset will be left in the cursor after processing the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (let ((head (edebug-top-element-required cursor "Expected elements"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ;; Prevent backtracking whenever instrumenting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 ;; A list form is never optional because it matches anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (edebug-&optional nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (edebug-&rest nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;; Skip the first offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (edebug-set-cursor cursor (edebug-cursor-expressions cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (cdr (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ((null head) nil) ; () is legal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 ((symbolp head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 ((null head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (edebug-syntax-error "nil head"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 ((eq head 'interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 ;; Special case: replace (interactive-p) with variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (setq edebug-def-interactive 'check-it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (edebug-interactive-p-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (cons head (edebug-list-form-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 head (edebug-move-cursor cursor))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 ((consp head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (if (and (listp head) (eq (car head) ',))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (edebug-match cursor '(("," def-form) body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 ;; Process anonymous function and args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 ;; This assumes no anonymous macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (edebug-match-specs cursor '(lambda-expr body) 'edebug-match-specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (t (edebug-syntax-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 "Head of list form must be a symbol or lambda expression.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1539 ;;; Matching of specs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (defvar edebug-after-dotted-spec nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (defvar edebug-matching-depth 0) ;; initial value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (defconst edebug-max-depth 150) ;; maximum number of matching recursions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1547 ;;; Failure to match
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1548
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 ;; This throws to no-match, if there are higher alternatives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 ;; Otherwise it signals an error. The place of the error is found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 ;; with the two before- and after-offset functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (defun edebug-no-match (cursor &rest edebug-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 ;; Throw a no-match, or signal an error immediately if gate is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 ;; Remember this point in case we need to report this error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (setq edebug-error-point (or edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (edebug-before-offset cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 edebug-best-error (or edebug-best-error edebug-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (if (and edebug-gate (not edebug-&optional))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (if edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (goto-char edebug-error-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (apply 'edebug-syntax-error edebug-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (funcall 'throw 'no-match edebug-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (defun edebug-match (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 ;; Top level spec matching function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 ;; Used also at each lower level of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (let (edebug-&optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 edebug-&rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (edebug-gate edebug-gate) ;; locally bound to limit effect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (edebug-match-specs cursor specs 'edebug-match-specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (defun edebug-match-one-spec (cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ;; Match one spec, which is not a keyword &-spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 ((symbolp spec) (edebug-match-symbol cursor spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 ((vectorp spec) (edebug-match cursor (append spec nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ((stringp spec) (edebug-match-string cursor spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 ((listp spec) (edebug-match-list cursor spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (defun edebug-match-specs (cursor specs remainder-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 ;; Append results of matching the list of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 ;; The first spec is handled and the remainder-handler handles the rest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (let ((edebug-matching-depth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (if (> edebug-matching-depth edebug-max-depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (error "too deep - perhaps infinite loop in spec?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (1+ edebug-matching-depth))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 ((null specs) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 ;; Is the spec dotted?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 ((atom specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (let ((edebug-dotted-spec t));; Containing spec list was dotted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (edebug-match-specs cursor (list specs) remainder-handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 ;; Is the form dotted?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 ((not (listp (edebug-cursor-expressions cursor)));; allow nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (if (not edebug-dotted-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (edebug-no-match cursor "Dotted spec required."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 ;; Cancel dotted spec and dotted form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (let ((edebug-dotted-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (this-form (edebug-cursor-expressions cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (this-offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 ;; Wrap the form in a list, (by changing the cursor??)...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (edebug-set-cursor cursor (list this-form) this-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 ;; and process normally, then unwrap the result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (car (edebug-match-specs cursor specs remainder-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (t;; Process normally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (let* ((spec (car specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (first-char (and (symbolp spec) (aref (symbol-name spec) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 ;;(message "spec = %s first char = %s" spec first-char) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (nconc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 ((eq ?& first-char);; "&" symbols take all following specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (funcall (get-edebug-spec spec) cursor (cdr specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ((eq ?: first-char);; ":" symbols take one following spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (setq rest (cdr (cdr specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (funcall (get-edebug-spec spec) cursor (car (cdr specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (t;; Any other normal spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (setq rest (cdr specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (edebug-match-one-spec cursor spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (funcall remainder-handler cursor rest remainder-handler)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 ;; Define specs for all the symbol specs with functions used to process them.
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1636 ;; Perhaps we shouldn't be doing this with edebug-form-specs since the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 ;; user may want to define macros or functions with the same names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 ;; We could use an internal obarray for these primitive specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (function (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (put (car pair) 'edebug-form-spec (cdr pair))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 '((&optional . edebug-match-&optional)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (&rest . edebug-match-&rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (&or . edebug-match-&or)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (form . edebug-match-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (sexp . edebug-match-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (body . edebug-match-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (&define . edebug-match-&define)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (name . edebug-match-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (:name . edebug-match-colon-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (arg . edebug-match-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (def-body . edebug-match-def-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (def-form . edebug-match-def-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 ;; Less frequently used:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 ;; (function . edebug-match-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (lambda-expr . edebug-match-lambda-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (&not . edebug-match-&not)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (&key . edebug-match-&key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (place . edebug-match-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (gate . edebug-match-gate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 ;; (nil . edebug-match-nil) not this one - special case it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (defun edebug-match-symbol (cursor symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 ;; Match a symbol spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (let* ((spec (get-edebug-spec symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (if (consp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 ;; It is an indirect spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (edebug-match cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 ;; Otherwise it should be the symbol name of a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 ;; There could be a bug here - maybe need to do edebug-match bindings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (funcall spec cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 ((null symbol) ;; special case this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (edebug-match-nil cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 ((fboundp symbol) ; is it a predicate?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (let ((sexp (edebug-top-element-required cursor "Expected" symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 ;; Special case for edebug-`.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (if (and (listp sexp) (eq (car sexp) ',))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (edebug-match cursor '(("," def-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (if (not (funcall symbol sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (edebug-no-match cursor symbol "failed"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (list sexp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (t (error "%s is not a form-spec or function" symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (defun edebug-match-sexp (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (list (prog1 (edebug-top-element-required cursor "Expected sexp")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (edebug-move-cursor cursor))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (defun edebug-match-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (list (edebug-form cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (defalias 'edebug-match-place 'edebug-match-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 ;; Currently identical to edebug-match-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 ;; This is for common lisp setf-style place arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (defsubst edebug-match-body (cursor) (edebug-forms cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (defun edebug-match-&optional (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 ;; Keep matching until one spec fails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (edebug-&optional-wrapper cursor specs 'edebug-&optional-wrapper))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (defun edebug-&optional-wrapper (cursor specs remainder-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (let (result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (edebug-&optional specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (edebug-gate nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (this-form (edebug-cursor-expressions cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (this-offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (if (null (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (edebug-match-specs cursor specs remainder-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 ;; Returning nil means no no-match was thrown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 ;; no-match, but don't fail; just reset cursor and return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (edebug-set-cursor cursor this-form this-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (defun edebug-&rest-wrapper (cursor specs remainder-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (if (null specs) (setq specs edebug-&rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 ;; Reuse the &optional handler with this as the remainder handler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (edebug-&optional-wrapper cursor specs remainder-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (defun edebug-match-&rest (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 ;; Repeatedly use specs until failure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (let ((edebug-&rest specs) ;; remember these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 edebug-error-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (edebug-&rest-wrapper cursor specs 'edebug-&rest-wrapper)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (defun edebug-match-&or (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 ;; Keep matching until one spec succeeds, and return its results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 ;; If none match, fail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 ;; This needs to be optimized since most specs spend time here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (let ((original-specs specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (this-form (edebug-cursor-expressions cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 (this-offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (catch 'matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (while specs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (throw 'matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (let (edebug-gate ;; only while matching each spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 edebug-error-point)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1754 ;; Doesn't support e.g. &or symbolp &rest form
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (edebug-match-one-spec cursor (car specs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 ;; Match failed, so reset and try again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (setq specs (cdr specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 ;; Reset the cursor for the next match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (edebug-set-cursor cursor this-form this-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 ;; All failed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (apply 'edebug-no-match cursor "Expected one of" original-specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (defun edebug-match-&not (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 ;; If any specs match, then fail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (if (null (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 (let ((edebug-gate nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (edebug-match-&or cursor specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 ;; This means something matched, so it is a no match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (edebug-no-match cursor "Unexpected"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 ;; This means nothing matched, so it is OK.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 nil) ;; So, return nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (def-edebug-spec &key edebug-match-&key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (defun edebug-match-&key (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 ;; Following specs must look like (<name> <spec>) ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 ;; where <name> is the name of a keyword, and spec is its spec.
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1783 ;; This really doesn't save much over the expanded form and takes time.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (edebug-match-&rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (cons '&or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (mapcar (function (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (vector (format ":%s" (car pair))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (car (cdr pair)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (defun edebug-match-gate (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 ;; Simply set the gate to prevent backtracking at this level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (setq edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 (defun edebug-match-list (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 ;; The spec is a list, but what kind of list, and what context?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (if edebug-dotted-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 ;; After dotted spec but form did not contain dot,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 ;; so match list spec elements as if spliced in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (let ((edebug-dotted-spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (edebug-match-specs cursor specs 'edebug-match-specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 ;; If it matched, really clear the dotted-spec flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (setq edebug-dotted-spec nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (let ((spec (car specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (form (edebug-top-element-required cursor "Expected" specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 ((eq 'quote spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (let ((spec (car (cdr specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 ((symbolp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 ;; Special case: spec quotes a symbol to match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 ;; Change in future. Use "..." instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (if (not (eq spec form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (edebug-no-match cursor "Expected" spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (setq edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (error "Bad spec: %s" specs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 ((listp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (list (edebug-match-sublist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 ;; First offset is for the list form itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 ;; Treat nil as empty list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (edebug-new-cursor form (cdr (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (edebug-move-cursor cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 ((and (eq 'vector spec) (vectorp form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 ;; Special case: match a vector with the specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 (let ((result (edebug-match-sublist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (edebug-new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 form (cdr (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 (cdr specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (list (apply 'vector result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (t (edebug-no-match cursor "Expected" specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (defun edebug-match-sublist (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 ;; Match a sublist of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (let (edebug-&optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 ;;edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 ;;edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 ;; match with edebug-match-specs so edebug-best-error is not bound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (edebug-match-specs cursor specs 'edebug-match-specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (if (not (edebug-empty-cursor cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 (if edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 (apply 'edebug-no-match cursor edebug-best-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 ;; A failed &rest or &optional spec may leave some args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (edebug-no-match cursor "Failed matching" specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (defun edebug-match-string (cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (let ((sexp (edebug-top-element-required cursor "Expected" spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (if (not (eq (intern spec) sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (edebug-no-match cursor "Expected" spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 ;; Since it matched, failure means immediate error, unless &optional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (setq edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (list sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (defun edebug-match-nil (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 ;; There must be nothing left to match a nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (if (not (edebug-empty-cursor cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (edebug-no-match cursor "Unmatched argument(s)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (defun edebug-match-function (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (error "Use function-form instead of function in edebug spec"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (defun edebug-match-&define (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 ;; Match a defining form.
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1887 ;; Normally, &define is interpreted specially other places.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 ;; This should only be called inside of a spec list to match the remainder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 ;; of the current list. e.g. ("lambda" &define args def-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (edebug-before-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 ;; Find the last offset in the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (let ((offsets (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (while (consp offsets) (setq offsets (cdr offsets)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (defun edebug-match-lambda-expr (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 ;; The expression must be a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 ;; This will match any list form that begins with a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 ;; that has an edebug-form-spec beginning with &define. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 ;; practice, only lambda expressions should be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 ;; I could add a &lambda specification to avoid confusion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 (let* ((sexp (edebug-top-element-required
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 cursor "Expected lambda expression"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (offset (edebug-top-offset cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (head (and (consp sexp) (car sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (spec (and (symbolp head) (get-edebug-spec head)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (edebug-inside-func nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 ;; Find out if this is a defining form from first symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (if (and (consp spec) (eq '&define (car spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (edebug-defining-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (edebug-new-cursor sexp offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (car offset);; before the sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (edebug-after-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (cons (symbol-name head) (cdr spec))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (edebug-move-cursor cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (edebug-no-match cursor "Expected lambda expression")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (defun edebug-match-name (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 ;; Set the edebug-def-name bound in edebug-defining-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (let ((name (edebug-top-element-required cursor "Expected name")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 ;; Maybe strings and numbers could be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (if (not (symbolp name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (edebug-no-match cursor "Symbol expected for name of definition"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (if edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 ;; Construct a new name by appending to previous name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (intern (format "%s@%s" edebug-def-name name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (list name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (defun edebug-match-colon-name (cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 ;; Set the edebug-def-name to the spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (if edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 ;; Construct a new name by appending to previous name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 (intern (format "%s@%s" edebug-def-name spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (defun edebug-match-arg (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 ;; set the def-args bound in edebug-defining-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (let ((edebug-arg (edebug-top-element-required cursor "Expected arg")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (if (or (not (symbolp edebug-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (edebug-lambda-list-keywordp edebug-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (edebug-no-match cursor "Bad argument:" edebug-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (setq edebug-def-args (cons edebug-arg edebug-def-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (list edebug-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (defun edebug-match-def-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 ;; Like form but the form is wrapped in edebug-enter form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 ;; The form is assumed to be executing outside of the function context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 ;; This is a hack for now, since a def-form might execute inside as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 ;; Not to be used otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (let ((edebug-inside-func nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (list (edebug-make-enter-wrapper (list (edebug-form cursor))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (defun edebug-match-def-body (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 ;; Like body but body is wrapped in edebug-enter form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 ;; The body is assumed to be executing inside of the function context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 ;; Not to be used otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (let ((edebug-inside-func t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (list (edebug-wrap-def-body (edebug-forms cursor)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1974 ;;;; Edebug Form Specs
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1975 ;;; ==========================================================
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1976 ;;; See cl-specs.el for common lisp specs.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1977
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1978 ;;;;* Spec for def-edebug-spec
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
1979 ;;; Out of date.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (defun edebug-spec-p (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 "Return non-nil if OBJECT is a symbol with an edebug-form-spec property."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 (and (symbolp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (get object 'edebug-form-spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (def-edebug-spec def-edebug-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 ;; Top level is different from lower levels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (&define :name edebug-spec name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 &or "nil" edebug-spec-p "t" "0" (&rest edebug-spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (def-edebug-spec edebug-spec-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 ;; A list must have something in it, or it is nil, a symbolp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 ((edebug-spec . [&or nil edebug-spec])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (def-edebug-spec edebug-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (&or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (vector &rest edebug-spec) ; matches a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 ("vector" &rest edebug-spec) ; matches a vector spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 ("quote" symbolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 edebug-spec-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 stringp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 [edebug-lambda-list-keywordp &rest edebug-spec]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 ;; [edebug-keywordp gate edebug-spec] ;; need edebug-keywordp for this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 edebug-spec-p ;; Including all the special ones e.g. form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 symbolp;; a predicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2009 ;;;* Emacs special forms and some functions.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 ;; quote expects only one argument, although it allows any number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (def-edebug-spec quote sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 ;; The standard defining forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (def-edebug-spec defconst defvar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (def-edebug-spec defvar (symbolp &optional form stringp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (def-edebug-spec defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (&define name lambda-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 [&optional stringp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 [&optional ("interactive" interactive)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (def-edebug-spec defmacro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (&define name lambda-list def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2026 (def-edebug-spec arglist lambda-list) ;; deprecated - use lambda-list.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (def-edebug-spec lambda-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (([&rest arg]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 [&optional ["&optional" arg &rest arg]]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 &optional ["&rest" arg]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 (def-edebug-spec interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (&optional &or stringp def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 ;; A function-form is for an argument that may be a function or a form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 ;; This specially recognizes anonymous functions quoted with quote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (def-edebug-spec function-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 ;; form at the end could also handle "function",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 ;; but recognize it specially to avoid wrapping function forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 (&or ([&or "quote" "function"] &or symbolp lambda-expr) form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 ;; function expects a symbol or a lambda or macro expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 ;; A macro is allowed by Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 (def-edebug-spec function (&or symbolp lambda-expr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 ;; lambda is a macro in emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 (def-edebug-spec lambda (&define lambda-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 [&optional stringp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 [&optional ("interactive" interactive)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 ;; A macro expression is a lambda expression with "macro" prepended.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (def-edebug-spec macro (&define "lambda" lambda-list def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 ;; (def-edebug-spec anonymous-form ((&or ["lambda" lambda] ["macro" macro])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 ;; Standard functions that take function-forms arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (def-edebug-spec mapcar (function-form form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 (def-edebug-spec mapconcat (function-form form form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (def-edebug-spec mapatoms (function-form &optional form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (def-edebug-spec apply (function-form &rest form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (def-edebug-spec funcall (function-form &rest form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (def-edebug-spec let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 ((&rest &or (symbolp &optional form) symbolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (def-edebug-spec let* let)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (def-edebug-spec setq (&rest symbolp form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (def-edebug-spec setq-default setq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (def-edebug-spec cond (&rest (&rest form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 (def-edebug-spec condition-case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (symbolp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 &rest (symbolp body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (def-edebug-spec \` (backquote-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 ;; Supports quotes inside backquotes,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 ;; but only at the top level inside unquotes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (def-edebug-spec backquote-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (&or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 ([&or "," ",@"] &or ("quote" backquote-form) form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 (backquote-form &rest backquote-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 ;; If you use dotted forms in backquotes, replace the previous line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 ;; with the following. This takes quite a bit more stack space, however.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 ;; (backquote-form . [&or nil backquote-form])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (vector &rest backquote-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 ;; Special version of backquote that instruments backquoted forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 ;; destined to be evaluated, usually as the result of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 ;; macroexpansion. Backquoted code can only have unquotes (, and ,@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 ;; in places where list forms are allowed, and predicates. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 ;; backquote is used in a macro, unquoted code that come from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 ;; arguments must be instrumented, if at all, with def-form not def-body.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 ;; We could assume that all forms (not nested in other forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 ;; in arguments of macros should be def-forms, whether or not the macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 ;; are defined with edebug-` but this would be expensive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 ;; ,@ might have some problems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (defalias 'edebug-\` '\`) ;; same macro as regular backquote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (def-edebug-spec edebug-\` (def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 ;; Assume immediate quote in unquotes mean backquote at next higher level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (def-edebug-spec , (&or ("quote" edebug-`) def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (def-edebug-spec ,@ (&define ;; so (,@ form) is never wrapped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 &or ("quote" edebug-`) def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 ;; New byte compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (def-edebug-spec defsubst defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (def-edebug-spec dont-compile t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (def-edebug-spec eval-when-compile t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (def-edebug-spec eval-and-compile t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 ;; Anything else?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 ;; Some miscellaneous specs for macros in public packages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 ;; Send me yours.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 ;; advice.el by Hans Chalupsky (hans@cs.buffalo.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (def-edebug-spec ad-dolist ((symbolp form &optional form) body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (def-edebug-spec defadvice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 (&define name ;; thing being advised.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 (name ;; class is [&or "before" "around" "after"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 ;; "activation" "deactivation"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 name ;; name of advice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 &rest sexp ;; optional position and flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 [&optional stringp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 [&optional ("interactive" interactive)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2144 ;;; The debugger itself
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (defvar edebug-active nil) ;; Non-nil when edebug is active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2148 ;;; add minor-mode-alist entry
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (or (assq 'edebug-active minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 (setq minor-mode-alist (cons (list 'edebug-active " *Debugging*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (defvar edebug-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 ;; Stack of active functions evaluated via edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 ;; Should be nil at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (defvar edebug-stack-depth -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 ;; Index of last edebug-stack item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (defvar edebug-offset-indices nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 ;; Stack of offset indices of visited edebug sexps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 ;; Should be nil at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 ;; Each function adds one cons. Top is modified with setcar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (defvar edebug-entered nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 ;; Non-nil if edebug has already been entered at this recursive edit level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 ;; This should stay nil at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 ;; Should these be options?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (defconst edebug-debugger 'edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 ;; Name of function to use for debugging when error or quit occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 ;; Set this to 'debug if you want to debug edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 ;; Dynamically bound variables, declared globally but left unbound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 (defvar edebug-function) ; the function being executed. change name!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 (defvar edebug-args) ; the arguments of the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 (defvar edebug-data) ; the edebug data for the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 (defvar edebug-value) ; the result of the expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (defvar edebug-after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 (defvar edebug-def-mark) ; the mark for the definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (defvar edebug-freq-count) ; the count of expression visits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (defvar edebug-coverage) ; the coverage results of each expression of function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (defvar edebug-buffer) ; which buffer the function is in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (defvar edebug-result) ; the result of the function call returned by body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (defvar edebug-outside-executing-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (defvar edebug-outside-defining-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (defvar edebug-execution-mode 'step) ; Current edebug mode set by user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (defvar edebug-next-execution-mode nil) ; Use once instead of initial mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (defvar edebug-outside-debug-on-error) ; the value of debug-on-error outside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (defvar edebug-outside-debug-on-quit) ; the value of debug-on-quit outside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 (defvar edebug-outside-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (defvar edebug-outside-post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (defvar edebug-outside-post-command-idle-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 ;; Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 (defvar pre-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (defvar post-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (defvar post-command-idle-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 (defvar cl-lexical-debug) ;; Defined in cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2210 ;;; Handling signals
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 (if (not (fboundp 'edebug-original-signal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 (defalias 'edebug-original-signal (symbol-function 'signal)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 ;; We should use advise for this!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (defun edebug-signal (edebug-signal-name edebug-signal-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 "Signal an error. Args are SIGNAL-NAME, and associated DATA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 A signal name is a symbol with an `error-conditions' property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 that is a list of condition names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 A handler for any of those names will get to handle this signal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 The symbol `error' should always be one of them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 DATA should be a list. Its elements are printed as part of the error message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 If the signal is handled, DATA is made available to the handler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 See `condition-case'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 This is the Edebug replacement for the standard `signal'. It should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 only be active while Edebug is. It checks `debug-on-error' to see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 whether it should call the debugger. When execution is resumed, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 error is signaled again."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 (if (and (listp debug-on-error) (memq edebug-signal-name debug-on-error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 (edebug 'error (cons edebug-signal-name edebug-signal-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 ;; If we reach here without another non-local exit, then send signal again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 ;; i.e. the signal is not continuable, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 (edebug-original-signal edebug-signal-name edebug-signal-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2238 ;;; Entering Edebug
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (defun edebug-enter (edebug-function edebug-args edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 ;; Entering FUNC. The arguments are ARGS, and the body is BODY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 ;; Setup edebug variables and evaluate BODY. This function is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 ;; when a function evaluated with edebug-eval-top-level-form is entered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 ;; Return the result of BODY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 ;; Is this the first time we are entering edebug since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 ;; lower-level recursive-edit command?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 ;; More precisely, this tests whether Edebug is currently active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 (if (not edebug-entered)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (let ((edebug-entered t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 ;; Binding max-lisp-eval-depth here is OK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 ;; but not inside an unwind-protect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 ;; Doing it here also keeps it from growing too large.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (max-lisp-eval-depth (+ 100 max-lisp-eval-depth)) ; too much??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (max-specpdl-size (+ 200 max-specpdl-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (debugger edebug-debugger) ; only while edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 (edebug-outside-debug-on-error debug-on-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 (edebug-outside-debug-on-quit debug-on-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 ;; Binding these may not be the right thing to do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 ;; We want to allow the global values to be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 (debug-on-error (or debug-on-error edebug-on-error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (debug-on-quit edebug-on-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 ;; Lexical bindings must be uncompiled for this to work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (cl-lexical-debug t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 ;; Save the outside value of executing macro. (here??)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
2269 (edebug-outside-executing-macro executing-kbd-macro)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 (edebug-outside-pre-command-hook pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 (edebug-outside-post-command-hook post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 (edebug-outside-post-command-idle-hook post-command-idle-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 (let (;; Don't keep reading from an executing kbd macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 ;; within edebug unless edebug-continue-kbd-macro is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 ;; non-nil. Again, local binding may not be best.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
2277 (executing-kbd-macro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
2278 (if edebug-continue-kbd-macro executing-kbd-macro))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 ;; Disable command hooks. This is essential when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 ;; a hook function is instrumented - to avoid infinite loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 ;; This may be more than we need, however.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 (pre-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 (post-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 (post-command-idle-hook nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 (setq edebug-execution-mode (or edebug-next-execution-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 edebug-initial-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 edebug-execution-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 edebug-next-execution-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 ;; Bind signal to edebug-signal only while Edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 (fset 'signal 'edebug-signal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 (edebug-enter edebug-function edebug-args edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 (fset 'signal (symbol-function 'edebug-original-signal))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 ;; Reset global variables in case outside value was changed.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
2296 (setq executing-kbd-macro edebug-outside-executing-macro
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 pre-command-hook edebug-outside-pre-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 post-command-hook edebug-outside-post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 post-command-idle-hook edebug-outside-post-command-idle-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (let* ((edebug-data (get edebug-function 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 (edebug-def-mark (car edebug-data)) ; mark at def start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 (edebug-freq-count (get edebug-function 'edebug-freq-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 (edebug-coverage (get edebug-function 'edebug-coverage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 (edebug-buffer (marker-buffer edebug-def-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 (edebug-stack (cons edebug-function edebug-stack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 (edebug-offset-indices (cons 0 edebug-offset-indices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (if (get edebug-function 'edebug-on-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 (setq edebug-execution-mode 'step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (if (eq (get edebug-function 'edebug-on-entry) 'temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 (put edebug-function 'edebug-on-entry nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 (if edebug-trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 (edebug-enter-trace edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 (funcall edebug-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (defun edebug-enter-trace (edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 (let ((edebug-stack-depth (1+ edebug-stack-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 edebug-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (edebug-print-trace-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 (format "%s args: %s" edebug-function edebug-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 (prog1 (setq edebug-result (funcall edebug-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 (edebug-print-trace-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 (format "%s result: %s" edebug-function edebug-result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (def-edebug-spec edebug-tracing (form body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 (defmacro edebug-tracing (msg &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 "Print MSG in *edebug-trace* before and after evaluating BODY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 The result of BODY is also printed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 (` (let ((edebug-stack-depth (1+ edebug-stack-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 edebug-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (edebug-print-trace-before (, msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (prog1 (setq edebug-result (progn (,@ body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 (edebug-print-trace-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (format "%s result: %s" (, msg) edebug-result))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (defun edebug-print-trace-before (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 "Function called to print trace info before expression evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 MSG is printed after `::::{ '."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (edebug-trace-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 edebug-trace-buffer "%s{ %s" (make-string edebug-stack-depth ?\:) msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 (defun edebug-print-trace-after (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 "Function called to print trace info after expression evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 MSG is printed after `::::} '."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 (edebug-trace-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 edebug-trace-buffer "%s} %s" (make-string edebug-stack-depth ?\:) msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 (defun edebug-slow-before (edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 ;; Debug current function given BEFORE position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 ;; Called from functions compiled with edebug-eval-top-level-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 ;; Return the before index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 (setcar edebug-offset-indices edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 ;; Increment frequency count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 (aset edebug-freq-count edebug-before-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 (1+ (aref edebug-freq-count edebug-before-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 (if (or (not (memq edebug-execution-mode '(Go-nonstop next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 (edebug-input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 (edebug-debugger edebug-before-index 'before nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (defun edebug-fast-before (edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 ;; Do nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 (defun edebug-slow-after (edebug-before-index edebug-after-index edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 ;; Debug current function given AFTER position and VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 ;; Called from functions compiled with edebug-eval-top-level-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 ;; Return VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (setcar edebug-offset-indices edebug-after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 ;; Increment frequency count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (aset edebug-freq-count edebug-after-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 (1+ (aref edebug-freq-count edebug-after-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (if edebug-test-coverage (edebug-update-coverage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 (if (and (eq edebug-execution-mode 'Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 (not (edebug-input-pending-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 ;; Just return result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 edebug-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (edebug-debugger edebug-after-index 'after edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 (defun edebug-fast-after (edebug-before-index edebug-after-index edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 ;; Do nothing but return the value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (defun edebug-run-slow ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 (defalias 'edebug-before 'edebug-slow-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 (defalias 'edebug-after 'edebug-slow-after))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 ;; This is not used, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 (defun edebug-run-fast ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 (defalias 'edebug-before 'edebug-fast-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 (defalias 'edebug-after 'edebug-fast-after))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 (edebug-run-slow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 (defun edebug-update-coverage ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 (let ((old-result (aref edebug-coverage edebug-after-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 ((eq 'ok-coverage old-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 ((eq 'unknown old-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 (aset edebug-coverage edebug-after-index edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 ;; Test if a different result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 ((not (eq edebug-value old-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 (aset edebug-coverage edebug-after-index 'ok-coverage)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 ;; Dynamically declared unbound variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 (defvar edebug-arg-mode) ; the mode, either before, after, or error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 (defvar edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 (defvar edebug-break-data) ; break data for current function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 (defvar edebug-break) ; whether a break occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 (defvar edebug-global-break) ; whether a global break occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 (defvar edebug-break-condition) ; whether the breakpoint is conditional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 (defvar edebug-break-result nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 (defvar edebug-global-break-result nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 (defun edebug-debugger (edebug-offset-index edebug-arg-mode edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 ;; Check breakpoints and pending input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 ;; If edebug display should be updated, call edebug-display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 ;; Return edebug-value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 (let* (;; This needs to be here since breakpoints may be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 (edebug-breakpoints (car (cdr edebug-data))) ; list of breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (edebug-break-data (assq edebug-offset-index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 (edebug-break-condition (car (cdr edebug-break-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 (edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 (if edebug-global-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (setq edebug-global-break-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 (eval edebug-global-break-condition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 (error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 (edebug-break))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 ;;; (edebug-trace "exp: %s" edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 ;; Test whether we should break.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (setq edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (or edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (and edebug-break-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 (or (not edebug-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (setq edebug-break-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 (eval edebug-break-condition))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 (if (and edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 (nth 2 edebug-break-data)) ; is it temporary?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 ;; Delete the breakpoint.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (setcdr edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (cons (delq edebug-break-data edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (cdr (cdr edebug-data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 ;; Display if mode is not go, continue, or Continue-fast
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 ;; or break, or input is pending,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 (if (or (not (memq edebug-execution-mode '(go continue Continue-fast)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 (edebug-input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (edebug-display)) ; <--------------- display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 edebug-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 ;; window-start now stored with each function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 ;;(defvar edebug-window-start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 ;; Remember where each buffers' window starts between edebug calls.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 ;; This is to avoid spurious recentering.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 ;; Does this still need to be buffer-local??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 ;;(setq-default edebug-window-start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 ;;(make-variable-buffer-local 'edebug-window-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 ;; Dynamically declared unbound vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (defvar edebug-point) ; the point in edebug buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (defvar edebug-outside-buffer) ; the current-buffer outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 (defvar edebug-outside-point) ; the point outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (defvar edebug-outside-mark) ; the mark outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 (defvar edebug-window-data) ; window and window-start for current function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 (defvar edebug-outside-windows) ; outside window configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 (defvar edebug-eval-buffer) ; for the evaluation list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (defvar edebug-outside-o-a-p) ; outside overlay-arrow-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (defvar edebug-outside-o-a-s) ; outside overlay-arrow-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 (defvar edebug-outside-c-i-e-a) ; outside cursor-in-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (defvar edebug-eval-list nil) ;; List of expressions to evaluate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 (defvar edebug-previous-result nil) ;; Last result returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 ;; Emacs 19 adds an arg to mark and mark-marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (defalias 'edebug-mark 'mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (defalias 'edebug-mark-marker 'mark-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (defun edebug-display ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 ;; Setup windows for edebug, determine mode, maybe enter recursive-edit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 ;; Uses local variables of edebug-enter, edebug-before, edebug-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 ;; and edebug-debugger.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (let ((edebug-active t) ; for minor mode alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 edebug-stop ; should we enter recursive-edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 (edebug-point (+ edebug-def-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (aref (nth 2 edebug-data) edebug-offset-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 edebug-buffer-outside-point ; current point in edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 ;; window displaying edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 (edebug-window-data (nth 3 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 (edebug-outside-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 (edebug-outside-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 (edebug-outside-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (edebug-outside-mark (edebug-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 edebug-outside-windows ; window or screen configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 edebug-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 edebug-eval-buffer ; declared here so we can kill it below
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (edebug-eval-result-list (and edebug-eval-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 (edebug-eval-result-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 edebug-trace-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (edebug-outside-o-a-p overlay-arrow-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 (edebug-outside-o-a-s overlay-arrow-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 (edebug-outside-c-i-e-a cursor-in-echo-area))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (let ((overlay-arrow-position overlay-arrow-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 (overlay-arrow-string overlay-arrow-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 (cursor-in-echo-area nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 ;; any others??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (if (not (buffer-name edebug-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 (let ((debug-on-error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (error "Buffer defining %s not found" edebug-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (if (eq 'after edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 ;; Compute result string now before windows are modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (edebug-compute-previous-result edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 ;; Save windows now before we modify them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 (setq edebug-outside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 (edebug-current-windows edebug-save-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (if edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (setq edebug-buffer-points (edebug-get-displayed-buffer-points)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 ;; First move the edebug buffer point to edebug-point
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2555 ;; so that window start doesn't get changed when we display it.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2556 ;; I don't know if this is going to help.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 ;;(set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 ;;(goto-char edebug-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 ;; If edebug-buffer is not currently displayed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 ;; first find a window for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 (edebug-pop-to-buffer edebug-buffer (car edebug-window-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 (setcar edebug-window-data (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 ;; Now display eval list, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 ;; This is done after the pop to edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 ;; so that buffer-window correspondence is correct after quitting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (edebug-eval-display edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 ;; The evaluation list better not have deleted edebug-window-data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 (select-window (car edebug-window-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 (set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 (setq edebug-buffer-outside-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 (goto-char edebug-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 (if (eq 'before edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 ;; Check whether positions are up-to-date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 ;; This assumes point is never before symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 (if (not (memq (following-char) '(?\( ?\# ?\` )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 (let ((debug-on-error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 (error "Source has changed - reevaluate definition of %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 edebug-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (setcdr edebug-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 (edebug-adjust-window (cdr edebug-window-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 ;; Test if there is input, not including keyboard macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 (if (edebug-input-pending-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (setq edebug-execution-mode 'step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 edebug-stop t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (edebug-stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 ;; (discard-input) ; is this unfriendly??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 ;; Now display arrow based on mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 (edebug-overlay-arrow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 ((eq 'error edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 ;; Display error message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 (setq edebug-execution-mode 'step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 (edebug-overlay-arrow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 (if (eq 'quit (car edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (message "Quit")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 (edebug-report-error edebug-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 (message "Global Break: %s => %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 edebug-global-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 edebug-global-break-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (message "Break: %s => %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 edebug-break-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 ((not (eq edebug-execution-mode 'Continue-fast))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 (message "Break"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 (t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (t (message "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 (if (eq 'after edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 ;; Display result of previous evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (if (and edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (not (eq edebug-execution-mode 'Continue-fast)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 (sit-for 1)) ; Show break message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 (edebug-previous-result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 (edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 ((eq edebug-execution-mode 'continue) (edebug-sit-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 ((eq edebug-execution-mode 'Continue-fast) (edebug-sit-for 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 (t (setq edebug-stop t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 ;; not edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 ((eq edebug-execution-mode 'trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 (edebug-sit-for 1)) ; Force update and pause.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 ((eq edebug-execution-mode 'Trace-fast)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 (edebug-sit-for 0)) ; Force update and continue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 (if (or edebug-stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 (memq edebug-execution-mode '(step next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 (eq edebug-arg-mode 'error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 ;; (setq edebug-execution-mode 'step)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2651 ;; (edebug-overlay-arrow) ; this doesn't always show up.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 (edebug-recursive-edit))) ; <---------- Recursive edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 ;; Reset the edebug-window-data to whatever it is now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 (let ((window (if (eq (window-buffer) edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 (edebug-get-buffer-window edebug-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 ;; Remember window-start for edebug-buffer, if still displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 (setcar edebug-window-data window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (setcdr edebug-window-data (window-start window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 ;; Save trace window point before restoring outside windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 ;; Could generalize this for other buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 (setq edebug-trace-window (get-buffer-window edebug-trace-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 (if edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 (setq edebug-trace-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 (and edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (window-start edebug-trace-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 ;; Restore windows before continuing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 (edebug-set-windows edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 ;; Restore displayed buffer points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 ;; Needed even if restoring windows because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 ;; window-points are not restored. (should they be??)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 (if edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 (edebug-set-buffer-points edebug-buffer-points))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 ;; Unrestore trace window's window-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 (if edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 (set-window-start edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 edebug-trace-window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 ;; Unrestore edebug-buffer's window-start, if displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 (let ((window (car edebug-window-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 (if (and window (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 (eq (window-buffer) edebug-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 (set-window-start window (cdr edebug-window-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 'no-force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 ;; Unrestore edebug-buffer's window-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 ;; Needed in addition to setting the buffer point
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2697 ;; - otherwise quitting doesn't leave point as is.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 ;; But this causes point to not be restored at times.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 ;; Also, it may not be a visible window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 ;; (set-window-point window edebug-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 ;; Unrestore edebug-buffer's point. Rerestored below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 ;; (goto-char edebug-point) ;; in edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 ;; Since we may be in a save-excursion, in case of quit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 ;; reselect the outside window only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 ;; Only needed if we are not recovering windows??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 (if (edebug-window-live-p edebug-outside-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 (select-window edebug-outside-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 ) ; if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 ;; Restore current buffer always, in case application needs it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 (set-buffer edebug-outside-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 ;; Restore point, and mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 ;; Needed even if restoring windows because
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2717 ;; that doesn't restore point and mark in the current buffer.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2718 ;; But don't restore point if edebug-buffer is current buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 (if (not (eq edebug-buffer edebug-outside-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (goto-char edebug-outside-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 (if (marker-buffer (edebug-mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 ;; Does zmacs-regions need to be nil while doing set-marker?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 (set-marker (edebug-mark-marker) edebug-outside-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 ) ; unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 ;; None of the following is done if quit or signal occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 ;; Restore edebug-buffer's outside point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 ;; (edebug-trace "restore edebug-buffer point: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 ;; edebug-buffer-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 (let ((current-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 (set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 (goto-char edebug-buffer-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 (set-buffer current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 ;; ... nothing more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 ;; Reset global variables to outside values in case they were changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 overlay-arrow-position edebug-outside-o-a-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 overlay-arrow-string edebug-outside-o-a-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 cursor-in-echo-area edebug-outside-c-i-e-a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 (defvar edebug-number-of-recursions 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 ;; Number of recursive edits started by edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 ;; Should be 0 at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 (defvar edebug-recursion-depth 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 ;; Value of recursion-depth when edebug was called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 ;; Dynamically declared unbound vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 (defvar edebug-outside-match-data) ; match data outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 (defvar edebug-backtrace-buffer) ; each recursive edit gets its own
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 (defvar edebug-inside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 (defvar edebug-interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 (defvar edebug-outside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 (defvar edebug-outside-standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 (defvar edebug-outside-standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 (defvar edebug-outside-last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 (defvar edebug-outside-last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 (defvar edebug-outside-this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 (defvar edebug-outside-last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 ;; Note: here we have defvars for variables that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 ;; built-in in certain versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 ;; Each defvar makes a difference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 ;; in versions where the variable is *not* built-in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 ;; Emacs 18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 (defvar edebug-outside-unread-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 ;; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 (defvar edebug-outside-unread-command-event) ;; like unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 (defvar unread-command-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 ;; Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 (defvar edebug-outside-last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 (defvar edebug-outside-unread-command-events)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 (defvar edebug-outside-last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 (defvar edebug-outside-last-event-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 (defvar edebug-outside-last-nonmenu-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 (defvar edebug-outside-track-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 ;; Disable byte compiler warnings about unread-command-char and -event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 ;; (maybe works with byte-compile-version 2.22 at least)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 (defvar edebug-unread-command-char-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 (defvar edebug-unread-command-event-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 (setq edebug-unread-command-char-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 (get 'unread-command-char 'byte-obsolete-variable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 (put 'unread-command-char 'byte-obsolete-variable nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 (setq edebug-unread-command-event-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 (get 'unread-command-event 'byte-obsolete-variable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 (put 'unread-command-event 'byte-obsolete-variable nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 (defun edebug-recursive-edit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 ;; Start up a recursive edit inside of edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 ;; The current buffer is the edebug-buffer, which is put into edebug-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 ;; Assume that none of the variables below are buffer-local.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 (let ((edebug-buffer-read-only buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 ;; match-data must be done in the outside buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 (edebug-outside-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 (save-excursion ; might be unnecessary now??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 (set-buffer edebug-outside-buffer) ; in case match buffer different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 (match-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 ;;(edebug-number-of-recursions (1+ edebug-number-of-recursions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 (edebug-recursion-depth (recursion-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 edebug-entered ; bind locally to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 (edebug-interactive-p nil) ; again non-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 edebug-backtrace-buffer ; each recursive edit gets its own
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 ;; The window configuration may be saved and restored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 ;; during a recursive-edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 (edebug-outside-map (current-local-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 (edebug-outside-standard-output standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 (edebug-outside-standard-input standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 (edebug-outside-defining-kbd-macro defining-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 (edebug-outside-last-command-char last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 (edebug-outside-last-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 (edebug-outside-this-command this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 (edebug-outside-last-input-char last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 ;; XEmacs: added the boundp checks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 (edebug-outside-unread-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 (and (boundp 'unread-command-char) unread-command-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 (edebug-outside-last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 (and (boundp 'last-input-event) last-input-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 (edebug-outside-last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 (and (boundp 'last-command-event) last-command-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 (edebug-outside-unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 (and (boundp 'unread-command-event) unread-command-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 (edebug-outside-unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 (and (boundp 'unread-command-events) unread-command-events))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 (edebug-outside-last-event-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 (and (boundp 'last-event-frame) last-event-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 (edebug-outside-last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 (and (boundp 'last-nonmenu-event) last-nonmenu-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 (edebug-outside-track-mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 (and (boundp 'track-mouse) track-mouse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 ;; Declare global values local but using the same global value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 ;; We could set these to the values for previous edebug call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 (last-command-char last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 (last-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 (this-command this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 (last-input-char last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 ;; Assume no edebug command sets unread-command-char.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 (unread-command-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 ;; More for Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 (last-input-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 (last-command-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 (unread-command-event nil);; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 (unread-command-events nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 (last-event-frame nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 (last-nonmenu-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 (track-mouse nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 ;; Bind again to outside values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 (debug-on-error edebug-outside-debug-on-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 (debug-on-quit edebug-outside-debug-on-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 ;; Don't keep defining a kbd macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 (defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 (if edebug-continue-kbd-macro defining-kbd-macro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 ;; others??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 (if (fboundp 'zmacs-deactivate-region);; for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 (zmacs-deactivate-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 (if (and (eq edebug-execution-mode 'go)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 (not (memq edebug-arg-mode '(after error))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 (message "Break"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 (fset 'signal (symbol-function 'edebug-original-signal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 (edebug-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 (recursive-edit) ; <<<<<<<<<< Recursive edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 ;; Do the following, even if quit occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 (fset 'signal 'edebug-signal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 (if edebug-backtrace-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 (kill-buffer edebug-backtrace-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 ;; Could be an option to keep eval display up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 (if edebug-eval-buffer (kill-buffer edebug-eval-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 ;; Remember selected-window after recursive-edit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 ;; (setq edebug-inside-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 (store-match-data edebug-outside-match-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 ;; Recursive edit may have changed buffers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 ;; so set it back before exiting let.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 (if (buffer-name edebug-buffer) ; if it still exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 (set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 (if (memq edebug-execution-mode '(go Go-nonstop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 (edebug-overlay-arrow))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 (setq buffer-read-only edebug-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 (use-local-map edebug-outside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 ;; gotta have a buffer to let its buffer local variables be set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 (get-buffer-create " bogus edebug buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 ));; inner let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 ;; Reset global vars to outside values, in case they have been changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 last-command-char edebug-outside-last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 last-command-event edebug-outside-last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 last-command edebug-outside-last-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 this-command edebug-outside-this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 unread-command-char edebug-outside-unread-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 unread-command-event edebug-outside-unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 unread-command-events edebug-outside-unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 last-input-char edebug-outside-last-input-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 last-input-event edebug-outside-last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 last-event-frame edebug-outside-last-event-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 last-nonmenu-event edebug-outside-last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 track-mouse edebug-outside-track-mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 standard-output edebug-outside-standard-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 standard-input edebug-outside-standard-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 defining-kbd-macro edebug-outside-defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2941 ;;; Display related functions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 (defun edebug-adjust-window (old-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 ;; If pos is not visible, adjust current window to fit following context.
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2945 ;;; (message "window: %s old-start: %s window-start: %s pos: %s"
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
2946 ;;; (selected-window) old-start (window-start) (point)) (sit-for 5)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 (if (not (pos-visible-in-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 ;; First try old-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 (if old-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 (set-window-start (selected-window) old-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 (if (not (pos-visible-in-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 ;; (message "resetting window start") (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 (set-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 (forward-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 (if (< (point) (window-start)) -1 ; one line before if in back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 (- (/ (window-height) 2)) ; center the line moving forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 (defconst edebug-arrow-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 '((Continue-fast . "=")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 (Trace-fast . "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 (continue . ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 (trace . "->")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 (step . "=>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 (next . "=>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 (go . "<>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 (Go-nonstop . "..") ; not used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 "Association list of arrows for each edebug mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 (defun edebug-overlay-arrow ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 ;; Set up the overlay arrow at beginning-of-line in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 ;; The arrow string is derived from edebug-arrow-alist and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 ;; edebug-execution-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 (let ((pos (save-excursion (beginning-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 (setq overlay-arrow-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 (cdr (assq edebug-execution-mode edebug-arrow-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 (setq overlay-arrow-position (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 (set-marker overlay-arrow-position pos (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 (defun edebug-toggle-save-all-windows ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 "Toggle the saving and restoring of all windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 Also, each time you toggle it on, the inside and outside window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 configurations become the same as the current configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 (setq edebug-save-windows (not edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 (setq edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 (setq edebug-outside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 (edebug-current-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 edebug-save-windows))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 (message "Window saving is %s for all windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 (if edebug-save-windows "on" "off")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 (defmacro edebug-changing-windows (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 (` (let ((window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 (setq edebug-inside-windows (edebug-current-windows t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 (edebug-set-windows edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 (,@ body) ;; Code to change edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 (setq edebug-outside-windows (edebug-current-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 ;; Problem: what about outside windows that are deleted inside?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 (edebug-set-windows edebug-inside-windows))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 (defun edebug-toggle-save-selected-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 "Toggle the saving and restoring of the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 Also, each time you toggle it on, the inside and outside window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 configurations become the same as the current configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 ((eq t edebug-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 ;; Save all outside windows except the selected one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 ;; Remove (selected-window) from outside-windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 (edebug-changing-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 (setq edebug-save-windows (delq window (edebug-window-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 ((memq (selected-window) edebug-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 (setq edebug-outside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 (delq (assq (selected-window) edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 edebug-outside-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 (setq edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 (delq (selected-window) edebug-save-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 (t ; Save a new window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 (edebug-changing-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 (setq edebug-save-windows (cons window edebug-save-windows)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 (message "Window saving is %s for %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 (if (memq (selected-window) edebug-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 "on" "off")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 (defun edebug-toggle-save-windows (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 "Toggle the saving and restoring of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 With prefix, toggle for just the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 Otherwise, toggle for all windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 (edebug-toggle-save-selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 (edebug-toggle-save-all-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 (defun edebug-where ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 "Show the debug windows and where we stopped in the program."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 (if (not edebug-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 (error "Edebug is not active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 ;; Restore the window configuration to what it last was inside.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 ;; But it is not always set. - experiment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 ;;(if edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 ;; (edebug-set-windows edebug-inside-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 (edebug-pop-to-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 (goto-char edebug-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 (defun edebug-view-outside ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 "Change to the outside window configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 (if (not edebug-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 (error "Edebug is not active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 (setq edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 (edebug-current-windows edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 (edebug-set-windows edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 (goto-char edebug-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 (message "Window configuration outside of Edebug. Return with %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 (substitute-command-keys "\\<global-map>\\[edebug-where]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 (defun edebug-bounce-point (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 "Bounce the point in the outside current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 If prefix arg is supplied, sit for that many seconds before returning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 The default is one second."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 (if (not edebug-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 (error "Edebug is not active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 ;; If the buffer's currently displayed, avoid set-window-configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 (edebug-pop-to-buffer edebug-outside-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 (goto-char edebug-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 (message "Current buffer: %s Point: %s Mark: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 (current-buffer) (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 (if (marker-buffer (edebug-mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 (marker-position (edebug-mark-marker)) "<not set>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 (edebug-sit-for arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 (edebug-pop-to-buffer edebug-buffer (car edebug-window-data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 ;; Joe Wells, here is a start at your idea of adding a buffer to the internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 ;; display list. Still need to use this list in edebug-display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 '(defvar edebug-display-buffer-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 "List of buffers that edebug will display when it is active.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 '(defun edebug-display-buffer (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 "Toggle display of a buffer inside of edebug."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 (interactive "bBuffer: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 (let ((already-displaying (memq buffer edebug-display-buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 (setq edebug-display-buffer-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 (if already-displaying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 (delq buffer edebug-display-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 (cons buffer edebug-display-buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 (message "Displaying %s %s" buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 (if already-displaying "off" "on"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3114 ;;; Breakpoint related functions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 (defun edebug-find-stop-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 ;; Return (function . index) of the nearest edebug stop point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 (let* ((edebug-def-name (edebug-form-data-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 (edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 (let ((data (get edebug-def-name 'edebug)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 (if (or (null data) (markerp data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 (error "%s is not instrumented for Edebug" edebug-def-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 data)) ; we could do it automatically, if data is a marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 ;; pull out parts of edebug-data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 (edebug-def-mark (car edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 ;; (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 (offset-vector (nth 2 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 (offset (- (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 (if (looking-at "[ \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 ;; skip backwards until non-whitespace, or bol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 (skip-chars-backward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 edebug-def-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 len i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 ;; the offsets are in order so we can do a linear search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 (setq len (length offset-vector))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 (setq i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 (while (and (< i len) (> offset (aref offset-vector i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 (if (and (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 (<= offset (aref offset-vector i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 ;; return the relevant info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 (cons edebug-def-name i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 (message "Point is not on an expression in %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 (defun edebug-next-breakpoint ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 "Move point to the next breakpoint, or first if none past point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 ;; pull out parts of edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 (edebug-def-mark (car edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 (offset-vector (nth 2 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 (if (not edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 (message "No breakpoints in this function.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 (let ((breaks edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 (while (and breaks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 (<= (car (car breaks)) index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 (setq breaks (cdr breaks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 (setq breakpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 (if breaks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 (car breaks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 ;; goto the first breakpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 (car edebug-breakpoints)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 (goto-char (+ edebug-def-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 (aref offset-vector (car breakpoint))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3178 (message "%s"
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3179 (concat (if (nth 2 breakpoint)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 "Temporary " "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 (if (car (cdr breakpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 (format "Condition: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 (edebug-safe-prin1-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 (car (cdr breakpoint))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 (defun edebug-modify-breakpoint (flag &optional condition temporary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 "Modify the breakpoint for the form at point or after it according
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 to FLAG: set if t, clear if nil. Then move to that point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 If CONDITION or TEMPORARY are non-nil, add those attributes to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 the breakpoint. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 ;; pull out parts of edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 (edebug-def-mark (car edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 (offset-vector (nth 2 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 present)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 ;; delete it either way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 (setq present (assq index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 (setq edebug-breakpoints (delq present edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 (if flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 ;; add it to the list and resort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 (setq edebug-breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 (edebug-sort-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 (list index condition temporary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 edebug-breakpoints) '<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 (if condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 (message "Breakpoint set in %s with condition: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 edebug-def-name condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 (message "Breakpoint set in %s" edebug-def-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 (if present
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 (message "Breakpoint unset in %s" edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 (message "No breakpoint here")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 (setcar (cdr edebug-data) edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 (goto-char (+ edebug-def-mark (aref offset-vector index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 (defun edebug-set-breakpoint (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 "Set the breakpoint of nearest sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 With prefix argument, make it a temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 (edebug-modify-breakpoint t nil arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 (defun edebug-unset-breakpoint ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 "Clear the breakpoint of nearest sexp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 (edebug-modify-breakpoint nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 ;; For emacs 18, no read-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 (defun edebug-set-conditional-breakpoint (arg condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 "Set a conditional breakpoint at nearest sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 The condition is evaluated in the outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 With prefix argument, make it a temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 ;; (interactive "P\nxCondition: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 ;; Edit previous condition as follows, but it is cumbersome:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 (edebug-break-data (assq index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 (edebug-break-condition (car (cdr edebug-break-data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 (read-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 (format "Condition in %s: " edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 (if edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 (format "%s" edebug-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 (format ""))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 (edebug-modify-breakpoint t condition arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 (defun edebug-set-global-break-condition (expression)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 (interactive (list (read-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 "Global Condition: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 (format "%s" edebug-global-break-condition))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 (setq edebug-global-break-condition expression))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3273 ;;; Mode switching functions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 (defun edebug-set-mode (mode shortmsg msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 ;; Set the edebug mode to MODE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 ;; Display SHORTMSG, or MSG if not within edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 (if (eq (1+ edebug-recursion-depth) (recursion-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 (setq edebug-execution-mode mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 (message shortmsg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 ;; Continue execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 (exit-recursive-edit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 ;; This is not terribly useful!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 (setq edebug-next-execution-mode mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 (message msg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 (defalias 'edebug-step-through-mode 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 (defun edebug-step-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 "Proceed to next stop point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 (edebug-set-mode 'step "" "Edebug will stop at next stop point."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 (defun edebug-next-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 "Proceed to next `after' stop point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299 (edebug-set-mode 'next "" "Edebug will stop after next eval."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301 (defun edebug-go-mode (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 "Go, evaluating until break.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 With prefix ARG, set temporary break at current point and go."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 (edebug-set-breakpoint t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307 (edebug-set-mode 'go "Go..." "Edebug will go until break."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 (defun edebug-Go-nonstop-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 "Go, evaluating without debugging."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 (edebug-set-mode 'Go-nonstop "Go-Nonstop..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 "Edebug will not stop at breaks."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316 (defun edebug-trace-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 "Begin trace mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319 (edebug-set-mode 'trace "Tracing..." "Edebug will trace with pause."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 (defun edebug-Trace-fast-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322 "Trace with no wait at each step."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 (edebug-set-mode 'Trace-fast
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 "Trace fast..." "Edebug will trace without pause."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327 (defun edebug-continue-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 "Begin continue mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 (edebug-set-mode 'continue "Continue..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331 "Edebug will pause at breakpoints."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 (defun edebug-Continue-fast-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 "Trace with no wait at each step."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 (edebug-set-mode 'Continue-fast "Continue fast..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 "Edebug will stop and go at breakpoints."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 ;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 ;; The following use the mode changing commands and breakpoints.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 (defun edebug-goto-here ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 "Proceed to this stop point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 (edebug-go-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 (defun edebug-stop ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 "Stop execution and do not continue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 Useful for exiting from trace or continue loop."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353 (message "Stop"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356 '(defun edebug-forward ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357 "Proceed to the exit of the next expression to be evaluated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 (edebug-set-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 'forward "Forward"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361 "Edebug will stop after exiting the next expression."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364 (defun edebug-forward-sexp (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 "Proceed from the current point to the end of the ARGth sexp ahead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 If there are not ARG sexps ahead, then do edebug-step-out."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 (let ((parse-sexp-ignore-comments t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3370 ;; Call forward-sexp repeatedly until done or failure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371 (forward-sexp arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 (edebug-go-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 (edebug-step-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 (defun edebug-step-out ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 "Proceed from the current point to the end of the containing sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 If there is no containing sexp that is not the top level defun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 go to the end of the last sexp, or if that is the same point, then step."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383 (let ((parse-sexp-ignore-comments t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 (up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 ;; Is there still a containing expression?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387 (up-list 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 (edebug-go-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 ;; At top level - 1, so first check if there are more sexps at this level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 (let ((start-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392 ;; (up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 (down-list -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 (if (= (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395 (edebug-step-mode) ; No more at this level, so step.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 (edebug-go-mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 (defun edebug-instrument-function (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400 ;; Func should be a function symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401 ;; Return the function symbol, or nil if not instrumented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402 (let ((func-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 (setq func-marker (get func 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3405 ((markerp func-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406 ;; It is uninstrumented, so instrument it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3408 (set-buffer (marker-buffer func-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 (goto-char func-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410 (edebug-eval-top-level-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3411 func))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3412 ((consp func-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3413 (message "%s is already instrumented." func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414 func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3415 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3416 ;; We could try harder, e.g. do a tags search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3417 (error "Don't know where %s is defined" func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3420 (defun edebug-instrument-callee ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421 "Instrument the definition of the function or macro about to be called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3422 Do this when stopped before the form or it will be too late.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3423 One side effect of using this command is that the next time the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3424 function or macro is called, Edebug will be called there as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3425 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3426 (if (not (looking-at "\("))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3427 (error "You must be before a list form")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3428 (let ((func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3429 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3430 (down-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3431 (if (looking-at "\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3432 (edebug-form-data-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3433 (edebug-get-form-data-entry (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3434 (edebug-original-read (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3435 (edebug-instrument-function func))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3438 (defun edebug-step-in ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3439 "Step into the definition of the function or macro about to be called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3440 This first does `edebug-instrument-callee' to ensure that it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441 instrumented. Then it does `edebug-on-entry' and switches to `go' mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3442 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443 (let ((func (edebug-instrument-callee)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444 (if func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3445 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3446 (edebug-on-entry func 'temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3447 (edebug-go-mode nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449 (defun edebug-on-entry (function &optional flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450 "Cause Edebug to stop when FUNCTION is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3451 With prefix argument, make this temporary so it is automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3452 cancelled the first time the function is entered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 (interactive "aEdebug on entry to: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454 ;; Could store this in the edebug data instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455 (put function 'edebug-on-entry (if flag 'temp t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 (defun cancel-edebug-on-entry (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 (interactive "aEdebug on entry to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459 (put function 'edebug-on-entry nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3462 (if (not (fboundp 'edebug-original-debug-on-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 (fset 'edebug-original-debug-on-entry (symbol-function 'debug-on-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3464 '(fset 'debug-on-entry 'edebug-debug-on-entry) ;; Should we do this?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465 ;; Also need edebug-cancel-debug-on-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 '(defun edebug-debug-on-entry (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 "Request FUNCTION to invoke debugger each time it is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 If the user continues, FUNCTION's execution proceeds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470 Works by modifying the definition of FUNCTION,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 which must be written in Lisp, not predefined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 Use `cancel-debug-on-entry' to cancel the effect of this command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 Redefining FUNCTION also does that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 This version is from Edebug. If the function is instrumented for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 Edebug, it calls `edebug-on-entry'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477 (interactive "aDebug on entry (to function): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478 (let ((func-data (get function 'edebug)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 (if (or (null func-data) (markerp func-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 (edebug-original-debug-on-entry function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 (edebug-on-entry function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 (defun edebug-top-level-nonstop ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 "Set mode to Go-nonstop, and exit to top-level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 This is useful for exiting even if unwind-protect code may be executed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 (setq edebug-execution-mode 'Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 (top-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 ;;(defun edebug-exit-out ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 ;; "Go until the current function exits."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 ;; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 ;; (edebug-set-mode 'exiting "Exit..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3498 ;;; The following initial mode setting definitions are not used yet.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 '(defconst edebug-initial-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3501 '((edebug-Continue-fast . Continue-fast)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502 (edebug-Trace-fast . Trace-fast)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503 (edebug-continue . continue)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 (edebug-trace . trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 (edebug-go . go)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 (edebug-step-through . step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507 (edebug-Go-nonstop . Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509 "Association list between commands and the modes they set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3512 '(defun edebug-set-initial-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3513 "Ask for the initial mode of the enclosing function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3514 The mode is requested via the key that would be used to set the mode in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3515 edebug-mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3516 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3517 (let* ((this-function (edebug-which-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3518 (keymap (if (eq edebug-mode-map (current-local-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3519 edebug-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3520 (old-mode (or (get this-function 'edebug-initial-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3521 edebug-initial-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3522 (key (read-key-sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3523 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3524 "Change initial edebug mode for %s from %s (%s) to (enter key): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3525 this-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3526 old-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3527 (where-is-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3528 (car (rassq old-mode edebug-initial-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3529 keymap 'firstonly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3530 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3531 (mode (cdr (assq (key-binding key) edebug-initial-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3532 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3533 (if (and mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3534 (or (get this-function 'edebug-initial-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3535 (not (eq mode edebug-initial-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3536 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3537 (put this-function 'edebug-initial-mode mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3538 (message "Initial mode for %s is now: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3539 this-function mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3540 (error "Key must map to one of the mode changing commands")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3541 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3542
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3543 ;;; Evaluation of expressions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3545 (def-edebug-spec edebug-outside-excursion t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3547 (defmacro edebug-outside-excursion (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3548 "Evaluate an expression list in the outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3549 Return the result of the last expression."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3550 (` (save-excursion ; of current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3551 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3552 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3553 ;; After excursion, we will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3554 ;; restore to current window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3555 (setq edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 (edebug-current-windows edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557 ;; Restore outside windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558 (edebug-set-windows edebug-outside-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 (set-buffer edebug-buffer) ; why?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561 ;; (use-local-map edebug-outside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562 (store-match-data edebug-outside-match-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563 ;; Restore outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564 (let (;; (edebug-inside-map (current-local-map)) ;; restore map??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565 (last-command-char edebug-outside-last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3566 (last-command-event edebug-outside-last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3567 (last-command edebug-outside-last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3568 (this-command edebug-outside-this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3569 (unread-command-char edebug-outside-unread-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3570 (unread-command-event edebug-outside-unread-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3571 (unread-command-events edebug-outside-unread-command-events)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3572 (last-input-char edebug-outside-last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573 (last-input-event edebug-outside-last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 (last-event-frame edebug-outside-last-event-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575 (last-nonmenu-event edebug-outside-last-nonmenu-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576 (track-mouse edebug-outside-track-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577 (standard-output edebug-outside-standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578 (standard-input edebug-outside-standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
3580 (executing-kbd-macro edebug-outside-executing-macro)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3581 (defining-kbd-macro edebug-outside-defining-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 (pre-command-hook edebug-outside-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3583 (post-command-hook edebug-outside-post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3584 (post-command-idle-hook edebug-outside-post-command-idle-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3586 ;; See edebug-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3587 (overlay-arrow-position edebug-outside-o-a-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588 (overlay-arrow-string edebug-outside-o-a-s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3589 (cursor-in-echo-area edebug-outside-c-i-e-a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3590 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3591 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3592 (save-excursion ; of edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3593 (set-buffer edebug-outside-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3594 (goto-char edebug-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595 (if (marker-buffer (edebug-mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3596 (set-marker (edebug-mark-marker) edebug-outside-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3597 (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 ;; Back to edebug-buffer. Restore rest of inside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600 ;; (use-local-map edebug-inside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602 ;; Restore inside windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 (edebug-set-windows edebug-inside-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 ;; Save values that may have been changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3607 edebug-outside-last-command-char last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608 edebug-outside-last-command-event last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 edebug-outside-last-command last-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610 edebug-outside-this-command this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 edebug-outside-unread-command-char unread-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612 edebug-outside-unread-command-event unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613 edebug-outside-unread-command-events unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614 edebug-outside-last-input-char last-input-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615 edebug-outside-last-input-event last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3616 edebug-outside-last-event-frame last-event-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617 edebug-outside-last-nonmenu-event last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3618 edebug-outside-track-mouse track-mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619 edebug-outside-standard-output standard-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3620 edebug-outside-standard-input standard-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3621
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
3622 edebug-outside-executing-macro executing-kbd-macro
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623 edebug-outside-defining-kbd-macro defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 edebug-outside-pre-command-hook pre-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625 edebug-outside-post-command-hook post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3626 edebug-outside-post-command-idle-hook post-command-idle-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3628 edebug-outside-o-a-p overlay-arrow-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3629 edebug-outside-o-a-s overlay-arrow-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3630 edebug-outside-c-i-e-a cursor-in-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3631 ))) ; let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3632 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3634 (defvar cl-debug-env nil) ;; defined in cl; non-nil when lexical env used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3636 (defun edebug-eval (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3637 ;; Are there cl lexical variables active?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3638 (if cl-debug-env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3639 (eval (cl-macroexpand-all edebug-expr cl-debug-env))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3640 (eval edebug-expr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3642 (defun edebug-safe-eval (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3643 ;; Evaluate EXPR safely.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3644 ;; If there is an error, a string is returned describing the error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3645 (condition-case edebug-err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3646 (edebug-eval edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3647 (error (edebug-format "%s: %s" ;; could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3648 (get (car edebug-err) 'error-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3649 (car (cdr edebug-err))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3650
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3651 ;;; Printing
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3652
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3653 ;; Replace printing functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3655 ;; obsolete names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3656 (defalias 'edebug-install-custom-print-funcs 'edebug-install-custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3657 (defalias 'edebug-reset-print-funcs 'edebug-uninstall-custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3658 (defalias 'edebug-uninstall-custom-print-funcs 'edebug-uninstall-custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3660 (defun edebug-install-custom-print ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3661 "Replace print functions used by Edebug with custom versions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3662 ;; Modifying the custom print functions, or changing print-length,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3663 ;; print-level, print-circle, custom-print-list or custom-print-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3664 ;; have immediate effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3665 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3666 (require 'cust-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3667 (defalias 'edebug-prin1 'custom-prin1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3668 (defalias 'edebug-print 'custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3669 (defalias 'edebug-prin1-to-string 'custom-prin1-to-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3670 (defalias 'edebug-format 'custom-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3671 (defalias 'edebug-message 'custom-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3672 "Installed")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3674 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3675 (defun edebug-uninstall-custom-print ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3676 "Replace edebug custom print functions with internal versions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3677 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3678 (defalias 'edebug-prin1 'prin1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3679 (defalias 'edebug-print 'print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3680 (defalias 'edebug-prin1-to-string 'prin1-to-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3681 (defalias 'edebug-format 'format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3682 (defalias 'edebug-message 'message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3683 "Uninstalled")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3685 ;; Default print functions are the same as Emacs'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3686 (edebug-uninstall-custom-print))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3689 (defun edebug-report-error (edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3690 ;; Print an error message like command level does.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3691 ;; This also prints the error name if it has no error-message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3692 (message "%s: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3693 (or (get (car edebug-value) 'error-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3694 (format "peculiar error (%s)" (car edebug-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3695 (mapconcat (function (lambda (edebug-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3696 ;; continuing after an error may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3697 ;; complain about edebug-arg. why??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3698 (prin1-to-string edebug-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3699 (cdr edebug-value) ", ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3701 ;; Define here in case they are not already defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3702 (defvar print-level nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3703 (defvar print-circle nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3704 (defvar print-readably) ;; defined by XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3705 ;; Alternatively, we could change the definition of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3706 ;; edebug-safe-prin1-to-string to only use these if defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3708 (defun edebug-safe-prin1-to-string (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3709 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3710 (print-length (or edebug-print-length print-length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3711 (print-level (or edebug-print-level print-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3712 (print-circle (or edebug-print-circle print-circle))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3713 (print-readably nil)) ;; XEmacs uses this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3714 (edebug-prin1-to-string value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3716 (defun edebug-compute-previous-result (edebug-previous-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3717 (setq edebug-previous-result
48
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 26
diff changeset
3718 (if (numberp edebug-previous-value)
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 26
diff changeset
3719 (format "Result: %s" edebug-previous-value)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3720 (if edebug-unwrap-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3721 (setq edebug-previous-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3722 (edebug-unwrap* edebug-previous-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3723 (concat "Result: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3724 (edebug-safe-prin1-to-string edebug-previous-value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3726 (defun edebug-previous-result ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3727 "Print the previous result."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3728 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3729 (message "%s" edebug-previous-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3730
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3731 ;;; Read, Eval and Print
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3733 (defun edebug-eval-expression (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3734 "Evaluate an expression in the outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3735 If interactive, prompt for the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3736 Print result in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3737 (interactive "xEval: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3738 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3739 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3740 (setq values (cons (edebug-eval edebug-expr) values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3741 (edebug-safe-prin1-to-string (car values)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3743 (defun edebug-eval-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3744 "Evaluate sexp before point in the outside environment;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3745 print value in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3746 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3747 (edebug-eval-expression (edebug-last-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3749 (defun edebug-eval-print-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3750 "Evaluate sexp before point in the outside environment;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3751 print value into current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3752 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3753 (let* ((edebug-form (edebug-last-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3754 (edebug-result-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3755 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3756 (edebug-safe-prin1-to-string (edebug-safe-eval edebug-form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3757 (standard-output (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3758 (princ "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3759 ;; princ the string to get rid of quotes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3760 (princ edebug-result-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3761 (princ "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3762 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3763
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3764 ;;; Edebug Minor Mode
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3766 ;; Global GUD bindings for all emacs-lisp-mode buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3767 (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3768 (define-key emacs-lisp-mode-map "\C-x\C-a\C-n" 'edebug-next-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3769 (define-key emacs-lisp-mode-map "\C-x\C-a\C-c" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3770 (define-key emacs-lisp-mode-map "\C-x\C-a\C-l" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3773 (defvar edebug-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3774 (if edebug-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3775 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3776 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3777 (setq edebug-mode-map (copy-keymap emacs-lisp-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3778 ;; control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3779 (define-key edebug-mode-map " " 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3780 (define-key edebug-mode-map "n" 'edebug-next-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3781 (define-key edebug-mode-map "g" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3782 (define-key edebug-mode-map "G" 'edebug-Go-nonstop-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3783 (define-key edebug-mode-map "t" 'edebug-trace-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3784 (define-key edebug-mode-map "T" 'edebug-Trace-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3785 (define-key edebug-mode-map "c" 'edebug-continue-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3786 (define-key edebug-mode-map "C" 'edebug-Continue-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3788 ;;(define-key edebug-mode-map "f" 'edebug-forward) not implemented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3789 (define-key edebug-mode-map "f" 'edebug-forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3790 (define-key edebug-mode-map "h" 'edebug-goto-here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3792 (define-key edebug-mode-map "I" 'edebug-instrument-callee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3793 (define-key edebug-mode-map "i" 'edebug-step-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3794 (define-key edebug-mode-map "o" 'edebug-step-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3796 ;; quitting and stopping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3797 (define-key edebug-mode-map "q" 'top-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3798 (define-key edebug-mode-map "Q" 'edebug-top-level-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3799 (define-key edebug-mode-map "a" 'abort-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3800 (define-key edebug-mode-map "S" 'edebug-stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3802 ;; breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3803 (define-key edebug-mode-map "b" 'edebug-set-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3804 (define-key edebug-mode-map "u" 'edebug-unset-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3805 (define-key edebug-mode-map "B" 'edebug-next-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3806 (define-key edebug-mode-map "x" 'edebug-set-conditional-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3807 (define-key edebug-mode-map "X" 'edebug-set-global-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3809 ;; evaluation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3810 (define-key edebug-mode-map "r" 'edebug-previous-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3811 (define-key edebug-mode-map "e" 'edebug-eval-expression)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3812 (define-key edebug-mode-map "\C-x\C-e" 'edebug-eval-last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3813 (define-key edebug-mode-map "E" 'edebug-visit-eval-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3815 ;; views
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3816 (define-key edebug-mode-map "w" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3817 (define-key edebug-mode-map "v" 'edebug-view-outside) ;; maybe obsolete??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3818 (define-key edebug-mode-map "p" 'edebug-bounce-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3819 (define-key edebug-mode-map "P" 'edebug-view-outside) ;; same as v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3820 (define-key edebug-mode-map "W" 'edebug-toggle-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3822 ;; misc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3823 (define-key edebug-mode-map "?" 'edebug-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3824 (define-key edebug-mode-map "d" 'edebug-backtrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3826 (define-key edebug-mode-map "-" 'negative-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3828 ;; statistics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3829 (define-key edebug-mode-map "=" 'edebug-temp-display-freq-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3831 ;; GUD bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3832 (define-key edebug-mode-map "\C-c\C-s" 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3833 (define-key edebug-mode-map "\C-c\C-n" 'edebug-next-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3834 (define-key edebug-mode-map "\C-c\C-c" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3836 (define-key edebug-mode-map "\C-x " 'edebug-set-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3837 (define-key edebug-mode-map "\C-c\C-d" 'edebug-unset-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3838 (define-key edebug-mode-map "\C-c\C-t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3839 (function (lambda () (edebug-set-breakpoint t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3840 (define-key edebug-mode-map "\C-c\C-l" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3841 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3843 ;; Autoloading these global bindings doesn't make sense because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3844 ;; they cannot be used anyway unless Edebug is already loaded and active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3846 (defvar global-edebug-prefix "\^XX"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3847 "Prefix key for global edebug commands, available from any buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3849 (defvar global-edebug-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3850 "Global map of edebug commands, available from any buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3852 (if global-edebug-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3853 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3854 (setq global-edebug-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3856 (global-unset-key global-edebug-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3857 (global-set-key global-edebug-prefix global-edebug-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3859 (define-key global-edebug-map " " 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3860 (define-key global-edebug-map "g" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3861 (define-key global-edebug-map "G" 'edebug-Go-nonstop-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3862 (define-key global-edebug-map "t" 'edebug-trace-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3863 (define-key global-edebug-map "T" 'edebug-Trace-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3864 (define-key global-edebug-map "c" 'edebug-continue-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3865 (define-key global-edebug-map "C" 'edebug-Continue-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3867 ;; breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3868 (define-key global-edebug-map "b" 'edebug-set-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3869 (define-key global-edebug-map "u" 'edebug-unset-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3870 (define-key global-edebug-map "x" 'edebug-set-conditional-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3871 (define-key global-edebug-map "X" 'edebug-set-global-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3873 ;; views
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3874 (define-key global-edebug-map "w" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3875 (define-key global-edebug-map "W" 'edebug-toggle-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3877 ;; quitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3878 (define-key global-edebug-map "q" 'top-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3879 (define-key global-edebug-map "Q" 'edebug-top-level-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3880 (define-key global-edebug-map "a" 'abort-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3882 ;; statistics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3883 (define-key global-edebug-map "=" 'edebug-display-freq-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3884 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3886 (defun edebug-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3887 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3888 (describe-function 'edebug-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3890 (defun edebug-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3891 "Mode for Emacs Lisp buffers while in Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3893 In addition to all Emacs Lisp commands (except those that modify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3894 buffer) there are local and global key bindings to several Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3895 specific commands. E.g. `edebug-step-mode' is bound to \\[edebug-step-mode]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3896 in the Edebug buffer and \\<global-map>\\[edebug-step-mode] in any buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3898 Also see bindings for the eval list buffer, *edebug*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3900 The edebug buffer commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3901 \\{edebug-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3903 Global commands prefixed by `global-edebug-prefix':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3904 \\{global-edebug-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3906 Options:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3907 edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3908 edebug-all-defs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3909 edebug-all-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3910 edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3911 edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3912 edebug-initial-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3913 edebug-trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3914 edebug-test-coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3915 edebug-continue-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3916 edebug-print-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3917 edebug-print-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3918 edebug-print-circle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3919 edebug-on-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3920 edebug-on-quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3921 edebug-on-signal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3922 edebug-unwrap-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3923 edebug-global-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3924 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3925 (use-local-map edebug-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3926
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3927 ;;; edebug eval list mode
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
3928
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3929 ;; A list of expressions and their evaluations is displayed in *edebug*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3931 (defun edebug-eval-result-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3932 "Return a list of evaluations of edebug-eval-list"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3933 ;; Assumes in outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3934 ;; Don't do any edebug things now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3935 (let ((edebug-execution-mode 'Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3936 (edebug-trace nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3937 (mapcar 'edebug-safe-eval edebug-eval-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3939 (defun edebug-eval-display-list (edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3940 ;; Assumes edebug-eval-buffer exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3941 (let ((edebug-eval-list-temp edebug-eval-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3942 (standard-output edebug-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3943 (edebug-comment-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3944 (format ";%s\n" (make-string (- (window-width) 2) ?-))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3945 (set-buffer edebug-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3946 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3947 (while edebug-eval-list-temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3948 (prin1 (car edebug-eval-list-temp)) (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3949 (prin1 (car edebug-eval-result-list)) (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3950 (princ edebug-comment-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3951 (setq edebug-eval-list-temp (cdr edebug-eval-list-temp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3952 (setq edebug-eval-result-list (cdr edebug-eval-result-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3953 (edebug-pop-to-buffer edebug-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3954 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3956 (defun edebug-create-eval-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3957 (if (not (and edebug-eval-buffer (buffer-name edebug-eval-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3958 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3959 (set-buffer (setq edebug-eval-buffer (get-buffer-create "*edebug*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3960 (edebug-eval-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3962 ;; Should generalize this to be callable outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3963 ;; with calls in user functions, e.g. (edebug-eval-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3965 (defun edebug-eval-display (edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3966 "Display expressions and evaluations in EVAL-LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3967 It modifies the context by popping up the eval display."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3968 (if edebug-eval-result-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3969 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3970 (edebug-create-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3971 (edebug-eval-display-list edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3972 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3974 (defun edebug-eval-redisplay ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3975 "Redisplay eval list in outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3976 May only be called from within edebug-recursive-edit."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3977 (edebug-create-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3978 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3979 (edebug-eval-display-list (edebug-eval-result-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3980 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3982 (defun edebug-visit-eval-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3983 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3984 (edebug-eval-redisplay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3985 (edebug-pop-to-buffer edebug-eval-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3988 (defun edebug-update-eval-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3989 "Replace the evaluation list with the sexps now in the eval buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3990 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3991 (let ((starting-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3992 new-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3993 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3994 ;; get the first expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3995 (edebug-skip-whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3996 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3997 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3998 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3999 (setq new-list (cons (edebug-last-sexp) new-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4001 (while (re-search-forward "^;" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4002 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4003 (skip-chars-forward " \t\n\r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4004 (if (and (/= ?\; (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4005 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4006 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4007 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4008 (setq new-list (cons (edebug-last-sexp) new-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4010 (setq edebug-eval-list (nreverse new-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4011 (edebug-eval-redisplay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4012 (goto-char starting-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4015 (defun edebug-delete-eval-item ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4016 "Delete the item under point and redisplay."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4017 ;; could add arg to do repeatedly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4018 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4019 (if (re-search-backward "^;" nil 'nofail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4020 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4021 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4022 (point) (progn (re-search-forward "^;" nil 'nofail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4023 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4024 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4025 (edebug-update-eval-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4029 (defvar edebug-eval-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4030 "Keymap for edebug-eval-mode. Superset of lisp-interaction-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4032 (if edebug-eval-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4033 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4034 (setq edebug-eval-mode-map (copy-keymap lisp-interaction-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4035
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4036 (define-key edebug-eval-mode-map "\C-c\C-w" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4037 (define-key edebug-eval-mode-map "\C-c\C-d" 'edebug-delete-eval-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4038 (define-key edebug-eval-mode-map "\C-c\C-u" 'edebug-update-eval-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4039 (define-key edebug-eval-mode-map "\C-x\C-e" 'edebug-eval-last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4040 (define-key edebug-eval-mode-map "\C-j" 'edebug-eval-print-last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4041 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4044 (defun edebug-eval-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4045 "Mode for evaluation list buffer while in Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4047 In addition to all Interactive Emacs Lisp commands there are local and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4048 global key bindings to several Edebug specific commands. E.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4049 `edebug-step-mode' is bound to \\[edebug-step-mode] in the Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4050 buffer and \\<global-map>\\[edebug-step-mode] in any buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4052 Eval list buffer commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4053 \\{edebug-eval-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4055 Global commands prefixed by global-edebug-prefix:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4056 \\{global-edebug-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4057 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4058 (lisp-interaction-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4059 (setq major-mode 'edebug-eval-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4060 (setq mode-name "Edebug-Eval")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4061 (use-local-map edebug-eval-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4062
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4063 ;;; Interface with standard debugger.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4065 ;; (setq debugger 'edebug) ; to use the edebug debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4066 ;; (setq debugger 'debug) ; use the standard debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4067
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4068 ;; Note that debug and its utilities must be byte-compiled to work,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4069 ;; since they depend on the backtrace looking a certain way. But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4070 ;; edebug is not dependent on this, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4071
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4072 (defun edebug (&optional edebug-arg-mode &rest debugger-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4073 "Replacement for debug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4074 If we are running an edebugged function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4075 show where we last were. Otherwise call debug normally."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4076 ;; (message "entered: %s depth: %s edebug-recursion-depth: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4077 ;; edebug-entered (recursion-depth) edebug-recursion-depth) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4078 (if (and edebug-entered ; anything active?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4079 (eq (recursion-depth) edebug-recursion-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4080 (let (;; Where were we before the error occurred?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4081 (edebug-offset-index (car edebug-offset-indices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4082 ;; Bind variables required by edebug-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4083 (edebug-value (car debugger-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4084 edebug-breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4085 edebug-break-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4086 edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4087 edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4088 (edebug-break (null edebug-arg-mode)) ;; if called explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4089 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4090 (edebug-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4091 (if (eq edebug-arg-mode 'error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4092 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4093 edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4095 ;; Otherwise call debug normally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4096 ;; Still need to remove extraneous edebug calls from stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4097 (apply 'debug edebug-arg-mode debugger-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4098 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4101 (defun edebug-backtrace ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4102 "Display a non-working backtrace. Better than nothing..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4103 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4104 (if (or (not edebug-backtrace-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4105 (null (buffer-name edebug-backtrace-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4106 (setq edebug-backtrace-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4107 (generate-new-buffer "*Backtrace*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4108 ;; else, could just display edebug-backtrace-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4109 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4110 (with-output-to-temp-buffer (buffer-name edebug-backtrace-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4111 (setq edebug-backtrace-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4112 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4113 (print-length 50)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4114 last-ok-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4115 (backtrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4117 ;; Clean up the backtrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4118 ;; Not quite right for current edebug scheme.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4119 (set-buffer edebug-backtrace-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4120 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4121 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4122 (setq last-ok-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4123 (if t (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4125 ;; Delete interspersed edebug internals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4126 (while (re-search-forward "^ \(?edebug" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4127 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4128 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4129 ((looking-at "^ \(edebug-after")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4130 ;; Previous lines may contain code, so just delete this line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4131 (setq last-ok-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4132 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4133 (delete-region last-ok-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4135 ((looking-at "^ edebug")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4136 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4137 (delete-region last-ok-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4138 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4139 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4141
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4142 ;;; Trace display
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4144 (defun edebug-trace-display (buf-name fmt &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4145 "In buffer BUF-NAME, display FMT and ARGS at the end and make it visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4146 The buffer is created if it does not exist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4147 You must include newlines in FMT to break lines, but one newline is appended."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4148 ;; e.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4149 ;; (edebug-trace-display "*trace-point*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4150 ;; "saving: point = %s window-start = %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4151 ;; (point) (window-start))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4152 (let* ((oldbuf (current-buffer))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4153 (selected-window (selected-window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4154 (buffer (get-buffer-create buf-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4155 buf-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4156 ;; (message "before pop-to-buffer") (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4157 (edebug-pop-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4158 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4159 (setq buf-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4160 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4161 (insert (apply 'edebug-format fmt args) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4162 ;; Make it visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4163 (vertical-motion (- 1 (window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4164 (set-window-start buf-window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4165 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4166 ;; (set-window-point buf-window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4167 ;; (edebug-sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4168 (bury-buffer buffer)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4169 (select-window selected-window)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4170 (set-buffer oldbuf))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4171 buf-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4174 (defun edebug-trace (fmt &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4175 "Convenience call to edebug-trace-display using edebug-trace-buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4176 (apply 'edebug-trace-display edebug-trace-buffer fmt args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4178
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4179 ;;; Frequency count and coverage
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4181 (defun edebug-display-freq-count ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4182 "Display the frequency count data for each line of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4183 definition. The frequency counts are inserted as comment lines after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4184 each line, and you can undo all insertions with one `undo' command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4186 The counts are inserted starting under the `(' before an expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4187 or the `)' after an expression, or on the last char of a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4188 The counts are only displayed when they differ from previous counts on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4189 the same line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4191 If coverage is being tested, whenever all known results of an expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4192 are `eq', the char `=' will be appended after the count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4193 for that expression. Note that this is always the case for an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4194 expression only evaluated once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4196 To clear the frequency count and coverage data for a definition,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4197 reinstrument it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4198 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4199 (let* ((function (edebug-form-data-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4200 (counts (get function 'edebug-freq-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4201 (coverages (get function 'edebug-coverage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4202 (data (get function 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4203 (def-mark (car data)) ; mark at def start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4204 (edebug-points (nth 2 data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4205 (i (1- (length edebug-points)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4206 (last-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4207 (first-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4208 (start-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4209 (start-of-count-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4210 (last-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4211 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4212 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4213 ;; Traverse in reverse order so offsets are correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4214 (while (<= 0 i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4215 ;; Start at last expression in line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4216 (goto-char (+ def-mark (aref edebug-points i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4217 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4218 (setq start-of-line (- (point) def-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4219 last-index i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4221 ;; Find all indexes on same line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4222 (while (and (<= 0 (setq i (1- i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4223 (<= start-of-line (aref edebug-points i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4224 ;; Insert all the indices for this line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4225 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4226 (setq start-of-count-line (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4227 first-index i ; really last index for line above this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4228 last-count -1) ; cause first count to always appear.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4229 (insert ";#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4230 ;; i == first-index still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4231 (while (<= (setq i (1+ i)) last-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4232 (let ((count (aref counts i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4233 (coverage (aref coverages i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4234 (col (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4235 (goto-char (+ (aref edebug-points i) def-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4236 (- (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4237 (if (= ?\( (following-char)) 0 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4238 (insert (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4239 (max 0 (- col (- (point) start-of-count-line))) ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4240 (if (and (< 0 count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4241 (not (memq coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4242 '(unknown ok-coverage))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4243 "=" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4244 (if (= count last-count) "" (int-to-string count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4245 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4246 (setq last-count count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4247 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4248 (setq i first-index)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4250 (defun edebug-temp-display-freq-count ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4251 "Temporarily display the frequency count data for the current definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4252 It is removed when you hit any char."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4253 ;; This seems not to work with Emacs 18.59. It undoes too far.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4254 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4255 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4256 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4257 (edebug-display-freq-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4258 (setq unread-command-char (read-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4259 (undo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4261
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4262 ;;; Menus
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4264 (defun edebug-toggle (variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4265 (set variable (not (eval variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4266 (message "%s: %s" variable (eval variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4268 ;; We have to require easymenu (even for Emacs 18) just so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4269 ;; the easy-menu-define macro call is compiled correctly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4270 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4272 (defconst edebug-mode-menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4273 '("Edebug"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4274 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4275 ["Stop" edebug-stop t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4276 ["Step" edebug-step-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4277 ["Next" edebug-next-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4278 ["Trace" edebug-trace-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4279 ["Trace Fast" edebug-Trace-fast-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4280 ["Continue" edebug-continue-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4281 ["Continue Fast" edebug-Continue-fast-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4282 ["Go" edebug-go-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4283 ["Go Nonstop" edebug-Go-nonstop-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4284 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4285 ["Help" edebug-help t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4286 ["Abort" abort-recursive-edit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4287 ["Quit to Top Level" top-level t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4288 ["Quit Nonstop" edebug-top-level-nonstop t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4289 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4290 ("Jumps"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4291 ["Forward Sexp" edebug-forward-sexp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4292 ["Step In" edebug-step-in t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4293 ["Step Out" edebug-step-out t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4294 ["Goto Here" edebug-goto-here t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4296 ("Breaks"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4297 ["Set Breakpoint" edebug-set-breakpoint t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4298 ["Unset Breakpoint" edebug-unset-breakpoint t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4299 ["Set Conditional Breakpoint" edebug-set-conditional-breakpoint t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4300 ["Set Global Break Condition" edebug-set-global-break-condition t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4301 ["Show Next Breakpoint" edebug-next-breakpoint t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4303 ("Views"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4304 ["Where am I?" edebug-where t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4305 ["Bounce to Current Point" edebug-bounce-point t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4306 ["View Outside Windows" edebug-view-outside t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4307 ["Previous Result" edebug-previous-result t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4308 ["Show Backtrace" edebug-backtrace t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4309 ["Display Freq Count" edebug-display-freq-count t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4311 ("Eval"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4312 ["Expression" edebug-eval-expression t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4313 ["Last Sexp" edebug-eval-last-sexp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4314 ["Visit Eval List" edebug-visit-eval-list t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4316 ("Options"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4317 ["Edebug All Defs" edebug-all-defs t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4318 ["Edebug All Forms" edebug-all-forms t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4319 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4320 ["Toggle Tracing" (edebug-toggle 'edebug-trace) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4321 ["Toggle Coverage Testing" (edebug-toggle 'edebug-test-coverage) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4322 ["Toggle Window Saving" edebug-toggle-save-windows t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4323 ["Toggle Point Saving"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4324 (edebug-toggle 'edebug-save-displayed-buffer-points) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4325 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4326 "XEmacs style menus for Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4328
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4329 ;;; Emacs version specific code
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4330
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4331 ;;; The default for all above is Emacs 18, because it is easier to compile
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4332 ;;; Emacs 18 code in Emacs 19 than vice versa. This default will
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4333 ;;; change once most people are using Emacs 19 or derivatives.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4334
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4335 ;; Epoch specific code is in a separate file: edebug-epoch.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4337 ;; The byte-compiler will complain about changes in number of arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4338 ;; to functions like mark and read-from-minibuffer. These warnings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4339 ;; may be ignored because the right call should always be made.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4341 (defun edebug-emacs-19-specific ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4343 (defalias 'edebug-window-live-p 'window-live-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4345 ;; Mark takes an argument in Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4346 (defun edebug-mark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4347 (mark t));; Does this work for XEmacs too?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4349 ;; Use minibuffer-history when reading expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4350 (defvar read-expression-history) ;; hush bytecomp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4351 (defvar read-expression-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4353 (defun edebug-set-conditional-breakpoint (arg condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4354 "Set a conditional breakpoint at nearest sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4355 The condition is evaluated in the outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4356 With prefix argument, make it a temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4357 ;; (interactive "P\nxCondition: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4358 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4359 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4360 current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4361 ;; Read condition as follows; getting previous condition is cumbersome:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4362 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4363 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4364 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4365 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4366 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4367 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4368 (edebug-break-data (assq index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4369 (edebug-break-condition (car (cdr edebug-break-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4370 (edebug-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4371 ;; Prepend the current condition, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4372 (if edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4373 (cons edebug-break-condition read-expression-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4374 read-expression-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4375 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4376 (read-from-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4377 "Condition: " nil read-expression-map t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4378 'edebug-expression-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4379 (setq read-expression-history edebug-expression-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4380 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4381 (edebug-modify-breakpoint t condition arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4383 (defun edebug-eval-expression (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4384 "Evaluate an expression in the outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4385 If interactive, prompt for the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4386 Print result in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4387 (interactive (list (read-from-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4388 "Eval: " nil read-expression-map t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4389 'read-expression-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4390 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4391 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4392 (setq values (cons (edebug-eval edebug-expr) values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4393 (edebug-safe-prin1-to-string (car values)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4395 (easy-menu-define edebug-menu edebug-mode-map "Edebug menus" edebug-mode-menus)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4396 (if (eq (console-type) 'x) ; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4397 (x-popup-menu nil (lookup-key edebug-mode-map [menu-bar Edebug])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4398 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4401 (defun edebug-xemacs-specific ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4403 ;; We need to bind zmacs-regions to nil around all calls to `mark' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4404 ;; `mark-marker' but don't bind it to nil before entering a recursive edit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4405 ;; that is, don't interfere with the binding the user might see while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4406 ;; executing a command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4408 (defvar zmacs-regions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4410 (defun edebug-mark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4411 (let ((zmacs-regions nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4412 (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4414 (defun edebug-mark-marker ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4415 (let ((zmacs-regions nil));; for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4416 (mark-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4419 (defun edebug-mode-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4420 (interactive "@event")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4421 (popup-menu edebug-mode-menus))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4423 (define-key edebug-mode-map 'button3 'edebug-mode-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4424 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4426 (defun edebug-emacs-version-specific ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4427 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4428 ((string-match "XEmacs" emacs-version);; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4429 (edebug-xemacs-specific))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4431 ((and (boundp 'epoch::version) epoch::version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4432 (require 'edebug-epoch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4434 ((not (string-match "^18" emacs-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4435 (edebug-emacs-19-specific))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4437 (edebug-emacs-version-specific)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4439
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4440 ;;; Byte-compiler
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4441
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4442 ;; Extension for bytecomp to resolve undefined function references.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4443 ;; Requires new byte compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4445 ;; Reenable byte compiler warnings about unread-command-char and -event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4446 ;; Disabled before edebug-recursive-edit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4447 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4448 (if edebug-unread-command-char-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4449 (put 'unread-command-char 'byte-obsolete-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4450 edebug-unread-command-char-warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4451 (if edebug-unread-command-event-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4452 (put 'unread-command-event 'byte-obsolete-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4453 edebug-unread-command-event-warning)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4455 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4456 ;; The body of eval-when-compile seems to get evaluated with eval-defun.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4457 ;; We only want to evaluate when actually byte compiling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4458 ;; But it is OK to evaluate as long as byte-compiler has been loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4459 (if (featurep 'byte-compile) (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4461 (defun byte-compile-resolve-functions (funcs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4462 "Say it is OK for the named functions to be unresolved."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4463 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4464 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4465 (lambda (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4466 (setq byte-compile-unresolved-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4467 (delq (assq func byte-compile-unresolved-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4468 byte-compile-unresolved-functions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4469 funcs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4470 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4472 '(defun byte-compile-resolve-free-references (vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4473 "Say it is OK for the named variables to be referenced."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4474 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4475 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4476 (lambda (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4477 (setq byte-compile-free-references
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4478 (delq var byte-compile-free-references))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4479 vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4480 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4482 '(defun byte-compile-resolve-free-assignments (vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4483 "Say it is OK for the named variables to be assigned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4484 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4485 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4486 (lambda (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4487 (setq byte-compile-free-assignments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4488 (delq var byte-compile-free-assignments))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4489 vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4490 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4492 (byte-compile-resolve-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4493 '(reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4494 edebug-gensym ;; also in cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4495 ;; Interfaces to standard functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4496 edebug-original-eval-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4497 edebug-original-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4498 edebug-get-buffer-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4499 edebug-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4500 edebug-mark-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4501 edebug-input-pending-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4502 edebug-sit-for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4503 edebug-prin1-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4504 edebug-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4505 edebug-original-signal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4506 ;; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4507 zmacs-deactivate-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4508 popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4509 ;; CL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4510 cl-macroexpand-all
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4511 ;; And believe it or not, the byte compiler doesn't know about:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4512 byte-compile-resolve-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4513 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4515 '(byte-compile-resolve-free-references
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4516 '(read-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4517 read-expression-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4519 '(byte-compile-resolve-free-assignments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4520 '(read-expression-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4522 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4524
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4525 ;;; Autoloading of Edebug accessories
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4527 (if (featurep 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4528 (add-hook 'edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4529 (function (lambda () (require 'cl-specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4530 ;; The following causes cl-specs to be loaded if you load cl.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4531 (add-hook 'cl-load-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4532 (function (lambda () (require 'cl-specs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4534 ;;; edebug-cl-read and cl-read are available from liberte@cs.uiuc.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4535 (if (featurep 'cl-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4536 (add-hook 'edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4537 (function (lambda () (require 'edebug-cl-read))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4538 ;; The following causes edebug-cl-read to be loaded when you load cl-read.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4539 (add-hook 'cl-read-load-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4540 (function (lambda () (require 'edebug-cl-read)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4542
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4543 ;;; Finalize Loading
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4544
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4545 ;;; Finally, hook edebug into the rest of Emacs.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
4546 ;;; There are probably some other things that could go here.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4548 ;; Install edebug read and eval functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4549 (edebug-install-read-eval-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4551 (provide 'edebug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4553 ;;; edebug.el ends here