annotate lisp/edebug/edebug.el @ 161:28f395d8dc7a r20-3b7

Import from CVS: tag r20-3b7
author cvs
date Mon, 13 Aug 2007 09:42:26 +0200
parents b980b6286996
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; 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
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
8 ;; This file is part of XEmacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
9
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
11 ;; under the terms of the GNU General Public License as published by
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
13 ;; any later version.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
14
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
18 ;; General Public License for more details.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
19
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
20 ;; You should have received a copy of the GNU General Public License
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
23 ;; 02111-1307, USA.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
24
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
25 ;;; Synched up with: FSF 19.34.
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
26
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
27 ;;; Commentary:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
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.
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
32 ;; |$Date: 1997/06/14 20:30:57 $|$Revision: 1.6 $|~/modes/edebug.el|
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
33
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
34 ;; This minor mode allows programmers to step through Emacs Lisp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
35 ;; source code while executing functions. You can also set
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
36 ;; breakpoints, trace (stopping at each expression), evaluate
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
37 ;; expressions as if outside Edebug, reevaluate and display a list of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
38 ;; expressions, trap errors normally caught by debug, and display a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
39 ;; debug style backtrace.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
40
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
41 ;;; Installation
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
42 ;; =============
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
43
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
44 ;; Put edebug.el in some directory in your load-path and
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
45 ;; byte-compile it. Also read the beginning of edebug-epoch.el,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
46 ;; cl-specs.el, and edebug-cl-read.el if they apply to you.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
47
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
48 ;; Unless you are using Emacs 19 which is already set up to use Edebug,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
49 ;; put the following forms in your .emacs file.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
50 ;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
51 ;; (autoload 'edebug-eval-top-level-form "edebug")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
52
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
53 ;; If you wish to change the default edebug global command prefix, change:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
54 ;; (setq edebug-global-prefix "\C-xX")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
55
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
56 ;; Other options, are described in the manual.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
57
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
58 ;; In previous versions of Edebug, users were directed to set
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
59 ;; `debugger' to `edebug-debug'. This is no longer necessary
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
60 ;; since Edebug automatically sets it whenever Edebug is active.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
61
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
62 ;;; Minimal Instructions
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
63 ;; =====================
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
64
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
65 ;; First evaluate a defun with C-xx, then run the function. Step
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
66 ;; through the code with SPC, mark breakpoints with b, go until a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
67 ;; breakpoint is reached with g, and quit execution with q. Use the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
68 ;; "?" command in edebug to describe other commands. See edebug.tex
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
69 ;; or the Emacs 19 Lisp Reference Manual for more instructions.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
70
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
71 ;; Send me your enhancements, ideas, bugs, or fixes.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
72 ;; For bugs, you can call edebug-submit-bug-report if you have reporter.el.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
73 ;; There is an edebug mailing list if you want to keep up
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
74 ;; with the latest developments. Requests to: edebug-request@cs.uiuc.edu
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
75
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
76 ;; Daniel LaLiberte 217-398-4114
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
77 ;; University of Illinois, Urbana-Champaign
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
78 ;; Department of Computer Science
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
79 ;; 1304 W Springfield
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
80 ;; Urbana, IL 61801
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
81
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
82 ;; uiucdcs!liberte
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
83 ;; liberte@cs.uiuc.edu
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
84
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
85 ;; For the early revision history, see edebug-history.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
86
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
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
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
90 (let ((raw-version "$Revision: 1.6 $"))
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
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
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
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
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
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
129 ;;; Options
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
131 (defgroup edebug nil
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
132 "A source-level debugger for Emacs Lisp"
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
133 :group 'lisp)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
134
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
135
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (defvar edebug-setup-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "*Functions to call before edebug is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 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
139 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
140 to load up Edebug specifications associated with a package you are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 using but only when you also use Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
143 (defcustom edebug-all-defs nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 "*If non-nil, evaluation of any defining forms will instrument for Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 This applies to `eval-defun', `eval-region', `eval-buffer', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 `eval-current-buffer'. `eval-region' is also called by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 `eval-last-sexp', and `eval-print-last-sexp'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 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
150 variable. You may wish to make it local to each buffer with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 \(make-local-variable 'edebug-all-defs) in your
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
152 `emacs-lisp-mode-hook'."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
153 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
154 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
155
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
156 (defcustom edebug-all-forms nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 "*Non-nil evaluation of all forms will instrument for Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 This doesn't apply to loading or evaluations in the minibuffer.
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
159 Use the command `edebug-all-forms' to toggle the value of this option."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
160 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
161 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
162
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
163 (defcustom edebug-eval-macro-args nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "*Non-nil means all macro call arguments may be evaluated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 If this variable is nil, the default, Edebug will *not* wrap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 macro call arguments as if they will be evaluated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 For each macro, a `edebug-form-spec' overrides this option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 So to specify exceptions for macros that have some arguments evaluated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 and some not, you should specify an `edebug-form-spec'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
171 This option is going away soon."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
172 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
173 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
174
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
175 (defcustom edebug-stop-before-symbols nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "*Non-nil causes Edebug to stop before symbols as well as after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 In any case, a breakpoint or interrupt may stop before a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
179 This option is going away soon."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
180 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
181 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
182
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
183 (defcustom edebug-save-windows t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 "*If non-nil, Edebug saves and restores the window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 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
186 the window configurations, it is better to set this variable to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 If the value is a list, only the listed windows are saved and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 restored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
191 `edebug-toggle-save-windows' may be used to change this variable."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
192 :type '(choice boolean (repeat string))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
193 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
194
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
195 (defcustom edebug-save-displayed-buffer-points nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "*If non-nil, save and restore point in all displayed buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 Saving and restoring point in other buffers is necessary if you are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 debugging code that changes the point of a buffer which is displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 in a non-selected window. If Edebug or the user then selects the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 window, the buffer's point will be changed to the window's point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 Saving and restoring point in all buffers is expensive, since it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 requires selecting each window twice, so enable this only if you need
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
205 it."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
206 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
207 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
208
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
209 (defcustom edebug-initial-mode 'step
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "*Initial execution mode for Edebug, if non-nil. If this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 is non-@code{nil}, it specifies the initial execution mode for Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 when it is first activated. Possible values are step, next, go,
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
213 Go-nonstop, trace, Trace-fast, continue, and Continue-fast."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
214 :type '(choice (const step) (const next) (const go)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
215 (const Go-nonstop) (const trace)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
216 (const Trace-fast) (const continue)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
217 (const continue-fast))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
218 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
219
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
220 (defcustom edebug-trace nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "*Non-nil means display a trace of function entry and exit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 Tracing output is displayed in a buffer named `*edebug-trace*', one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 function entry or exit per line, indented by the recursion level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 You can customize by replacing functions `edebug-print-trace-before'
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
226 and `edebug-print-trace-after'."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
227 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
228 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
229
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
230 (defcustom edebug-test-coverage nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 "*If non-nil, Edebug tests coverage of all expressions debugged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 This is done by comparing the result of each expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 with the previous result. Coverage is considered OK if two different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 results are found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 Use `edebug-display-freq-count' to display the frequency count and
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
237 coverage information for a definition."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
238 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
239 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
240
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
241 (defcustom edebug-continue-kbd-macro nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 "*If non-nil, continue defining or executing any keyboard macro.
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
243 Use this with caution since it is not debugged."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
244 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
245 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
246
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
247
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
248 (defcustom edebug-print-length 50
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
249 "*Default value of `print-length' to use while printing results in Edebug."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
250 :type 'integer
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
251 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
252 (defcustom edebug-print-level 50
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
253 "*Default value of `print-level' to use while printing results in Edebug."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
254 :type 'integer
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
255 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
256 (defcustom edebug-print-circle t
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
257 "*Default value of `print-circle' to use while printing results in Edebug."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
258 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
259 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
260
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
261 (defcustom edebug-unwrap-results nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "*Non-nil if Edebug should unwrap results of expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 This is useful when debugging macros where the results of expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 are instrumented expressions. But don't do this when results might be
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
265 circular or an infinite loop will result."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
266 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
267 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
268
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
269 (defcustom edebug-on-error t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 "*Value bound to `debug-on-error' while Edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 If `debug-on-error' is non-nil, that value is still used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 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
275 these errors are signaled from Lisp code whether or not the signal is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 handled by a `condition-case'. This option is useful for debugging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 signals that *are* handled since they would otherwise be missed.
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
278 After execution is resumed, the error is signaled again."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
279 :type '(choice boolean (repeat string))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
280 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
281
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
282 (defcustom edebug-on-quit t
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
283 "*Value bound to `debug-on-quit' while Edebug is active."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
284 :type 'boolean
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
285 :group 'edebug)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
286
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
287 (defcustom edebug-global-break-condition nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "*If non-nil, an expression to test for at every stop point.
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
289 If the result is non-nil, then break. Errors are ignored."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
290 :type 'sexp
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 124
diff changeset
291 :group 'edebug)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
293 ;;; Form spec utilities.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (defmacro def-edebug-spec (symbol spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "Set the edebug-form-spec property of SYMBOL according to SPEC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 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
299 \(naming a function), or a list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (` (put (quote (, symbol)) 'edebug-form-spec (quote (, spec)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defmacro def-edebug-form-spec (symbol spec-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "For compatibility with old version. Use `def-edebug-spec' instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (message "Obsolete: use def-edebug-spec instead.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (def-edebug-spec symbol (eval spec-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (defun get-edebug-spec (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;; Get the spec of symbol resolving all indirection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (let ((edebug-form-spec (get symbol 'edebug-form-spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 indirect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (while (and (symbolp edebug-form-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (setq indirect (get edebug-form-spec 'edebug-form-spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; (edebug-trace "indirection: %s" edebug-form-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (setq edebug-form-spec indirect))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 edebug-form-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
318 ;;; Utilities
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;; Define edebug-gensym - from old cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (defvar edebug-gensym-index 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 "Integer used by `edebug-gensym' to produce new names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (defun edebug-gensym (&optional prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 "Generate a fresh uninterned symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 There is an optional argument, PREFIX. PREFIX is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 string that begins the new name. Most people take just the default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 except when debugging needs suggest otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (if (null prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (setq prefix "G"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (let ((newsymbol nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (newname ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (while (not newsymbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (setq newname (concat prefix (int-to-string edebug-gensym-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (setq edebug-gensym-index (+ edebug-gensym-index 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (if (not (intern-soft newname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (setq newsymbol (make-symbol newname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 newsymbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;; Only used by CL-like code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (defun edebug-keywordp (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 "Return t if OBJECT is a keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 A keyword is a symbol that starts with `:'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (and (symbolp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (= ?: (aref (symbol-name object) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defun edebug-lambda-list-keywordp (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Return t if OBJECT is a lambda list keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 A lambda list keyword is a symbol that starts with `&'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (and (symbolp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (= ?& (aref (symbol-name object) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defun edebug-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;; Return the last sexp before point in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;; Assumes Emacs Lisp syntax is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (read-from-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (forward-sexp -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (defun edebug-window-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 "Return a list of windows, in order of `next-window'."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
367 ;; This doesn't work for epoch.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (let* ((first-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (window-list (list first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (next (next-window first-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (while (not (eq next first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (setq window-list (cons next window-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (setq next (next-window next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (nreverse window-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun edebug-window-live-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "Return non-nil if WINDOW is visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (let* ((first-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (next (next-window first-window t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (while (not (or (eq next window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (eq next first-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (setq next (next-window next t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (eq next window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;; Not used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 '(defun edebug-two-window-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 "Return t if there are two windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (and (not (one-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (eq (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (next-window (next-window (selected-window))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defsubst edebug-lookup-function (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (while (and (symbolp object) (fboundp object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (setq object (symbol-function object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (defun edebug-macrop (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 "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
399 (setq object (edebug-lookup-function object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (if (and (listp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (eq 'macro (car object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (edebug-functionp (cdr object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (defun edebug-functionp (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 "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
407 (setq object (edebug-lookup-function object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (if (or (subrp object)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
409 (compiled-function-p object) ; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (and (listp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (eq (car object) 'lambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (listp (car (cdr object)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (defun edebug-sort-alist (alist function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;; Return the ALIST sorted with comparison function FUNCTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ;; This uses 'sort so the sorting is destructive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (sort alist (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (lambda (e1 e2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (funcall function (car e1) (car e2))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;;(def-edebug-spec edebug-save-restriction t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;; 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
425 '(defmacro edebug-save-restriction (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 "Evaluate BODY while saving the current buffers restriction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 BODY may change buffer outside of current restriction, unlike
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 save-restriction. BODY may change the current buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 and the restriction will be restored to the original buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 and the current buffer remains current.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 Return the result of the last expression in BODY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (` (let ((edebug:s-r-beg (point-min-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (edebug:s-r-end (point-max-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (progn (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (set-buffer (marker-buffer edebug:s-r-beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (narrow-to-region edebug:s-r-beg edebug:s-r-end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
440 ;;; Display
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (defconst edebug-trace-buffer "*edebug-trace*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 "Name of the buffer to put trace info in.")
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-pop-to-buffer (buffer &optional window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;; Like pop-to-buffer, but select window where BUFFER was last shown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; Select WINDOW if it provided and it still exists. Otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;; if buffer is currently shown in several windows, choose one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ;; Otherwise, find a new window, possibly splitting one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (setq window (if (and (windowp window) (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (eq (window-buffer window) buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if (eq (window-buffer (selected-window)) buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (edebug-get-buffer-window buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (one-window-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (split-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;; (message "next window: %s" (next-window)) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (if (eq (get-buffer-window edebug-trace-buffer) (next-window))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
462 ;; Don't select trace window
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (select-window (next-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (set-window-buffer (selected-window) buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (set-window-hscroll (selected-window) 0);; should this be??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; Selecting the window does not set the buffer until command loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;;(set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (defun edebug-get-displayed-buffer-points ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;; Return a list of buffer point pairs, for all displayed buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (let* ((first-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (next (next-window first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (buffer-point-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (while (not (eq next first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (set-buffer (setq buffer (window-buffer next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (setq buffer-point-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (cons (cons buffer (point)) buffer-point-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (setq next (next-window next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 buffer-point-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (defun edebug-set-buffer-points (buffer-points)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; Restore the buffer-points created by edebug-get-displayed-buffer-points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (let ((current-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (mapcar (function (lambda (buf-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (if (buffer-name (car buf-point)) ; still exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (set-buffer (car buf-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (goto-char (cdr buf-point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 buffer-points)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (set-buffer current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (defun edebug-current-windows (which-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; Get either a full window configuration or some window information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (if (listp which-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (mapcar (function (lambda (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (if (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (list window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (window-buffer window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (window-point window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (window-start window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (window-hscroll window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 which-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (defun edebug-set-windows (window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; Set either a full window configuration or some window information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (if (listp window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (lambda (one-window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (if one-window-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (apply (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (lambda (window buffer point start hscroll)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (if (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (set-window-buffer window buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (set-window-point window point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (set-window-start window start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (set-window-hscroll window hscroll)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 one-window-info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (set-window-configuration window-info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (defalias 'edebug-get-buffer-window 'get-buffer-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (defalias 'edebug-sit-for 'sit-for)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (defalias 'edebug-input-pending-p 'input-pending-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
534 ;;; Redefine read and eval functions
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
535 ;; read is redefined to maybe instrument forms.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
536 ;; eval-defun is redefined to check edebug-all-forms and edebug-all-defs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
537
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
538 ;; Use the Lisp version of eval-region.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (require 'eval-reg "eval-reg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ;; Save the original read function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (or (fboundp 'edebug-original-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (defalias 'edebug-original-read (symbol-function 'read)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (defun edebug-read (&optional stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 "Read one Lisp expression as text from STREAM, return as Lisp object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 If STREAM is nil, use the value of `standard-input' (which see).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 STREAM or the value of `standard-input' may be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 a buffer (read from point and advance it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 a marker (read from where it points and advance it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 a function (call it with no arguments for each character,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 call it with a char as argument to push a char back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 a string (takes text from string, starting at the beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 t (read text line using minibuffer and use it).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 This version, from Edebug, maybe instruments the expression. But the
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
557 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
558 also dependent on the values of `edebug-all-defs' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 `edebug-all-forms'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (or stream (setq stream standard-input))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (if (eq stream (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (edebug-read-and-maybe-wrap-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (edebug-original-read stream)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (or (fboundp 'edebug-original-eval-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defalias 'edebug-original-eval-defun (symbol-function 'eval-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
568 ;; We should somehow arrange to be able to do this
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
569 ;; without actually replacing the eval-defun command.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (defun edebug-eval-defun (edebug-it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 "Evaluate the top-level form containing point, or after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 This version, from Edebug, has the following differences: With a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 prefix argument instrument the code for Edebug. If `edebug-all-defs' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 non-nil, then the code is instrumented *unless* there is a prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 argument. If instrumenting, it prints: `Edebug: FUNCTIONNAME'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 Otherwise, it prints in the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (interactive "P")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
579 (let* ((edebugging (not (eq (not edebug-it) (not edebug-all-defs))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
580 (edebug-result)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
581 (form
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
582 (let ((edebug-all-forms edebugging)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
583 (edebug-all-defs (eq edebug-all-defs (not edebug-it))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
584 (edebug-read-top-level-form))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
585 (if (and (eq (car form) 'defvar)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
586 (cdr-safe (cdr-safe form)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
587 (setq form (cons 'defconst (cdr form))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
588 (setq edebug-result (eval form))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (if (not edebugging)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (princ edebug-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 edebug-result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (defalias 'edebug-defun 'edebug-eval-top-level-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (defun edebug-eval-top-level-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 "Evaluate a top level form, such as a defun or defmacro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 This is like `eval-defun', but the code is always instrumented for Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 Print its name in the minibuffer and leave point where it is,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 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
603 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (eval
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
605 ;; Bind edebug-all-forms only while reading, not while evalling
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;; but this causes problems while edebugging edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (let ((edebug-all-forms t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (edebug-all-defs t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (edebug-read-top-level-form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (defun edebug-read-top-level-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (let ((starting-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (end-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (edebug-read-and-maybe-wrap-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;; Recover point, but only if no error occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (goto-char starting-point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;; Compatibility with old versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (defalias 'edebug-all-defuns 'edebug-all-defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (defun edebug-all-defs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 "Toggle edebugging of all definitions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (setq edebug-all-defs (not edebug-all-defs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (message "Edebugging all definitions is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (if edebug-all-defs "on" "off")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (defun edebug-all-forms ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "Toggle edebugging of all forms."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (setq edebug-all-forms (not edebug-all-forms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (message "Edebugging all forms is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (if edebug-all-forms "on" "off")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (defun edebug-install-read-eval-functions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;; Don't install if already installed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (eq (symbol-function 'read) 'edebug-read) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (elisp-eval-region-install)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (defalias 'read 'edebug-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (defalias 'eval-defun 'edebug-eval-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (defun edebug-uninstall-read-eval-functions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (elisp-eval-region-uninstall)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (defalias 'read (symbol-function 'edebug-original-read))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (defalias 'eval-defun (symbol-function 'edebug-original-eval-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
656 ;;; Edebug internal data
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
657
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
658 ;; The internal data that is needed for edebugging is kept in the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
659 ;; buffer-local variable `edebug-form-data'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 ;; XEmacs change?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (defconst edebug-form-data nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (make-variable-buffer-local 'edebug-form-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ;; A list of entries associating symbols with buffer regions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 ;; This is an automatic buffer local variable. Each entry looks like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 ;; @code{(@var{symbol} @var{begin-marker} @var{end-marker}). The markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;; 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
669 ;; a symbol that holds all edebug related information for the form on its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 ;; property list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;; In the future, the symbol will be irrelevant and edebug data will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;; be stored in the definitions themselves rather than in the property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;; list of a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (defun edebug-make-form-data-entry (symbol begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (list symbol begin end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (defsubst edebug-form-data-name (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (car entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (defsubst edebug-form-data-begin (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (nth 1 entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (defsubst edebug-form-data-end (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (nth 2 entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (defsubst edebug-set-form-data-entry (entry name begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (setcar entry name);; in case name is changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (set-marker (nth 1 entry) begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (set-marker (nth 2 entry) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (defun edebug-get-form-data-entry (pnt &optional end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ;; Find the edebug form data entry which is closest to PNT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;; If END-POINT is supplied, match must be exact.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ;; Return `nil' if none found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (let ((rest edebug-form-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 closest-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (closest-dist 999999)) ;; need maxint here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (while (and rest (< 0 closest-dist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (let* ((entry (car rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (begin (edebug-form-data-begin entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (dist (- pnt begin)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (setq rest (cdr rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (if (and (<= 0 dist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (< dist closest-dist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (or (not end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (= end-point (edebug-form-data-end entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (<= pnt (edebug-form-data-end entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (setq closest-dist dist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 closest-entry entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 closest-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 ;; Also need to find all contained entries,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 ;; and find an entry given a symbol, which should be just assq.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (defun edebug-form-data-symbol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 ;; Return the edebug data symbol of the form where point is in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ;; If point is not inside a edebuggable form, cause error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (or (edebug-form-data-name (edebug-get-form-data-entry (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (error "Not inside instrumented form")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (defun edebug-make-top-form-data-entry (new-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 ;; Make NEW-ENTRY the first element in the `edebug-form-data' list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (edebug-clear-form-data-entry new-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (setq edebug-form-data (cons new-entry edebug-form-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (defun edebug-clear-form-data-entry (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 ;; If non-nil, clear ENTRY out of the form data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 ;; Maybe clear the markers and delete the symbol's edebug property?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (if entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 ;; Instead of this, we could just find all contained forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ;; (put (car entry) 'edebug nil) ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ;; (mapcar 'edebug-clear-form-data-entry ; dangerous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ;; (get (car entry) 'edebug-dependents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ;; (set-marker (nth 1 entry) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;; (set-marker (nth 2 entry) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (setq edebug-form-data (delq entry edebug-form-data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
741 ;;; Parser utilities
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (defun edebug-syntax-error (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;; Signal an invalid-read-syntax with ARGS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (signal 'invalid-read-syntax args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (defconst edebug-read-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 ;; Lookup table for significant characters indicating the class of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;; token that follows. This is not a \"real\" syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (let ((table (make-vector 256 'symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (while (< i ?!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (aset table i 'space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (aset table ?\( 'lparen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (aset table ?\) 'rparen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (aset table ?\' 'quote)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
759 (aset table ?\` 'backquote)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
760 (aset table ?\, 'comma)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (aset table ?\" 'string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (aset table ?\? 'char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (aset table ?\[ 'lbracket)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (aset table ?\] 'rbracket)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (aset table ?\. 'dot)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (aset table ?\# 'hash)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ;; We treat numbers as symbols, because of confusion with -, -1, and 1-.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
768 ;; 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
769 table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (defun edebug-next-token-class ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 ;; Move to the next token and return its class. We only care about
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
773 ;; lparen, rparen, dot, quote, backquote, comma, string, char, vector,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
774 ;; or symbol.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (edebug-skip-whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (aref edebug-read-syntax-table (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (defun edebug-skip-whitespace ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;; Leave point before the next token, skipping white space and comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (skip-chars-forward " \t\r\n\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (while (= (following-char) ?\;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 ;; \r is counted as a comment terminator to support selective display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (skip-chars-forward "^\n\r") ; skip the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (skip-chars-forward " \t\r\n\f")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 ;; Mostly obsolete reader; still used in one case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (defun edebug-read-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;; Read one sexp from the current buffer starting at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ;; Leave point immediately after it. A sexp can be a list or atom.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;; An atom is a symbol (or number), character, string, or vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 ;; This works for reading anything legitimate, but it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ;; is gummed up by parser inconsistencies (bugs?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (let ((class (edebug-next-token-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 ;; read goes one too far if a (possibly quoted) string or symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 ;; is immediately followed by non-whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ((eq class 'symbol) (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (edebug-original-read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (if (not (eq (aref edebug-read-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (preceding-char)) 'symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 ((eq class 'string) (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (edebug-original-read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (if (/= (preceding-char) ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ((eq class 'quote) (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (list 'quote (edebug-read-sexp)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
811 ((eq class 'backquote)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
812 (list '\` (edebug-read-sexp)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
813 ((eq class 'comma)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
814 (list '\, (edebug-read-sexp)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (t ; anything else, just read it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (edebug-original-read (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
818 ;;; Offsets for reader
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;; Define a structure to represent offset positions of expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 ;; Each offset structure looks like: (before . after) for constituents,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 ;; or for structures that have elements: (before <subexpressions> . after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 ;; where the <subexpressions> are the offset structures for subexpressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; including the head of a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (defconst edebug-offsets nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; Stack of offset structures in reverse order of the nesting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ;; This is used to get back to previous levels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (defconst edebug-offsets-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (defconst edebug-current-offset nil) ; Top of the stack, for convenience.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; 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
833 ;; is itself a list. This structure will be condensed, so the offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;; must also be condensed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (defconst edebug-read-dotted-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (defsubst edebug-initialize-offsets ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 ;; Reinitialize offset recording.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (setq edebug-current-offset nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (defun edebug-store-before-offset (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;; Add a new offset pair with POINT as the before offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (let ((new-offset (list point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (if edebug-current-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (setcdr edebug-current-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (cons new-offset (cdr edebug-current-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ;; Otherwise, we are at the top level, so initialize.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (setq edebug-offsets new-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 edebug-offsets-stack nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 edebug-read-dotted-list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ;; Cons the new offset to the front of the stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (setq edebug-offsets-stack (cons new-offset edebug-offsets-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 edebug-current-offset new-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (defun edebug-store-after-offset (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 ;; Finalize the current offset struct by reversing it and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ;; store POINT as the after offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (if (not edebug-read-dotted-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;; Just reverse the offsets of all subexpressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (setcdr edebug-current-offset (nreverse (cdr edebug-current-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ;; We just read a list after a dot, which will be abbreviated out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (setq edebug-read-dotted-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 ;; Drop the corresponding offset pair.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 ;; That is, nconc the reverse of the rest of the offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;; with the cdr of last offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (setcdr edebug-current-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (nconc (nreverse (cdr (cdr edebug-current-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (cdr (car (cdr edebug-current-offset))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ;; Now append the point using nconc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (setq edebug-current-offset (nconc edebug-current-offset point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ;; Pop the stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (setq edebug-offsets-stack (cdr edebug-offsets-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 edebug-current-offset (car edebug-offsets-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (defun edebug-ignore-offset ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ;; Ignore the last created offset pair.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (setcdr edebug-current-offset (cdr (cdr edebug-current-offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (def-edebug-spec edebug-storing-offsets (form body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (put 'edebug-storing-offsets 'lisp-indent-hook 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 (defmacro edebug-storing-offsets (point &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (` (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (edebug-store-before-offset (, point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (edebug-store-after-offset (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
893 ;;; Reader for Emacs Lisp.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
894
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ;; Uses edebug-next-token-class (and edebug-skip-whitespace) above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (defconst edebug-read-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 '((symbol . edebug-read-symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (lparen . edebug-read-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (string . edebug-read-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (quote . edebug-read-quote)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
902 (backquote . edebug-read-backquote)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
903 (comma . edebug-read-comma)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (lbracket . edebug-read-vector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (hash . edebug-read-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (defun edebug-read-storing-offsets (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (let ((class (edebug-next-token-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 edebug-read-dotted-list) ; see edebug-store-after-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (edebug-storing-offsets (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (if (setq func (assq class edebug-read-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (funcall (cdr func) stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ;; anything else, just read it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (edebug-original-read stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (defun edebug-read-symbol (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (edebug-original-read stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 ;; loses for escaped chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (if (not (eq (aref edebug-read-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (preceding-char)) 'symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (defun edebug-read-string (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (edebug-original-read stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (if (/= (preceding-char) ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (defun edebug-read-quote (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ;; Turn 'thing into (quote thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (edebug-storing-offsets (point) 'quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (edebug-read-storing-offsets stream)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
940 (defun edebug-read-backquote (stream)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
941 ;; Turn `thing into (\` thing)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
942 (let ((opoint (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
943 (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
944 ;; Generate the same structure of offsets we would have
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
945 ;; if the resulting list appeared verbatim in the input text.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
946 (edebug-storing-offsets opoint
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
947 (list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
948 (edebug-storing-offsets opoint '\`)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
949 (edebug-read-storing-offsets stream)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
950
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
951 (defvar edebug-read-backquote-new nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
952 "Non-nil if reading the inside of a new-style backquote with no parens around it.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
953 Value of nil means reading the inside of an old-style backquote construct
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
954 which is surrounded by an extra set of parentheses.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
955 This controls how we read comma constructs.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
956
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
957 (defun edebug-read-comma (stream)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
958 ;; Turn ,thing into (\, thing). Handle ,@ and ,. also.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
959 (let ((opoint (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
960 (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
961 (let ((symbol '\,))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
962 (cond ((eq (following-char) ?\.)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
963 (setq symbol '\,\.)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
964 (forward-char 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
965 ((eq (following-char) ?\@)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
966 (setq symbol '\,@)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
967 (forward-char 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
968 ;; Generate the same structure of offsets we would have
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
969 ;; if the resulting list appeared verbatim in the input text.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
970 (if edebug-read-backquote-new
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
971 (list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
972 (edebug-storing-offsets opoint symbol)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
973 (edebug-read-storing-offsets stream))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
974 (edebug-storing-offsets opoint symbol)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
975
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (defun edebug-read-function (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ;; Turn #'thing into (function thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (if (/= ?\' (following-char)) (edebug-syntax-error "Bad char"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (edebug-storing-offsets (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (if (featurep 'cl) 'function* 'function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (edebug-read-storing-offsets stream)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (defun edebug-read-list (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (forward-char 1) ; skip \(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (let ((elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (while (not (memq (edebug-next-token-class) '(rparen dot)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
991 (if (eq (edebug-next-token-class) 'backquote)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
992 (let ((edebug-read-backquote-new (not (null elements)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
993 (opoint (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
994 (if edebug-read-backquote-new
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
995 (setq elements (cons (edebug-read-backquote stream) elements))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
996 (forward-char 1) ; Skip backquote.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
997 ;; Call edebug-storing-offsets here so that we
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
998 ;; produce the same offsets we would have had
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
999 ;; if the backquote were an ordinary symbol.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1000 (setq elements (cons (edebug-storing-offsets opoint '\`)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1001 elements))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1002 (setq elements (cons (edebug-read-storing-offsets stream) elements))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (setq elements (nreverse elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (if (eq 'dot (edebug-next-token-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (let (dotted-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (forward-char 1) ; skip \.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (setq dotted-form (edebug-read-storing-offsets stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 elements (nconc elements dotted-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (if (not (eq (edebug-next-token-class) 'rparen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (edebug-syntax-error "Expected `)'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (setq edebug-read-dotted-list (listp dotted-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 elements)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (forward-char 1) ; skip \)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (defun edebug-read-vector (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (forward-char 1) ; skip \[
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (let ((elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (while (not (eq 'rbracket (edebug-next-token-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (setq elements (cons (edebug-read-storing-offsets stream) elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (apply 'vector (nreverse elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (forward-char 1) ; skip \]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1027 ;;; Cursors for traversal of list and vector elements with offsets.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (defvar edebug-dotted-spec nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (defun edebug-new-cursor (expressions offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 ;; Return a new cursor for EXPRESSIONS with OFFSETS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (if (vectorp expressions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (setq expressions (append expressions nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (cons expressions offsets))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (defsubst edebug-set-cursor (cursor expressions offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 ;; Set the CURSOR's EXPRESSIONS and OFFSETS to the given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 ;; Return the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (setcar cursor expressions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (setcdr cursor offsets)
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 '(defun edebug-copy-cursor (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 ;; Copy the cursor using the same object and offsets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (cons (car cursor) (cdr cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (defsubst edebug-cursor-expressions (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (car cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (defsubst edebug-cursor-offsets (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (cdr cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (defsubst edebug-empty-cursor (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 ;; Return non-nil if CURSOR is empty - meaning no more elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (null (car cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (defsubst edebug-top-element (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 ;; Return the top element at the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 ;; Assumes not empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (car (car cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (defun edebug-top-element-required (cursor &rest error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 ;; Check if a dotted form is required.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (if edebug-dotted-spec (edebug-no-match cursor "Dot expected."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 ;; Check if there is at least one more argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (if (edebug-empty-cursor cursor) (apply 'edebug-no-match cursor error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 ;; Return that top element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (edebug-top-element cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (defsubst edebug-top-offset (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 ;; Return the top offset pair corresponding to the top element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (car (cdr cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (defun edebug-move-cursor (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 ;; Advance and return the cursor to the next element and offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 ;; throw no-match if empty before moving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 ;; This is a violation of the cursor encapsulation, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 ;; there is plenty of that going on while matching.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 ;; The following test should always fail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (if (edebug-empty-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (edebug-no-match cursor "Not enough arguments."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (setcar cursor (cdr (car cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (setcdr cursor (cdr (cdr cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (defun edebug-before-offset (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 ;; Return the before offset of the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 ;; If there is nothing left in the offsets,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 ;; return one less than the offset itself,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 ;; which is the after offset for a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (let ((offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (if (consp offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (car (car offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (1- offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (defun edebug-after-offset (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;; Return the after offset of the cursor object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (let ((offset (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (while (consp offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (setq offset (cdr offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1104 ;;; The Parser
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1105
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1106 ;; The top level function for parsing forms is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1107 ;; edebug-read-and-maybe-wrap-form; it calls all the rest. It checks the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1108 ;; syntax a bit and leaves point at any error it finds, but otherwise
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1109 ;; should appear to work like eval-defun.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1110
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1111 ;; The basic plan is to surround each expression with a call to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1112 ;; the edebug debugger together with indexes into a table of positions of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1113 ;; all expressions. Thus an expression "exp" becomes:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1114
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1115 ;; (edebug-after (edebug-before 1) 2 exp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1116
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1117 ;; When this is evaluated, first point is moved to the beginning of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1118 ;; exp at offset 1 of the current function. The expression is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1119 ;; evaluated, which may cause more edebug calls, and then point is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1120 ;; moved to offset 2 after the end of exp.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1121
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1122 ;; The highest level expressions of the function are wrapped in a call to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1123 ;; edebug-enter, which supplies the function name and the actual
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1124 ;; arguments to the function. See functions edebug-enter, edebug-before,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1125 ;; and edebug-after for more details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 ;; Dynamically bound vars, left unbound, but globally declared.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 ;; This is to quiet the byte compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 ;; Window data of the highest definition being wrapped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 ;; This data is shared by all embedded definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (defvar edebug-top-window-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (defvar edebug-&optional)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (defvar edebug-&rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (defvar edebug-gate nil) ;; whether no-match forces an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (defconst edebug-def-name nil) ; name of definition, used by interactive-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (defconst edebug-old-def-name nil) ; previous name of containing definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (defconst edebug-error-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (defconst edebug-best-error 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (defun edebug-read-and-maybe-wrap-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 ;; 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
1147 ;; 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
1148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 ;; Run the setup hook.
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 108
diff changeset
1150 (let ((temp-hook edebug-setup-hook))
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 108
diff changeset
1151 (setq edebug-setup-hook nil)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 108
diff changeset
1152 (run-hooks 'temp-hook))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (let (result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 edebug-top-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 edebug-def-name;; make sure it is locally nil
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1157 ;; I don't like these here!!
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 edebug-&optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 edebug-&rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 edebug-gate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 ;; Do this once here instead of several times.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (max-lisp-eval-depth (+ 800 max-lisp-eval-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (max-specpdl-size (+ 2000 max-specpdl-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (setq no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (setq result (edebug-read-and-maybe-wrap-form1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (if no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (apply 'edebug-syntax-error no-match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (defun edebug-read-and-maybe-wrap-form1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (let (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 def-kind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 defining-form-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 def-name
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1181 ;; These offset things don't belong here, but to support recursive
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 ;; calls to edebug-read, they need to be here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 edebug-offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 edebug-offsets-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 edebug-current-offset ; reset to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (if (and (eq 'lparen (edebug-next-token-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (eq 'symbol (progn (forward-char 1) (edebug-next-token-class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 ;; Find out if this is a defining form from first symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (setq def-kind (edebug-original-read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 spec (and (symbolp def-kind) (get-edebug-spec def-kind))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 defining-form-p (and (listp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (eq '&define (car spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;; This is incorrect in general!! But OK most of the time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 def-name (if (and defining-form-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (eq 'name (car (cdr spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (eq 'symbol (edebug-next-token-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (edebug-original-read (current-buffer))))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1200 ;;;(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
1201 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (defining-form-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (if (or edebug-all-defs edebug-all-forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 ;; If it is a defining form and we are edebugging defs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 ;; then let edebug-list-form start it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (let ((cursor (edebug-new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (list (edebug-read-storing-offsets (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (list edebug-offsets))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (edebug-before-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (1- (edebug-after-offset cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (list (cons (symbol-name def-kind) (cdr spec))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;; Not edebugging this form, so reset the symbol's edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ;; property to be just a marker at the definition's source code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 ;; This only works for defs with simple names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (put def-name 'edebug (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 ;; Also nil out dependent defs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 '(mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (lambda (def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (put def-name 'edebug nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (get def-name 'edebug-dependents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (edebug-read-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 ;; If all forms are being edebugged, explicitly wrap it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (edebug-all-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (let ((cursor (edebug-new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (list (edebug-read-storing-offsets (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (list edebug-offsets))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (edebug-before-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (edebug-after-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 ;; Not a defining form, and not edebugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (t (edebug-read-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (defvar edebug-def-args) ; args of defining form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (defvar edebug-def-interactive) ; is it an emacs interactive function?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (defvar edebug-inside-func) ;; whether code is inside function context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 ;; Currently def-form sets this to nil; def-body sets it to t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (defun edebug-interactive-p-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 ;; Return a unique symbol for the variable used to store the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 ;; status of interactive-p for this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (intern (format "edebug-%s-interactive-p" edebug-def-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (defun edebug-wrap-def-body (forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 "Wrap the FORMS of a definition body."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (if edebug-def-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (` (let (((, (edebug-interactive-p-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (interactive-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (, (edebug-make-enter-wrapper forms))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (edebug-make-enter-wrapper forms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (defun edebug-make-enter-wrapper (forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;; Generate the enter wrapper for some forms of a definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 ;; 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
1266 ;; since it wraps the list of forms with a call to `edebug-enter'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ;; Uses the dynamically bound vars edebug-def-name and edebug-def-args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 ;; Do this after parsing since that may find a name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (` (edebug-enter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (quote (, edebug-def-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (, (if edebug-inside-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (` (list (,@
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1275 ;; Doesn't work with more than one def-body!!
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 ;; But the list will just be reversed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (nreverse edebug-def-args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 'nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (function (lambda () (,@ forms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (defvar edebug-form-begin-marker) ; the mark for def being instrumented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (defvar edebug-offset-index) ; the next available offset index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (defvar edebug-offset-list) ; the list of offset positions.
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-inc-offset (offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 ;; modifies edebug-offset-index and edebug-offset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 ;; accesses edebug-func-marc and buffer point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 edebug-offset-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (setq edebug-offset-list (cons (- offset edebug-form-begin-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 edebug-offset-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 edebug-offset-index (1+ edebug-offset-index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (defun edebug-make-before-and-after-form (before-index form after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 ;; Return the edebug form for the current function at offset BEFORE-INDEX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 ;; given FORM. Looks like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 ;; (edebug-after (edebug-before BEFORE-INDEX) AFTER-INDEX FORM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 ;; Also increment the offset index for subsequent use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ;; if (not edebug-stop-before-symbols) and form is a symbol,
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1304 ;; then don't call edebug-before.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (list 'edebug-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (list 'edebug-before before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 after-index form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (defun edebug-make-after-form (form after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 ;; Like edebug-make-before-and-after-form, but only after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (list 'edebug-after 0 after-index form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (defun edebug-unwrap (sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 "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
1316 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
1317 expressions; a `progn' form will be returned enclosing these forms."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (if (consp sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 ((eq 'edebug-after (car sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (nth 3 sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 ((eq 'edebug-enter (car sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (let ((forms (nthcdr 2 (nth 1 (nth 3 sexp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (if (> (length forms) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (cons 'progn forms) ;; could return (values forms) instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (car forms))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (t sexp);; otherwise it is not wrapped, so just return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (defun edebug-unwrap* (sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 "Return the sexp recursively unwrapped."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (let ((new-sexp (edebug-unwrap sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (while (not (eq sexp new-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (setq sexp new-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 new-sexp (edebug-unwrap sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (if (consp new-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (mapcar 'edebug-unwrap* new-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 new-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (defun edebug-defining-form (cursor form-begin form-end speclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 ;; Process the defining form, starting outside the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 ;; The speclist is a generated list spec that looks like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 ;; (("def-symbol" defining-form-spec-sans-&define))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 ;; Skip the first offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (edebug-set-cursor cursor (edebug-cursor-expressions cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (cdr (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 form-begin (1- form-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 speclist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (defun edebug-make-form-wrapper (cursor form-begin form-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 &optional speclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 ;; Wrap a form, usually a defining form, but any evaluated one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 ;; If speclist is non-nil, this is being called by edebug-defining-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 ;; Otherwise it is being called from edebug-read-and-maybe-wrap-form1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 ;; This is a hack, but I havent figured out a simpler way yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (let* ((form-data-entry (edebug-get-form-data-entry form-begin form-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 ;; Set this marker before parsing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (edebug-form-begin-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (if form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (edebug-form-data-begin form-data-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 ;; Buffer must be current-buffer for this to work:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (set-marker (make-marker) form-begin))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (let (edebug-offset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (edebug-offset-index 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 ;; For definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; (edebug-containing-def-name edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 ;; Get name from form-data, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (edebug-old-def-name (edebug-form-data-name form-data-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 edebug-def-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 edebug-def-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 edebug-inside-func;; whether wrapped code executes inside a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (if speclist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (edebug-match cursor speclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 ;; else wrap as an enter-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (edebug-make-enter-wrapper (list (edebug-form cursor)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 ;; 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
1389 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 ;; Add this def as a dependent of containing def. Buggy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 '(if (and edebug-containing-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (not (get edebug-containing-def-name 'edebug-dependents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (put edebug-containing-def-name 'edebug-dependents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (cons edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (get edebug-containing-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 'edebug-dependents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 ;; Create a form-data-entry or modify existing entry's markers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 ;; In the latter case, pointers to the entry remain eq.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (if (not form-data-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (setq form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (edebug-make-form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 edebug-form-begin-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 ;; Buffer must be current-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (set-marker (make-marker) form-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (edebug-set-form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 form-data-entry edebug-def-name ;; in case name is changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 form-begin form-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 ;; (message "defining: %s" edebug-def-name) (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (edebug-make-top-form-data-entry form-data-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (message "Edebug: %s" edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 ;;(debug edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 ;; Destructively reverse edebug-offset-list and make vector from it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (setq edebug-offset-list (vconcat (nreverse edebug-offset-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 ;; Side effects on the property list of edebug-def-name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (edebug-clear-frequency-count edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (edebug-clear-coverage edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 ;; Set up the initial window data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (if (not edebug-top-window-data) ;; if not already set, do it now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (let ((window ;; Find the best window for this buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (or (get-buffer-window (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (setq edebug-top-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (cons window (window-start window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 ;; Store the edebug data in symbol's property list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (put edebug-def-name 'edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;; A struct or vector would be better here!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (list edebug-form-begin-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 nil ; clear breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 edebug-offset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 edebug-top-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (defun edebug-clear-frequency-count (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 ;; Create initial frequency count vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 ;; For each stop point, the counter is incremented each time it is visited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (put name 'edebug-freq-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (make-vector (length edebug-offset-list) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (defun edebug-clear-coverage (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 ;; Create initial coverage vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 ;; Only need one per expression, but it is simpler to use stop points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (put name 'edebug-coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (make-vector (length edebug-offset-list) 'unknown)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (defun edebug-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ;; Return the instrumented form for the following form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 ;; Add the point offsets to the edebug-offset-list for the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (let* ((form (edebug-top-element-required cursor "Expected form"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (offset (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 ((consp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 ;; The first offset for a list form is for the list form itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (if (eq 'quote (car form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (let* ((head (car form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (spec (and (symbolp head) (get-edebug-spec head)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (new-cursor (edebug-new-cursor form offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 ;; Find out if this is a defining form from first symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 ;; An indirect spec would not work here, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (if (and (consp spec) (eq '&define (car spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (edebug-defining-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (car offset);; before the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (edebug-after-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (cons (symbol-name head) (cdr spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 ;; Wrap a regular form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (edebug-make-before-and-after-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (edebug-inc-offset (car offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (edebug-list-form new-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 ;; After processing the list form, the new-cursor is left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 ;; with the offset after the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (edebug-inc-offset (edebug-cursor-offsets new-cursor))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 ((symbolp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (cond
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1493 ;; Check for constant symbols that don't get wrapped.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ((or (memq form '(t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (and (fboundp 'edebug-keywordp) (edebug-keywordp form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;; This option may go away.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (edebug-stop-before-symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (edebug-make-before-and-after-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (edebug-inc-offset (car offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (edebug-inc-offset (cdr offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (t ;; just a variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (edebug-make-after-form form (edebug-inc-offset (cdr offset))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;; Anything else is self-evaluating.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (t form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (edebug-move-cursor cursor))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 (defsubst edebug-forms (cursor) (edebug-match cursor '(&rest form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (defsubst edebug-sexps (cursor) (edebug-match cursor '(&rest sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (defsubst edebug-list-form-args (head cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 ;; 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
1519 ;; Helper for edebug-list-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (let ((spec (get-edebug-spec head)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 ((consp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 ;; It is a speclist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (let (edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 edebug-error-point);; This may not be needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (edebug-match-sublist cursor spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 ((eq t spec) (edebug-forms cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 ((eq 0 spec) (edebug-sexps cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 ((symbolp spec) (funcall spec cursor));; Not used by edebug,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 ; but leave it in for compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 ;; No edebug-form-spec provided.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 ((edebug-macrop head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (if edebug-eval-macro-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (edebug-forms cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (edebug-sexps cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (t ;; Otherwise it is a function call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (edebug-forms cursor)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (defun edebug-list-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 ;; Return an instrumented form built from the list form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 ;; The after offset will be left in the cursor after processing the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (let ((head (edebug-top-element-required cursor "Expected elements"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 ;; Prevent backtracking whenever instrumenting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 ;; A list form is never optional because it matches anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (edebug-&optional nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (edebug-&rest nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 ;; Skip the first offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (edebug-set-cursor cursor (edebug-cursor-expressions cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (cdr (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ((null head) nil) ; () is legal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 ((symbolp head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 ((null head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (edebug-syntax-error "nil head"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 ((eq head 'interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 ;; Special case: replace (interactive-p) with variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (setq edebug-def-interactive 'check-it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (edebug-interactive-p-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (cons head (edebug-list-form-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 head (edebug-move-cursor cursor))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 ((consp head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (if (and (listp head) (eq (car head) ',))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (edebug-match cursor '(("," def-form) body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 ;; Process anonymous function and args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 ;; This assumes no anonymous macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (edebug-match-specs cursor '(lambda-expr body) '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 (t (edebug-syntax-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 "Head of list form must be a symbol or lambda expression.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1582 ;;; Matching of specs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 (defvar edebug-after-dotted-spec nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (defvar edebug-matching-depth 0) ;; initial value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (defconst edebug-max-depth 150) ;; maximum number of matching recursions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1590 ;;; Failure to match
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1591
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 ;; This throws to no-match, if there are higher alternatives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 ;; Otherwise it signals an error. The place of the error is found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 ;; with the two before- and after-offset functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (defun edebug-no-match (cursor &rest edebug-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 ;; Throw a no-match, or signal an error immediately if gate is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 ;; Remember this point in case we need to report this error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (setq edebug-error-point (or edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (edebug-before-offset cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 edebug-best-error (or edebug-best-error edebug-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (if (and edebug-gate (not edebug-&optional))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (if edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (goto-char edebug-error-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (apply 'edebug-syntax-error edebug-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (funcall 'throw 'no-match edebug-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (defun edebug-match (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 ;; Top level spec matching function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 ;; Used also at each lower level of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (let (edebug-&optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 edebug-&rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (edebug-gate edebug-gate) ;; locally bound to limit effect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (edebug-match-specs cursor specs 'edebug-match-specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (defun edebug-match-one-spec (cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 ;; Match one spec, which is not a keyword &-spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 ((symbolp spec) (edebug-match-symbol cursor spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ((vectorp spec) (edebug-match cursor (append spec nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 ((stringp spec) (edebug-match-string cursor spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 ((listp spec) (edebug-match-list cursor spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (defun edebug-match-specs (cursor specs remainder-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 ;; Append results of matching the list of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; The first spec is handled and the remainder-handler handles the rest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (let ((edebug-matching-depth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (if (> edebug-matching-depth edebug-max-depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (error "too deep - perhaps infinite loop in spec?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (1+ edebug-matching-depth))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 ((null specs) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 ;; Is the spec dotted?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 ((atom specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (let ((edebug-dotted-spec t));; Containing spec list was dotted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (edebug-match-specs cursor (list specs) remainder-handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 ;; Is the form dotted?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 ((not (listp (edebug-cursor-expressions cursor)));; allow nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (if (not edebug-dotted-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (edebug-no-match cursor "Dotted spec required."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 ;; Cancel dotted spec and dotted form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (let ((edebug-dotted-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (this-form (edebug-cursor-expressions cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (this-offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 ;; Wrap the form in a list, (by changing the cursor??)...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (edebug-set-cursor cursor (list this-form) this-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 ;; and process normally, then unwrap the result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (car (edebug-match-specs cursor specs remainder-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (t;; Process normally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (let* ((spec (car specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (first-char (and (symbolp spec) (aref (symbol-name spec) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 ;;(message "spec = %s first char = %s" spec first-char) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (nconc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 ((eq ?& first-char);; "&" symbols take all following specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (funcall (get-edebug-spec spec) cursor (cdr specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 ((eq ?: first-char);; ":" symbols take one following spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (setq rest (cdr (cdr specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (funcall (get-edebug-spec spec) cursor (car (cdr specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (t;; Any other normal spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (setq rest (cdr specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (edebug-match-one-spec cursor spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (funcall remainder-handler cursor rest remainder-handler)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 ;; Define specs for all the symbol specs with functions used to process them.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1679 ;; 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
1680 ;; user may want to define macros or functions with the same names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 ;; We could use an internal obarray for these primitive specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (function (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (put (car pair) 'edebug-form-spec (cdr pair))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 '((&optional . edebug-match-&optional)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (&rest . edebug-match-&rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (&or . edebug-match-&or)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (form . edebug-match-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (sexp . edebug-match-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (body . edebug-match-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (&define . edebug-match-&define)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (name . edebug-match-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (:name . edebug-match-colon-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (arg . edebug-match-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (def-body . edebug-match-def-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (def-form . edebug-match-def-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 ;; Less frequently used:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 ;; (function . edebug-match-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (lambda-expr . edebug-match-lambda-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (&not . edebug-match-&not)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (&key . edebug-match-&key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (place . edebug-match-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (gate . edebug-match-gate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 ;; (nil . edebug-match-nil) not this one - special case it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (defun edebug-match-symbol (cursor symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 ;; Match a symbol spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (let* ((spec (get-edebug-spec symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (if (consp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 ;; It is an indirect spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (edebug-match cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 ;; Otherwise it should be the symbol name of a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 ;; There could be a bug here - maybe need to do edebug-match bindings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (funcall spec cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 ((null symbol) ;; special case this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (edebug-match-nil cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 ((fboundp symbol) ; is it a predicate?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (let ((sexp (edebug-top-element-required cursor "Expected" symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 ;; Special case for edebug-`.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (if (and (listp sexp) (eq (car sexp) ',))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (edebug-match cursor '(("," def-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (if (not (funcall symbol sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (edebug-no-match cursor symbol "failed"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (list sexp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (t (error "%s is not a form-spec or function" symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (defun edebug-match-sexp (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (list (prog1 (edebug-top-element-required cursor "Expected sexp")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (edebug-move-cursor cursor))))
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-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (list (edebug-form cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (defalias 'edebug-match-place 'edebug-match-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 ;; Currently identical to edebug-match-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ;; This is for common lisp setf-style place arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (defsubst edebug-match-body (cursor) (edebug-forms cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (defun edebug-match-&optional (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ;; Keep matching until one spec fails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (edebug-&optional-wrapper cursor specs 'edebug-&optional-wrapper))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (defun edebug-&optional-wrapper (cursor specs remainder-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (let (result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (edebug-&optional specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (edebug-gate nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (this-form (edebug-cursor-expressions cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (this-offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (if (null (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (edebug-match-specs cursor specs remainder-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 ;; Returning nil means no no-match was thrown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 ;; no-match, but don't fail; just reset cursor and return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (edebug-set-cursor cursor this-form this-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (defun edebug-&rest-wrapper (cursor specs remainder-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (if (null specs) (setq specs edebug-&rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 ;; Reuse the &optional handler with this as the remainder handler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (edebug-&optional-wrapper cursor specs remainder-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (defun edebug-match-&rest (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 ;; Repeatedly use specs until failure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (let ((edebug-&rest specs) ;; remember these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 edebug-error-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (edebug-&rest-wrapper cursor specs 'edebug-&rest-wrapper)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (defun edebug-match-&or (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 ;; Keep matching until one spec succeeds, and return its results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 ;; If none match, fail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 ;; This needs to be optimized since most specs spend time here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (let ((original-specs specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (this-form (edebug-cursor-expressions cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (this-offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (catch 'matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (while specs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (throw 'matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (let (edebug-gate ;; only while matching each spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 edebug-error-point)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1797 ;; Doesn't support e.g. &or symbolp &rest form
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (edebug-match-one-spec cursor (car specs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ;; Match failed, so reset and try again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (setq specs (cdr specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 ;; Reset the cursor for the next match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (edebug-set-cursor cursor this-form this-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 ;; All failed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (apply 'edebug-no-match cursor "Expected one of" original-specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (defun edebug-match-&not (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 ;; If any specs match, then fail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (if (null (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (let ((edebug-gate nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (edebug-match-&or cursor specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 ;; This means something matched, so it is a no match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (edebug-no-match cursor "Unexpected"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 ;; This means nothing matched, so it is OK.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 nil) ;; So, return nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (def-edebug-spec &key edebug-match-&key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (defun edebug-match-&key (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 ;; Following specs must look like (<name> <spec>) ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ;; where <name> is the name of a keyword, and spec is its spec.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1826 ;; 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
1827 (edebug-match-&rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (cons '&or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (mapcar (function (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (vector (format ":%s" (car pair))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (car (cdr pair)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (defun edebug-match-gate (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 ;; Simply set the gate to prevent backtracking at this level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (setq edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (defun edebug-match-list (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 ;; The spec is a list, but what kind of list, and what context?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (if edebug-dotted-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 ;; After dotted spec but form did not contain dot,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 ;; so match list spec elements as if spliced in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (let ((edebug-dotted-spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 (edebug-match-specs cursor specs 'edebug-match-specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 ;; If it matched, really clear the dotted-spec flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (setq edebug-dotted-spec nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (let ((spec (car specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (form (edebug-top-element-required cursor "Expected" specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 ((eq 'quote spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (let ((spec (car (cdr specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 ((symbolp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 ;; Special case: spec quotes a symbol to match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 ;; Change in future. Use "..." instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (if (not (eq spec form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (edebug-no-match cursor "Expected" spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (setq edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (error "Bad spec: %s" specs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 ((listp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (list (edebug-match-sublist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 ;; First offset is for the list form itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 ;; Treat nil as empty list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (edebug-new-cursor form (cdr (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (edebug-move-cursor cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 ((and (eq 'vector spec) (vectorp form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 ;; Special case: match a vector with the specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (let ((result (edebug-match-sublist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (edebug-new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 form (cdr (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (cdr specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (list (apply 'vector result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (t (edebug-no-match cursor "Expected" specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (defun edebug-match-sublist (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 ;; Match a sublist of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (let (edebug-&optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 ;;edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 ;;edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 ;; match with edebug-match-specs so edebug-best-error is not bound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (edebug-match-specs cursor specs 'edebug-match-specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (if (not (edebug-empty-cursor cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (if edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 (apply 'edebug-no-match cursor edebug-best-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 ;; A failed &rest or &optional spec may leave some args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (edebug-no-match cursor "Failed matching" specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (defun edebug-match-string (cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (let ((sexp (edebug-top-element-required cursor "Expected" spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (if (not (eq (intern spec) sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (edebug-no-match cursor "Expected" spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 ;; Since it matched, failure means immediate error, unless &optional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (setq edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (list sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (defun edebug-match-nil (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 ;; There must be nothing left to match a nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (if (not (edebug-empty-cursor cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (edebug-no-match cursor "Unmatched argument(s)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 nil))
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-function (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (error "Use function-form instead of function in edebug spec"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (defun edebug-match-&define (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 ;; Match a defining form.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
1930 ;; Normally, &define is interpreted specially other places.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 ;; 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
1932 ;; of the current list. e.g. ("lambda" &define args def-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (edebug-before-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 ;; Find the last offset in the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (let ((offsets (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (while (consp offsets) (setq offsets (cdr offsets)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (defun edebug-match-lambda-expr (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 ;; The expression must be a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 ;; This will match any list form that begins with a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 ;; that has an edebug-form-spec beginning with &define. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 ;; practice, only lambda expressions should be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 ;; I could add a &lambda specification to avoid confusion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (let* ((sexp (edebug-top-element-required
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 cursor "Expected lambda expression"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (offset (edebug-top-offset cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (head (and (consp sexp) (car sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (spec (and (symbolp head) (get-edebug-spec head)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (edebug-inside-func nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 ;; Find out if this is a defining form from first symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (if (and (consp spec) (eq '&define (car spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (edebug-defining-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (edebug-new-cursor sexp offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (car offset);; before the sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (edebug-after-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (cons (symbol-name head) (cdr spec))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (edebug-move-cursor cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (edebug-no-match cursor "Expected lambda expression")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (defun edebug-match-name (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 ;; Set the edebug-def-name bound in edebug-defining-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (let ((name (edebug-top-element-required cursor "Expected name")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 ;; Maybe strings and numbers could be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (if (not (symbolp name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (edebug-no-match cursor "Symbol expected for name of definition"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (if edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 ;; Construct a new name by appending to previous name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (intern (format "%s@%s" edebug-def-name name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (list name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (defun edebug-match-colon-name (cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 ;; Set the edebug-def-name to the spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (if edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 ;; Construct a new name by appending to previous name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (intern (format "%s@%s" edebug-def-name spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (defun edebug-match-arg (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 ;; set the def-args bound in edebug-defining-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 (let ((edebug-arg (edebug-top-element-required cursor "Expected arg")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (if (or (not (symbolp edebug-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (edebug-lambda-list-keywordp edebug-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (edebug-no-match cursor "Bad argument:" edebug-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (setq edebug-def-args (cons edebug-arg edebug-def-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (list edebug-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (defun edebug-match-def-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 ;; Like form but the form is wrapped in edebug-enter form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 ;; The form is assumed to be executing outside of the function context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 ;; 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
2005 ;; Not to be used otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (let ((edebug-inside-func nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (list (edebug-make-enter-wrapper (list (edebug-form cursor))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (defun edebug-match-def-body (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 ;; Like body but body is wrapped in edebug-enter form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 ;; The body is assumed to be executing inside of the function context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 ;; Not to be used otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (let ((edebug-inside-func t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (list (edebug-wrap-def-body (edebug-forms cursor)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2017 ;;;; Edebug Form Specs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2018 ;;; ==========================================================
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2019 ;;; See cl-specs.el for common lisp specs.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2020
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2021 ;;;;* Spec for def-edebug-spec
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2022 ;;; Out of date.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (defun edebug-spec-p (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 "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
2026 (and (symbolp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 (get object 'edebug-form-spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (def-edebug-spec def-edebug-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 ;; Top level is different from lower levels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 (&define :name edebug-spec name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 &or "nil" edebug-spec-p "t" "0" (&rest edebug-spec)))
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 edebug-spec-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 ;; A list must have something in it, or it is nil, a symbolp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 ((edebug-spec . [&or nil edebug-spec])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (def-edebug-spec edebug-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (&or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 (vector &rest edebug-spec) ; matches a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 ("vector" &rest edebug-spec) ; matches a vector spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 ("quote" symbolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 edebug-spec-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 stringp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 [edebug-lambda-list-keywordp &rest edebug-spec]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 ;; [edebug-keywordp gate edebug-spec] ;; need edebug-keywordp for this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 edebug-spec-p ;; Including all the special ones e.g. form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 symbolp;; a predicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2052 ;;;* Emacs special forms and some functions.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 ;; quote expects only one argument, although it allows any number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (def-edebug-spec quote sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 ;; The standard defining forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (def-edebug-spec defconst defvar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (def-edebug-spec defvar (symbolp &optional form stringp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 (def-edebug-spec defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (&define name lambda-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 [&optional stringp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 [&optional ("interactive" interactive)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (def-edebug-spec defmacro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (&define name lambda-list def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2069 (def-edebug-spec arglist lambda-list) ;; deprecated - use lambda-list.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (def-edebug-spec lambda-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (([&rest arg]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 [&optional ["&optional" arg &rest arg]]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 &optional ["&rest" arg]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 )))
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 interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (&optional &or stringp def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 ;; 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
2081 ;; This specially recognizes anonymous functions quoted with quote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (def-edebug-spec function-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 ;; form at the end could also handle "function",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 ;; but recognize it specially to avoid wrapping function forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (&or ([&or "quote" "function"] &or symbolp lambda-expr) form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 ;; function expects a symbol or a lambda or macro expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 ;; A macro is allowed by Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (def-edebug-spec function (&or symbolp lambda-expr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 ;; lambda is a macro in emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (def-edebug-spec lambda (&define lambda-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 [&optional stringp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 [&optional ("interactive" interactive)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 ;; A macro expression is a lambda expression with "macro" prepended.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (def-edebug-spec macro (&define "lambda" lambda-list def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 ;; (def-edebug-spec anonymous-form ((&or ["lambda" lambda] ["macro" macro])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 ;; Standard functions that take function-forms arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 (def-edebug-spec mapcar (function-form form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (def-edebug-spec mapconcat (function-form form form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (def-edebug-spec mapatoms (function-form &optional form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 (def-edebug-spec apply (function-form &rest form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (def-edebug-spec funcall (function-form &rest form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (def-edebug-spec let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 ((&rest &or (symbolp &optional form) symbolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (def-edebug-spec let* let)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (def-edebug-spec setq (&rest symbolp form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 (def-edebug-spec setq-default setq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (def-edebug-spec cond (&rest (&rest form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (def-edebug-spec condition-case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (symbolp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 &rest (symbolp body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 (def-edebug-spec \` (backquote-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 ;; Supports quotes inside backquotes,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 ;; but only at the top level inside unquotes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 (def-edebug-spec backquote-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (&or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 ([&or "," ",@"] &or ("quote" backquote-form) form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (backquote-form &rest backquote-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 ;; If you use dotted forms in backquotes, replace the previous line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 ;; with the following. This takes quite a bit more stack space, however.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 ;; (backquote-form . [&or nil backquote-form])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (vector &rest backquote-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 ;; Special version of backquote that instruments backquoted forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 ;; destined to be evaluated, usually as the result of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 ;; macroexpansion. Backquoted code can only have unquotes (, and ,@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 ;; in places where list forms are allowed, and predicates. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 ;; backquote is used in a macro, unquoted code that come from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 ;; arguments must be instrumented, if at all, with def-form not def-body.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 ;; We could assume that all forms (not nested in other forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 ;; in arguments of macros should be def-forms, whether or not the macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 ;; are defined with edebug-` but this would be expensive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 ;; ,@ might have some problems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (defalias 'edebug-\` '\`) ;; same macro as regular backquote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (def-edebug-spec edebug-\` (def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 ;; Assume immediate quote in unquotes mean backquote at next higher level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (def-edebug-spec , (&or ("quote" edebug-`) def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (def-edebug-spec ,@ (&define ;; so (,@ form) is never wrapped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 &or ("quote" edebug-`) def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 ;; New byte compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (def-edebug-spec defsubst defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (def-edebug-spec dont-compile t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (def-edebug-spec eval-when-compile t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (def-edebug-spec eval-and-compile t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
2167 (def-edebug-spec save-selected-window t)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
2168 (def-edebug-spec save-current-buffer t)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
2169 (def-edebug-spec save-match-data t)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
2170 (def-edebug-spec with-output-to-string t)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
2171 (def-edebug-spec with-current-buffer t)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
2172 (def-edebug-spec with-temp-file t)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
2173 (def-edebug-spec with-temp-buffer t)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 136
diff changeset
2174
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 ;; Anything else?
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 ;; Some miscellaneous specs for macros in public packages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 ;; Send me yours.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 ;; advice.el by Hans Chalupsky (hans@cs.buffalo.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (def-edebug-spec ad-dolist ((symbolp form &optional form) body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 (def-edebug-spec defadvice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (&define name ;; thing being advised.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (name ;; class is [&or "before" "around" "after"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 ;; "activation" "deactivation"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 name ;; name of advice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 &rest sexp ;; optional position and flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 [&optional stringp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 [&optional ("interactive" interactive)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2195 ;;; The debugger itself
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (defvar edebug-active nil) ;; Non-nil when edebug is active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2199 ;;; add minor-mode-alist entry
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (or (assq 'edebug-active minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (setq minor-mode-alist (cons (list 'edebug-active " *Debugging*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 (defvar edebug-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 ;; Stack of active functions evaluated via edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 ;; Should be nil at the top level.
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 edebug-stack-depth -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 ;; Index of last edebug-stack item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (defvar edebug-offset-indices nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 ;; Stack of offset indices of visited edebug sexps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 ;; Should be nil at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 ;; Each function adds one cons. Top is modified with setcar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 (defvar edebug-entered nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 ;; Non-nil if edebug has already been entered at this recursive edit level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 ;; This should stay nil at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 ;; Should these be options?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (defconst edebug-debugger 'edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 ;; Name of function to use for debugging when error or quit occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 ;; Set this to 'debug if you want to debug edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 ;; Dynamically bound variables, declared globally but left unbound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 (defvar edebug-function) ; the function being executed. change name!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 (defvar edebug-args) ; the arguments of the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 (defvar edebug-data) ; the edebug data for the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 (defvar edebug-value) ; the result of the expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (defvar edebug-after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 (defvar edebug-def-mark) ; the mark for the definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (defvar edebug-freq-count) ; the count of expression visits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 (defvar edebug-coverage) ; the coverage results of each expression of function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (defvar edebug-buffer) ; which buffer the function is in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (defvar edebug-result) ; the result of the function call returned by body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 (defvar edebug-outside-executing-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 (defvar edebug-outside-defining-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (defvar edebug-execution-mode 'step) ; Current edebug mode set by user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (defvar edebug-next-execution-mode nil) ; Use once instead of initial mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 (defvar edebug-outside-debug-on-error) ; the value of debug-on-error outside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 (defvar edebug-outside-debug-on-quit) ; the value of debug-on-quit outside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (defvar edebug-outside-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (defvar edebug-outside-post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (defvar edebug-outside-post-command-idle-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 ;; Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (defvar pre-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (defvar post-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (defvar post-command-idle-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 (defvar cl-lexical-debug) ;; Defined in cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2261 ;;; Handling signals
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (if (not (fboundp 'edebug-original-signal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 (defalias 'edebug-original-signal (symbol-function 'signal)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 ;; We should use advise for this!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 (defun edebug-signal (edebug-signal-name edebug-signal-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 "Signal an error. Args are SIGNAL-NAME, and associated DATA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 A signal name is a symbol with an `error-conditions' property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 that is a list of condition names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 A handler for any of those names will get to handle this signal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 The symbol `error' should always be one of them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 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
2275 If the signal is handled, DATA is made available to the handler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 See `condition-case'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 This is the Edebug replacement for the standard `signal'. It should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 only be active while Edebug is. It checks `debug-on-error' to see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 whether it should call the debugger. When execution is resumed, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 error is signaled again."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 (if (and (listp debug-on-error) (memq edebug-signal-name debug-on-error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 (edebug 'error (cons edebug-signal-name edebug-signal-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 ;; If we reach here without another non-local exit, then send signal again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 ;; i.e. the signal is not continuable, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 (edebug-original-signal edebug-signal-name edebug-signal-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2289 ;;; Entering Edebug
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 (defun edebug-enter (edebug-function edebug-args edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 ;; Entering FUNC. The arguments are ARGS, and the body is BODY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 ;; Setup edebug variables and evaluate BODY. This function is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 ;; when a function evaluated with edebug-eval-top-level-form is entered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 ;; Return the result of BODY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 ;; Is this the first time we are entering edebug since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 ;; lower-level recursive-edit command?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 ;; More precisely, this tests whether Edebug is currently active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 (if (not edebug-entered)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 (let ((edebug-entered t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 ;; Binding max-lisp-eval-depth here is OK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 ;; but not inside an unwind-protect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 ;; Doing it here also keeps it from growing too large.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 (max-lisp-eval-depth (+ 100 max-lisp-eval-depth)) ; too much??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 (max-specpdl-size (+ 200 max-specpdl-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 (debugger edebug-debugger) ; only while edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 (edebug-outside-debug-on-error debug-on-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 (edebug-outside-debug-on-quit debug-on-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 ;; Binding these may not be the right thing to do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 ;; We want to allow the global values to be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 (debug-on-error (or debug-on-error edebug-on-error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (debug-on-quit edebug-on-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 ;; Lexical bindings must be uncompiled for this to work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 (cl-lexical-debug t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 ;; Save the outside value of executing macro. (here??)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
2320 (edebug-outside-executing-macro executing-kbd-macro)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 (edebug-outside-pre-command-hook pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (edebug-outside-post-command-hook post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 (edebug-outside-post-command-idle-hook post-command-idle-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (let (;; Don't keep reading from an executing kbd macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 ;; within edebug unless edebug-continue-kbd-macro is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 ;; non-nil. Again, local binding may not be best.
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
2328 (executing-kbd-macro
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
2329 (if edebug-continue-kbd-macro executing-kbd-macro))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 ;; Disable command hooks. This is essential when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 ;; a hook function is instrumented - to avoid infinite loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 ;; This may be more than we need, however.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 (pre-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 (post-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 (post-command-idle-hook nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (setq edebug-execution-mode (or edebug-next-execution-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 edebug-initial-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 edebug-execution-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 edebug-next-execution-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 ;; Bind signal to edebug-signal only while Edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 (fset 'signal 'edebug-signal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (edebug-enter edebug-function edebug-args edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 (fset 'signal (symbol-function 'edebug-original-signal))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 ;; Reset global variables in case outside value was changed.
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
2347 (setq executing-kbd-macro edebug-outside-executing-macro
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 pre-command-hook edebug-outside-pre-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 post-command-hook edebug-outside-post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 post-command-idle-hook edebug-outside-post-command-idle-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (let* ((edebug-data (get edebug-function 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 (edebug-def-mark (car edebug-data)) ; mark at def start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (edebug-freq-count (get edebug-function 'edebug-freq-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (edebug-coverage (get edebug-function 'edebug-coverage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 (edebug-buffer (marker-buffer edebug-def-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 (edebug-stack (cons edebug-function edebug-stack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 (edebug-offset-indices (cons 0 edebug-offset-indices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 (if (get edebug-function 'edebug-on-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 (setq edebug-execution-mode 'step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 (if (eq (get edebug-function 'edebug-on-entry) 'temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 (put edebug-function 'edebug-on-entry nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 (if edebug-trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 (edebug-enter-trace edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 (funcall edebug-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 (defun edebug-enter-trace (edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 (let ((edebug-stack-depth (1+ edebug-stack-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 edebug-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 (edebug-print-trace-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 (format "%s args: %s" edebug-function edebug-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 (prog1 (setq edebug-result (funcall edebug-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 (edebug-print-trace-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (format "%s result: %s" edebug-function edebug-result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 (def-edebug-spec edebug-tracing (form body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 (defmacro edebug-tracing (msg &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 "Print MSG in *edebug-trace* before and after evaluating BODY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 The result of BODY is also printed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 (` (let ((edebug-stack-depth (1+ edebug-stack-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 edebug-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 (edebug-print-trace-before (, msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 (prog1 (setq edebug-result (progn (,@ body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (edebug-print-trace-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 (format "%s result: %s" (, msg) edebug-result))))))
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-print-trace-before (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 "Function called to print trace info before expression evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 MSG is printed after `::::{ '."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (edebug-trace-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 edebug-trace-buffer "%s{ %s" (make-string edebug-stack-depth ?\:) msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 (defun edebug-print-trace-after (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 "Function called to print trace info after expression evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 MSG is printed after `::::} '."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 (edebug-trace-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 edebug-trace-buffer "%s} %s" (make-string edebug-stack-depth ?\:) msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 (defun edebug-slow-before (edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 ;; Debug current function given BEFORE position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 ;; Called from functions compiled with edebug-eval-top-level-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 ;; Return the before index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 (setcar edebug-offset-indices edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 ;; Increment frequency count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 (aset edebug-freq-count edebug-before-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 (1+ (aref edebug-freq-count edebug-before-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 (if (or (not (memq edebug-execution-mode '(Go-nonstop next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 (edebug-input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 (edebug-debugger edebug-before-index 'before nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 (defun edebug-fast-before (edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 ;; Do nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 (defun edebug-slow-after (edebug-before-index edebug-after-index edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 ;; Debug current function given AFTER position and VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 ;; Called from functions compiled with edebug-eval-top-level-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 ;; Return VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 (setcar edebug-offset-indices edebug-after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 ;; Increment frequency count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 (aset edebug-freq-count edebug-after-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 (1+ (aref edebug-freq-count edebug-after-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 (if edebug-test-coverage (edebug-update-coverage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 (if (and (eq edebug-execution-mode 'Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (not (edebug-input-pending-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 ;; Just return result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 edebug-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 (edebug-debugger edebug-after-index 'after edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 (defun edebug-fast-after (edebug-before-index edebug-after-index edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 ;; Do nothing but return the value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 (defun edebug-run-slow ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (defalias 'edebug-before 'edebug-slow-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (defalias 'edebug-after 'edebug-slow-after))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 ;; This is not used, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 (defun edebug-run-fast ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (defalias 'edebug-before 'edebug-fast-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 (defalias 'edebug-after 'edebug-fast-after))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 (edebug-run-slow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (defun edebug-update-coverage ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (let ((old-result (aref edebug-coverage edebug-after-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 ((eq 'ok-coverage old-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 ((eq 'unknown old-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 (aset edebug-coverage edebug-after-index edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 ;; Test if a different result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 ((not (eq edebug-value old-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (aset edebug-coverage edebug-after-index 'ok-coverage)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 ;; Dynamically declared unbound variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 (defvar edebug-arg-mode) ; the mode, either before, after, or error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (defvar edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (defvar edebug-break-data) ; break data for current function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 (defvar edebug-break) ; whether a break occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (defvar edebug-global-break) ; whether a global break occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (defvar edebug-break-condition) ; whether the breakpoint is conditional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 (defvar edebug-break-result nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (defvar edebug-global-break-result nil)
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 (defun edebug-debugger (edebug-offset-index edebug-arg-mode edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 ;; Check breakpoints and pending input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 ;; If edebug display should be updated, call edebug-display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 ;; Return edebug-value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (let* (;; This needs to be here since breakpoints may be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 (edebug-breakpoints (car (cdr edebug-data))) ; list of breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 (edebug-break-data (assq edebug-offset-index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 (edebug-break-condition (car (cdr edebug-break-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (if edebug-global-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 (setq edebug-global-break-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (eval edebug-global-break-condition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 (error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 (edebug-break))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 ;;; (edebug-trace "exp: %s" edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 ;; Test whether we should break.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (setq edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (or edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (and edebug-break-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (or (not edebug-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (setq edebug-break-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (eval edebug-break-condition))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (if (and edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (nth 2 edebug-break-data)) ; is it temporary?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 ;; Delete the breakpoint.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 (setcdr edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (cons (delq edebug-break-data edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (cdr (cdr edebug-data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 ;; Display if mode is not go, continue, or Continue-fast
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 ;; or break, or input is pending,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 (if (or (not (memq edebug-execution-mode '(go continue Continue-fast)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (edebug-input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (edebug-display)) ; <--------------- display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 edebug-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 ;; window-start now stored with each function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 ;;(defvar edebug-window-start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 ;; Remember where each buffers' window starts between edebug calls.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 ;; This is to avoid spurious recentering.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 ;; Does this still need to be buffer-local??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 ;;(setq-default edebug-window-start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 ;;(make-variable-buffer-local 'edebug-window-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 ;; Dynamically declared unbound vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 (defvar edebug-point) ; the point in edebug buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 (defvar edebug-outside-buffer) ; the current-buffer outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (defvar edebug-outside-point) ; the point outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 (defvar edebug-outside-mark) ; the mark outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (defvar edebug-window-data) ; window and window-start for current function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (defvar edebug-outside-windows) ; outside window configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (defvar edebug-eval-buffer) ; for the evaluation list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 (defvar edebug-outside-o-a-p) ; outside overlay-arrow-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (defvar edebug-outside-o-a-s) ; outside overlay-arrow-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 (defvar edebug-outside-c-i-e-a) ; outside cursor-in-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 (defvar edebug-eval-list nil) ;; List of expressions to evaluate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 (defvar edebug-previous-result nil) ;; Last result returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 ;; Emacs 19 adds an arg to mark and mark-marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (defalias 'edebug-mark 'mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 (defalias 'edebug-mark-marker 'mark-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 (defun edebug-display ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 ;; Setup windows for edebug, determine mode, maybe enter recursive-edit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 ;; Uses local variables of edebug-enter, edebug-before, edebug-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 ;; and edebug-debugger.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 (let ((edebug-active t) ; for minor mode alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 edebug-stop ; should we enter recursive-edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 (edebug-point (+ edebug-def-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 (aref (nth 2 edebug-data) edebug-offset-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 edebug-buffer-outside-point ; current point in edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 ;; window displaying edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 (edebug-window-data (nth 3 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 (edebug-outside-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (edebug-outside-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (edebug-outside-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 (edebug-outside-mark (edebug-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 edebug-outside-windows ; window or screen configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 edebug-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 edebug-eval-buffer ; declared here so we can kill it below
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 (edebug-eval-result-list (and edebug-eval-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 (edebug-eval-result-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 edebug-trace-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 (edebug-outside-o-a-p overlay-arrow-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 (edebug-outside-o-a-s overlay-arrow-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 (edebug-outside-c-i-e-a cursor-in-echo-area))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 (let ((overlay-arrow-position overlay-arrow-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (overlay-arrow-string overlay-arrow-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 (cursor-in-echo-area nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 ;; any others??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 (if (not (buffer-name edebug-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (let ((debug-on-error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (error "Buffer defining %s not found" edebug-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (if (eq 'after edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 ;; Compute result string now before windows are modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (edebug-compute-previous-result edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 ;; Save windows now before we modify them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (setq edebug-outside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 (edebug-current-windows edebug-save-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 (if edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 (setq edebug-buffer-points (edebug-get-displayed-buffer-points)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 ;; First move the edebug buffer point to edebug-point
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2606 ;; so that window start doesn't get changed when we display it.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2607 ;; I don't know if this is going to help.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 ;;(set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 ;;(goto-char edebug-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 ;; If edebug-buffer is not currently displayed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 ;; first find a window for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 (edebug-pop-to-buffer edebug-buffer (car edebug-window-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (setcar edebug-window-data (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 ;; Now display eval list, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 ;; This is done after the pop to edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 ;; so that buffer-window correspondence is correct after quitting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 (edebug-eval-display edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 ;; The evaluation list better not have deleted edebug-window-data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 (select-window (car edebug-window-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 (setq edebug-buffer-outside-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (goto-char edebug-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (if (eq 'before edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 ;; Check whether positions are up-to-date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 ;; This assumes point is never before symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 (if (not (memq (following-char) '(?\( ?\# ?\` )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 (let ((debug-on-error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 (error "Source has changed - reevaluate definition of %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 edebug-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 (setcdr edebug-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 (edebug-adjust-window (cdr edebug-window-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 ;; Test if there is input, not including keyboard macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 (if (edebug-input-pending-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 (setq edebug-execution-mode 'step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 edebug-stop t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 (edebug-stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 ;; (discard-input) ; is this unfriendly??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 ;; Now display arrow based on mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 (edebug-overlay-arrow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 ((eq 'error edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 ;; Display error message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 (setq edebug-execution-mode 'step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 (edebug-overlay-arrow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 (if (eq 'quit (car edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 (message "Quit")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 (edebug-report-error edebug-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 (edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 (edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (message "Global Break: %s => %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 edebug-global-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 edebug-global-break-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 (edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 (message "Break: %s => %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 edebug-break-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 ((not (eq edebug-execution-mode 'Continue-fast))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (message "Break"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 (t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 (t (message "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 (if (eq 'after edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 ;; Display result of previous evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 (if (and edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 (not (eq edebug-execution-mode 'Continue-fast)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 (sit-for 1)) ; Show break message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 (edebug-previous-result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 (edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 ((eq edebug-execution-mode 'continue) (edebug-sit-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 ((eq edebug-execution-mode 'Continue-fast) (edebug-sit-for 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 (t (setq edebug-stop t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 ;; not edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 ((eq edebug-execution-mode 'trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 (edebug-sit-for 1)) ; Force update and pause.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 ((eq edebug-execution-mode 'Trace-fast)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 (edebug-sit-for 0)) ; Force update and continue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 (if (or edebug-stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 (memq edebug-execution-mode '(step next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 (eq edebug-arg-mode 'error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 ;; (setq edebug-execution-mode 'step)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2702 ;; (edebug-overlay-arrow) ; this doesn't always show up.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 (edebug-recursive-edit))) ; <---------- Recursive edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 ;; Reset the edebug-window-data to whatever it is now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 (let ((window (if (eq (window-buffer) edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 (edebug-get-buffer-window edebug-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 ;; Remember window-start for edebug-buffer, if still displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 (setcar edebug-window-data window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 (setcdr edebug-window-data (window-start window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 ;; Save trace window point before restoring outside windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 ;; Could generalize this for other buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 (setq edebug-trace-window (get-buffer-window edebug-trace-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 (if edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 (setq edebug-trace-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (and edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 (window-start edebug-trace-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 ;; Restore windows before continuing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 (edebug-set-windows edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 ;; Restore displayed buffer points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 ;; Needed even if restoring windows because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 ;; window-points are not restored. (should they be??)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 (if edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 (edebug-set-buffer-points edebug-buffer-points))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 ;; Unrestore trace window's window-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 (if edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 (set-window-start edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 edebug-trace-window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 ;; Unrestore edebug-buffer's window-start, if displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 (let ((window (car edebug-window-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 (if (and window (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 (eq (window-buffer) edebug-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 (set-window-start window (cdr edebug-window-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 'no-force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 ;; Unrestore edebug-buffer's window-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 ;; Needed in addition to setting the buffer point
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2748 ;; - otherwise quitting doesn't leave point as is.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 ;; But this causes point to not be restored at times.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 ;; Also, it may not be a visible window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 ;; (set-window-point window edebug-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 ;; Unrestore edebug-buffer's point. Rerestored below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 ;; (goto-char edebug-point) ;; in edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 ;; Since we may be in a save-excursion, in case of quit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 ;; reselect the outside window only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 ;; Only needed if we are not recovering windows??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 (if (edebug-window-live-p edebug-outside-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 (select-window edebug-outside-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 ) ; if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 ;; Restore current buffer always, in case application needs it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 (set-buffer edebug-outside-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 ;; Restore point, and mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 ;; Needed even if restoring windows because
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2768 ;; that doesn't restore point and mark in the current buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2769 ;; But don't restore point if edebug-buffer is current buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 (if (not (eq edebug-buffer edebug-outside-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 (goto-char edebug-outside-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 (if (marker-buffer (edebug-mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 ;; Does zmacs-regions need to be nil while doing set-marker?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 (set-marker (edebug-mark-marker) edebug-outside-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 ) ; unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 ;; None of the following is done if quit or signal occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 ;; Restore edebug-buffer's outside point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 ;; (edebug-trace "restore edebug-buffer point: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 ;; edebug-buffer-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 (let ((current-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 (set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 (goto-char edebug-buffer-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 (set-buffer current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 ;; ... nothing more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 ;; Reset global variables to outside values in case they were changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 overlay-arrow-position edebug-outside-o-a-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 overlay-arrow-string edebug-outside-o-a-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 cursor-in-echo-area edebug-outside-c-i-e-a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 (defvar edebug-number-of-recursions 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 ;; Number of recursive edits started by edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 ;; Should be 0 at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 (defvar edebug-recursion-depth 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 ;; Value of recursion-depth when edebug was called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 ;; Dynamically declared unbound vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 (defvar edebug-outside-match-data) ; match data outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 (defvar edebug-backtrace-buffer) ; each recursive edit gets its own
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 (defvar edebug-inside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 (defvar edebug-interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 (defvar edebug-outside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 (defvar edebug-outside-standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 (defvar edebug-outside-standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 (defvar edebug-outside-last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 (defvar edebug-outside-last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 (defvar edebug-outside-this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 (defvar edebug-outside-last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 ;; Note: here we have defvars for variables that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 ;; built-in in certain versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 ;; Each defvar makes a difference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 ;; in versions where the variable is *not* built-in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 ;; Emacs 18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 (defvar edebug-outside-unread-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 ;; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 (defvar edebug-outside-unread-command-event) ;; like unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 (defvar unread-command-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 ;; Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 (defvar edebug-outside-last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 (defvar edebug-outside-unread-command-events)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 (defvar edebug-outside-last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 (defvar edebug-outside-last-event-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 (defvar edebug-outside-last-nonmenu-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 (defvar edebug-outside-track-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 ;; Disable byte compiler warnings about unread-command-char and -event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 ;; (maybe works with byte-compile-version 2.22 at least)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 (defvar edebug-unread-command-char-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 (defvar edebug-unread-command-event-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 (setq edebug-unread-command-char-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 (get 'unread-command-char 'byte-obsolete-variable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 (put 'unread-command-char 'byte-obsolete-variable nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 (setq edebug-unread-command-event-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 (get 'unread-command-event 'byte-obsolete-variable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 (put 'unread-command-event 'byte-obsolete-variable nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 (defun edebug-recursive-edit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 ;; Start up a recursive edit inside of edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 ;; The current buffer is the edebug-buffer, which is put into edebug-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 ;; Assume that none of the variables below are buffer-local.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 (let ((edebug-buffer-read-only buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 ;; match-data must be done in the outside buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 (edebug-outside-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 (save-excursion ; might be unnecessary now??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 (set-buffer edebug-outside-buffer) ; in case match buffer different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 (match-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 ;;(edebug-number-of-recursions (1+ edebug-number-of-recursions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 (edebug-recursion-depth (recursion-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 edebug-entered ; bind locally to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 (edebug-interactive-p nil) ; again non-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 edebug-backtrace-buffer ; each recursive edit gets its own
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 ;; The window configuration may be saved and restored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 ;; during a recursive-edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 (edebug-outside-map (current-local-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 (edebug-outside-standard-output standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 (edebug-outside-standard-input standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 (edebug-outside-defining-kbd-macro defining-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 (edebug-outside-last-command-char last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 (edebug-outside-last-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 (edebug-outside-this-command this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 (edebug-outside-last-input-char last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 ;; XEmacs: added the boundp checks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 (edebug-outside-unread-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 (and (boundp 'unread-command-char) unread-command-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 (edebug-outside-last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 (and (boundp 'last-input-event) last-input-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 (edebug-outside-last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 (and (boundp 'last-command-event) last-command-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 (edebug-outside-unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 (and (boundp 'unread-command-event) unread-command-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 (edebug-outside-unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 (and (boundp 'unread-command-events) unread-command-events))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 (edebug-outside-last-event-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 (and (boundp 'last-event-frame) last-event-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 (edebug-outside-last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 (and (boundp 'last-nonmenu-event) last-nonmenu-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 (edebug-outside-track-mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 (and (boundp 'track-mouse) track-mouse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 ;; Declare global values local but using the same global value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 ;; We could set these to the values for previous edebug call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 (last-command-char last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 (last-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 (this-command this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 (last-input-char last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 ;; Assume no edebug command sets unread-command-char.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 (unread-command-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 ;; More for Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 (last-input-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 (last-command-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 (unread-command-event nil);; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 (unread-command-events nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 (last-event-frame nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 (last-nonmenu-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 (track-mouse nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 ;; Bind again to outside values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 (debug-on-error edebug-outside-debug-on-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 (debug-on-quit edebug-outside-debug-on-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 ;; Don't keep defining a kbd macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 (defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 (if edebug-continue-kbd-macro defining-kbd-macro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 ;; others??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 (if (fboundp 'zmacs-deactivate-region);; for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 (zmacs-deactivate-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 (if (and (eq edebug-execution-mode 'go)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 (not (memq edebug-arg-mode '(after error))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 (message "Break"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 (fset 'signal (symbol-function 'edebug-original-signal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 (edebug-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 (recursive-edit) ; <<<<<<<<<< Recursive edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 ;; Do the following, even if quit occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 (fset 'signal 'edebug-signal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 (if edebug-backtrace-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 (kill-buffer edebug-backtrace-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 ;; Could be an option to keep eval display up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 (if edebug-eval-buffer (kill-buffer edebug-eval-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 ;; Remember selected-window after recursive-edit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 ;; (setq edebug-inside-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 (store-match-data edebug-outside-match-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 ;; Recursive edit may have changed buffers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 ;; so set it back before exiting let.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 (if (buffer-name edebug-buffer) ; if it still exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 (set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 (if (memq edebug-execution-mode '(go Go-nonstop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 (edebug-overlay-arrow))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 (setq buffer-read-only edebug-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 (use-local-map edebug-outside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 ;; gotta have a buffer to let its buffer local variables be set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 (get-buffer-create " bogus edebug buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 ));; inner let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 ;; Reset global vars to outside values, in case they have been changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 last-command-char edebug-outside-last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 last-command-event edebug-outside-last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 last-command edebug-outside-last-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 this-command edebug-outside-this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 unread-command-char edebug-outside-unread-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 unread-command-event edebug-outside-unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 unread-command-events edebug-outside-unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 last-input-char edebug-outside-last-input-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 last-input-event edebug-outside-last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 last-event-frame edebug-outside-last-event-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 last-nonmenu-event edebug-outside-last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 track-mouse edebug-outside-track-mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 standard-output edebug-outside-standard-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 standard-input edebug-outside-standard-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 defining-kbd-macro edebug-outside-defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 ))
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
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2992 ;;; Display related functions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 (defun edebug-adjust-window (old-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 ;; If pos is not visible, adjust current window to fit following context.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2996 ;;; (message "window: %s old-start: %s window-start: %s pos: %s"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
2997 ;;; (selected-window) old-start (window-start) (point)) (sit-for 5)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 (if (not (pos-visible-in-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 ;; First try old-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 (if old-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 (set-window-start (selected-window) old-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 (if (not (pos-visible-in-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 ;; (message "resetting window start") (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 (set-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 (forward-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 (if (< (point) (window-start)) -1 ; one line before if in back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 (- (/ (window-height) 2)) ; center the line moving forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 (defconst edebug-arrow-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 '((Continue-fast . "=")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 (Trace-fast . "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 (continue . ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 (trace . "->")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 (step . "=>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 (next . "=>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 (go . "<>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 (Go-nonstop . "..") ; not used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 "Association list of arrows for each edebug mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 (defun edebug-overlay-arrow ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 ;; Set up the overlay arrow at beginning-of-line in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 ;; The arrow string is derived from edebug-arrow-alist and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 ;; edebug-execution-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 (let ((pos (save-excursion (beginning-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 (setq overlay-arrow-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 (cdr (assq edebug-execution-mode edebug-arrow-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 (setq overlay-arrow-position (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 (set-marker overlay-arrow-position pos (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040
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-all-windows ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 "Toggle the saving and restoring of all windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 Also, each time you toggle it on, the inside and outside window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 configurations become the same as the current configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 (setq edebug-save-windows (not edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 (setq edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 (setq edebug-outside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 (edebug-current-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 edebug-save-windows))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 (message "Window saving is %s for all windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 (if edebug-save-windows "on" "off")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 (defmacro edebug-changing-windows (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 (` (let ((window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 (setq edebug-inside-windows (edebug-current-windows t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 (edebug-set-windows edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 (,@ body) ;; Code to change edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 (setq edebug-outside-windows (edebug-current-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 ;; Problem: what about outside windows that are deleted inside?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 (edebug-set-windows edebug-inside-windows))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 (defun edebug-toggle-save-selected-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 "Toggle the saving and restoring of the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 Also, each time you toggle it on, the inside and outside window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 configurations become the same as the current configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 ((eq t edebug-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 ;; Save all outside windows except the selected one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 ;; Remove (selected-window) from outside-windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 (edebug-changing-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 (setq edebug-save-windows (delq window (edebug-window-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 ((memq (selected-window) edebug-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 (setq edebug-outside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 (delq (assq (selected-window) edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 edebug-outside-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 (setq edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 (delq (selected-window) edebug-save-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 (t ; Save a new window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 (edebug-changing-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 (setq edebug-save-windows (cons window edebug-save-windows)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 (message "Window saving is %s for %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 (if (memq (selected-window) edebug-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 "on" "off")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 (defun edebug-toggle-save-windows (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 "Toggle the saving and restoring of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 With prefix, toggle for just the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 Otherwise, toggle for all windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 (edebug-toggle-save-selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 (edebug-toggle-save-all-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101
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-where ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 "Show the debug windows and where we stopped in the program."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 (if (not edebug-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 (error "Edebug is not active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 ;; Restore the window configuration to what it last was inside.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 ;; But it is not always set. - experiment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 ;;(if edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 ;; (edebug-set-windows edebug-inside-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 (edebug-pop-to-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 (goto-char edebug-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 (defun edebug-view-outside ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 "Change to the outside window configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 (if (not edebug-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 (error "Edebug is not active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 (setq edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 (edebug-current-windows edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 (edebug-set-windows edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 (goto-char edebug-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 (message "Window configuration outside of Edebug. Return with %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 (substitute-command-keys "\\<global-map>\\[edebug-where]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 (defun edebug-bounce-point (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 "Bounce the point in the outside current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 If prefix arg is supplied, sit for that many seconds before returning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 The default is one second."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 (if (not edebug-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 (error "Edebug is not active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 ;; If the buffer's currently displayed, avoid set-window-configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 (edebug-pop-to-buffer edebug-outside-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 (goto-char edebug-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 (message "Current buffer: %s Point: %s Mark: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 (current-buffer) (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 (if (marker-buffer (edebug-mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 (marker-position (edebug-mark-marker)) "<not set>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 (edebug-sit-for arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 (edebug-pop-to-buffer edebug-buffer (car edebug-window-data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 ;; 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
3149 ;; display list. Still need to use this list in edebug-display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 '(defvar edebug-display-buffer-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 "List of buffers that edebug will display when it is active.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 '(defun edebug-display-buffer (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 "Toggle display of a buffer inside of edebug."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 (interactive "bBuffer: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 (let ((already-displaying (memq buffer edebug-display-buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 (setq edebug-display-buffer-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 (if already-displaying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 (delq buffer edebug-display-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 (cons buffer edebug-display-buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 (message "Displaying %s %s" buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 (if already-displaying "off" "on"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3165 ;;; Breakpoint related functions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 (defun edebug-find-stop-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 ;; Return (function . index) of the nearest edebug stop point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 (let* ((edebug-def-name (edebug-form-data-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 (edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 (let ((data (get edebug-def-name 'edebug)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 (if (or (null data) (markerp data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 (error "%s is not instrumented for Edebug" edebug-def-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 data)) ; we could do it automatically, if data is a marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 ;; pull out parts of edebug-data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 (edebug-def-mark (car edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 ;; (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 (offset-vector (nth 2 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 (offset (- (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 (if (looking-at "[ \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 ;; skip backwards until non-whitespace, or bol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 (skip-chars-backward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 edebug-def-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 len i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 ;; the offsets are in order so we can do a linear search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 (setq len (length offset-vector))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 (setq i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 (while (and (< i len) (> offset (aref offset-vector i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 (if (and (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 (<= offset (aref offset-vector i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 ;; return the relevant info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 (cons edebug-def-name i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 (message "Point is not on an expression in %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 (defun edebug-next-breakpoint ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 "Move point to the next breakpoint, or first if none past point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 ;; pull out parts of edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 (edebug-def-mark (car edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 (offset-vector (nth 2 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 (if (not edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 (message "No breakpoints in this function.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 (let ((breaks edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 (while (and breaks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 (<= (car (car breaks)) index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 (setq breaks (cdr breaks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 (setq breakpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 (if breaks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 (car breaks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 ;; goto the first breakpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 (car edebug-breakpoints)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 (goto-char (+ edebug-def-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 (aref offset-vector (car breakpoint))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3229 (message "%s"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3230 (concat (if (nth 2 breakpoint)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 "Temporary " "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 (if (car (cdr breakpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 (format "Condition: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 (edebug-safe-prin1-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 (car (cdr breakpoint))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 ))))))
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 (defun edebug-modify-breakpoint (flag &optional condition temporary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 "Modify the breakpoint for the form at point or after it according
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 to FLAG: set if t, clear if nil. Then move to that point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 If CONDITION or TEMPORARY are non-nil, add those attributes to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 the breakpoint. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 ;; pull out parts of edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 (edebug-def-mark (car edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 (offset-vector (nth 2 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 present)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 ;; delete it either way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 (setq present (assq index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 (setq edebug-breakpoints (delq present edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 (if flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 ;; add it to the list and resort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 (setq edebug-breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 (edebug-sort-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 (list index condition temporary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 edebug-breakpoints) '<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 (if condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 (message "Breakpoint set in %s with condition: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 edebug-def-name condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 (message "Breakpoint set in %s" edebug-def-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 (if present
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 (message "Breakpoint unset in %s" edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 (message "No breakpoint here")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 (setcar (cdr edebug-data) edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 (goto-char (+ edebug-def-mark (aref offset-vector index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 (defun edebug-set-breakpoint (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 "Set the breakpoint of nearest sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 With prefix argument, make it a temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 (edebug-modify-breakpoint t nil arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 (defun edebug-unset-breakpoint ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 "Clear the breakpoint of nearest sexp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 (edebug-modify-breakpoint nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 ;; For emacs 18, no read-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 (defun edebug-set-conditional-breakpoint (arg condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 "Set a conditional breakpoint at nearest sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 The condition is evaluated in the outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 With prefix argument, make it a temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 ;; (interactive "P\nxCondition: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299 current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 ;; Edit previous condition as follows, but it is cumbersome:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307 (edebug-break-data (assq index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 (edebug-break-condition (car (cdr edebug-break-data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 (read-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 (format "Condition in %s: " edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311 (if edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 (format "%s" edebug-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 (format ""))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 (edebug-modify-breakpoint t condition arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 (defun edebug-set-global-break-condition (expression)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 (interactive (list (read-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319 "Global Condition: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 (format "%s" edebug-global-break-condition))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 (setq edebug-global-break-condition expression))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3324 ;;; Mode switching functions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 (defun edebug-set-mode (mode shortmsg msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327 ;; Set the edebug mode to MODE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 ;; Display SHORTMSG, or MSG if not within edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 (if (eq (1+ edebug-recursion-depth) (recursion-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331 (setq edebug-execution-mode mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 (message shortmsg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 ;; Continue execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 (exit-recursive-edit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 ;; This is not terribly useful!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 (setq edebug-next-execution-mode mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 (message msg)))
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 (defalias 'edebug-step-through-mode 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 (defun edebug-step-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 "Proceed to next stop point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 (edebug-set-mode 'step "" "Edebug will stop at next stop point."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 (defun edebug-next-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 "Proceed to next `after' stop point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 (edebug-set-mode 'next "" "Edebug will stop after next eval."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 (defun edebug-go-mode (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353 "Go, evaluating until break.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354 With prefix ARG, set temporary break at current point and go."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357 (edebug-set-breakpoint t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 (edebug-set-mode 'go "Go..." "Edebug will go until break."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 (defun edebug-Go-nonstop-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361 "Go, evaluating without debugging."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363 (edebug-set-mode 'Go-nonstop "Go-Nonstop..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364 "Edebug will not stop at breaks."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367 (defun edebug-trace-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368 "Begin trace mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3370 (edebug-set-mode 'trace "Tracing..." "Edebug will trace with pause."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 (defun edebug-Trace-fast-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373 "Trace with no wait at each step."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 (edebug-set-mode 'Trace-fast
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 "Trace fast..." "Edebug will trace without pause."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 (defun edebug-continue-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 "Begin continue mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 (edebug-set-mode 'continue "Continue..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 "Edebug will pause at breakpoints."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 (defun edebug-Continue-fast-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 "Trace with no wait at each step."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387 (edebug-set-mode 'Continue-fast "Continue fast..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 "Edebug will stop and go at breakpoints."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 ;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 ;; The following use the mode changing commands and breakpoints.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 (defun edebug-goto-here ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395 "Proceed to this stop point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397 (edebug-go-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400 (defun edebug-stop ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401 "Stop execution and do not continue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402 Useful for exiting from trace or continue loop."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 (message "Stop"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407 '(defun edebug-forward ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3408 "Proceed to the exit of the next expression to be evaluated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410 (edebug-set-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3411 'forward "Forward"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3412 "Edebug will stop after exiting the next expression."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3415 (defun edebug-forward-sexp (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3416 "Proceed from the current point to the end of the ARGth sexp ahead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3417 If there are not ARG sexps ahead, then do edebug-step-out."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3420 (let ((parse-sexp-ignore-comments t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421 ;; Call forward-sexp repeatedly until done or failure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3422 (forward-sexp arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3423 (edebug-go-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3424 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3425 (edebug-step-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3426 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3428 (defun edebug-step-out ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3429 "Proceed from the current point to the end of the containing sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3430 If there is no containing sexp that is not the top level defun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3431 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
3432 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3433 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3434 (let ((parse-sexp-ignore-comments t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3435 (up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3436 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3437 ;; Is there still a containing expression?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3438 (up-list 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3439 (edebug-go-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3440 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441 ;; 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
3442 (let ((start-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443 ;; (up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444 (down-list -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3445 (if (= (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3446 (edebug-step-mode) ; No more at this level, so step.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3447 (edebug-go-mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450 (defun edebug-instrument-function (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3451 ;; Func should be a function symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3452 ;; Return the function symbol, or nil if not instrumented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 (let ((func-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454 (setq func-marker (get func 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456 ((markerp func-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 ;; It is uninstrumented, so instrument it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459 (set-buffer (marker-buffer func-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460 (goto-char func-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461 (edebug-eval-top-level-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3462 func))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 ((consp func-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3464 (message "%s is already instrumented." func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465 func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 ;; We could try harder, e.g. do a tags search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 (error "Don't know where %s is defined" func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 (defun edebug-instrument-callee ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 "Instrument the definition of the function or macro about to be called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 Do this when stopped before the form or it will be too late.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 One side effect of using this command is that the next time the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 function or macro is called, Edebug will be called there as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477 (if (not (looking-at "\("))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478 (error "You must be before a list form")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 (let ((func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 (down-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482 (if (looking-at "\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483 (edebug-form-data-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 (edebug-get-form-data-entry (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 (edebug-original-read (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 (edebug-instrument-function func))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 (defun edebug-step-in ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490 "Step into the definition of the function or macro about to be called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491 This first does `edebug-instrument-callee' to ensure that it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 instrumented. Then it does `edebug-on-entry' and switches to `go' mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 (let ((func (edebug-instrument-callee)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 (if func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 (edebug-on-entry func 'temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 (edebug-go-mode nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 (defun edebug-on-entry (function &optional flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3501 "Cause Edebug to stop when FUNCTION is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502 With prefix argument, make this temporary so it is automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503 cancelled the first time the function is entered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 (interactive "aEdebug on entry to: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 ;; Could store this in the edebug data instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 (put function 'edebug-on-entry (if flag 'temp t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 (defun cancel-edebug-on-entry (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509 (interactive "aEdebug on entry to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3510 (put function 'edebug-on-entry nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3513 (if (not (fboundp 'edebug-original-debug-on-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3514 (fset 'edebug-original-debug-on-entry (symbol-function 'debug-on-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3515 '(fset 'debug-on-entry 'edebug-debug-on-entry) ;; Should we do this?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3516 ;; Also need edebug-cancel-debug-on-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3518 '(defun edebug-debug-on-entry (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3519 "Request FUNCTION to invoke debugger each time it is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3520 If the user continues, FUNCTION's execution proceeds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3521 Works by modifying the definition of FUNCTION,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3522 which must be written in Lisp, not predefined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3523 Use `cancel-debug-on-entry' to cancel the effect of this command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3524 Redefining FUNCTION also does that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3526 This version is from Edebug. If the function is instrumented for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3527 Edebug, it calls `edebug-on-entry'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3528 (interactive "aDebug on entry (to function): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3529 (let ((func-data (get function 'edebug)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3530 (if (or (null func-data) (markerp func-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3531 (edebug-original-debug-on-entry function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3532 (edebug-on-entry function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3535 (defun edebug-top-level-nonstop ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3536 "Set mode to Go-nonstop, and exit to top-level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3537 This is useful for exiting even if unwind-protect code may be executed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3538 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3539 (setq edebug-execution-mode 'Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3540 (top-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3543 ;;(defun edebug-exit-out ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3544 ;; "Go until the current function exits."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3545 ;; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3546 ;; (edebug-set-mode 'exiting "Exit..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3548
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3549 ;;; The following initial mode setting definitions are not used yet.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3551 '(defconst edebug-initial-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3552 '((edebug-Continue-fast . Continue-fast)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3553 (edebug-Trace-fast . Trace-fast)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3554 (edebug-continue . continue)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3555 (edebug-trace . trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 (edebug-go . go)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557 (edebug-step-through . step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558 (edebug-Go-nonstop . Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3559 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 "Association list between commands and the modes they set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563 '(defun edebug-set-initial-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564 "Ask for the initial mode of the enclosing function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565 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
3566 edebug-mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3567 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3568 (let* ((this-function (edebug-which-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3569 (keymap (if (eq edebug-mode-map (current-local-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3570 edebug-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3571 (old-mode (or (get this-function 'edebug-initial-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3572 edebug-initial-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573 (key (read-key-sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575 "Change initial edebug mode for %s from %s (%s) to (enter key): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576 this-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577 old-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578 (where-is-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579 (car (rassq old-mode edebug-initial-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3580 keymap 'firstonly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3581 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 (mode (cdr (assq (key-binding key) edebug-initial-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3583 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3584 (if (and mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3585 (or (get this-function 'edebug-initial-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3586 (not (eq mode edebug-initial-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3587 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588 (put this-function 'edebug-initial-mode mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3589 (message "Initial mode for %s is now: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3590 this-function mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3591 (error "Key must map to one of the mode changing commands")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3592 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3593
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3594 ;;; Evaluation of expressions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3596 (def-edebug-spec edebug-outside-excursion t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598 (defmacro edebug-outside-excursion (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 "Evaluate an expression list in the outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600 Return the result of the last expression."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601 (` (save-excursion ; of current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604 ;; After excursion, we will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 ;; restore to current window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606 (setq edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3607 (edebug-current-windows edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608 ;; Restore outside windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 (edebug-set-windows edebug-outside-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 (set-buffer edebug-buffer) ; why?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612 ;; (use-local-map edebug-outside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613 (store-match-data edebug-outside-match-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614 ;; Restore outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615 (let (;; (edebug-inside-map (current-local-map)) ;; restore map??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3616 (last-command-char edebug-outside-last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617 (last-command-event edebug-outside-last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3618 (last-command edebug-outside-last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619 (this-command edebug-outside-this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3620 (unread-command-char edebug-outside-unread-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3621 (unread-command-event edebug-outside-unread-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3622 (unread-command-events edebug-outside-unread-command-events)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623 (last-input-char edebug-outside-last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 (last-input-event edebug-outside-last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625 (last-event-frame edebug-outside-last-event-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3626 (last-nonmenu-event edebug-outside-last-nonmenu-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627 (track-mouse edebug-outside-track-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3628 (standard-output edebug-outside-standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3629 (standard-input edebug-outside-standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3630
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
3631 (executing-kbd-macro edebug-outside-executing-macro)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3632 (defining-kbd-macro edebug-outside-defining-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3633 (pre-command-hook edebug-outside-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3634 (post-command-hook edebug-outside-post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3635 (post-command-idle-hook edebug-outside-post-command-idle-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3637 ;; See edebug-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3638 (overlay-arrow-position edebug-outside-o-a-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3639 (overlay-arrow-string edebug-outside-o-a-s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3640 (cursor-in-echo-area edebug-outside-c-i-e-a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3641 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3642 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3643 (save-excursion ; of edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3644 (set-buffer edebug-outside-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3645 (goto-char edebug-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3646 (if (marker-buffer (edebug-mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3647 (set-marker (edebug-mark-marker) edebug-outside-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3648 (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3650 ;; Back to edebug-buffer. Restore rest of inside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3651 ;; (use-local-map edebug-inside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3652 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3653 ;; Restore inside windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3654 (edebug-set-windows edebug-inside-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3656 ;; Save values that may have been changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3657 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3658 edebug-outside-last-command-char last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3659 edebug-outside-last-command-event last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3660 edebug-outside-last-command last-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3661 edebug-outside-this-command this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3662 edebug-outside-unread-command-char unread-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3663 edebug-outside-unread-command-event unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3664 edebug-outside-unread-command-events unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3665 edebug-outside-last-input-char last-input-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3666 edebug-outside-last-input-event last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3667 edebug-outside-last-event-frame last-event-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3668 edebug-outside-last-nonmenu-event last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3669 edebug-outside-track-mouse track-mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3670 edebug-outside-standard-output standard-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3671 edebug-outside-standard-input standard-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3672
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
3673 edebug-outside-executing-macro executing-kbd-macro
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3674 edebug-outside-defining-kbd-macro defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3675 edebug-outside-pre-command-hook pre-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3676 edebug-outside-post-command-hook post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3677 edebug-outside-post-command-idle-hook post-command-idle-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3679 edebug-outside-o-a-p overlay-arrow-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3680 edebug-outside-o-a-s overlay-arrow-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3681 edebug-outside-c-i-e-a cursor-in-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3682 ))) ; let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3683 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3685 (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
3686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3687 (defun edebug-eval (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3688 ;; Are there cl lexical variables active?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3689 (if cl-debug-env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3690 (eval (cl-macroexpand-all edebug-expr cl-debug-env))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3691 (eval edebug-expr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3693 (defun edebug-safe-eval (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3694 ;; Evaluate EXPR safely.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3695 ;; If there is an error, a string is returned describing the error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3696 (condition-case edebug-err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3697 (edebug-eval edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3698 (error (edebug-format "%s: %s" ;; could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3699 (get (car edebug-err) 'error-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3700 (car (cdr edebug-err))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3701
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3702 ;;; Printing
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3703
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3704 ;; Replace printing functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3706 ;; obsolete names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3707 (defalias 'edebug-install-custom-print-funcs 'edebug-install-custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3708 (defalias 'edebug-reset-print-funcs 'edebug-uninstall-custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3709 (defalias 'edebug-uninstall-custom-print-funcs 'edebug-uninstall-custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3711 (defun edebug-install-custom-print ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3712 "Replace print functions used by Edebug with custom versions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3713 ;; Modifying the custom print functions, or changing print-length,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3714 ;; print-level, print-circle, custom-print-list or custom-print-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3715 ;; have immediate effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3716 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3717 (require 'cust-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3718 (defalias 'edebug-prin1 'custom-prin1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3719 (defalias 'edebug-print 'custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3720 (defalias 'edebug-prin1-to-string 'custom-prin1-to-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3721 (defalias 'edebug-format 'custom-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3722 (defalias 'edebug-message 'custom-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3723 "Installed")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3725 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3726 (defun edebug-uninstall-custom-print ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3727 "Replace edebug custom print functions with internal versions."
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 (defalias 'edebug-prin1 'prin1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3730 (defalias 'edebug-print 'print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3731 (defalias 'edebug-prin1-to-string 'prin1-to-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3732 (defalias 'edebug-format 'format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3733 (defalias 'edebug-message 'message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3734 "Uninstalled")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3736 ;; Default print functions are the same as Emacs'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3737 (edebug-uninstall-custom-print))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3740 (defun edebug-report-error (edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3741 ;; Print an error message like command level does.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3742 ;; This also prints the error name if it has no error-message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3743 (message "%s: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3744 (or (get (car edebug-value) 'error-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3745 (format "peculiar error (%s)" (car edebug-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3746 (mapconcat (function (lambda (edebug-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3747 ;; continuing after an error may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3748 ;; complain about edebug-arg. why??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3749 (prin1-to-string edebug-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3750 (cdr edebug-value) ", ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3752 ;; Define here in case they are not already defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3753 (defvar print-level nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3754 (defvar print-circle nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3755 (defvar print-readably) ;; defined by XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3756 ;; Alternatively, we could change the definition of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3757 ;; edebug-safe-prin1-to-string to only use these if defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3759 (defun edebug-safe-prin1-to-string (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3760 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3761 (print-length (or edebug-print-length print-length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3762 (print-level (or edebug-print-level print-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3763 (print-circle (or edebug-print-circle print-circle))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3764 (print-readably nil)) ;; XEmacs uses this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3765 (edebug-prin1-to-string value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3767 (defun edebug-compute-previous-result (edebug-previous-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3768 (setq edebug-previous-result
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
3769 (if (numberp edebug-previous-value)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
3770 (format "Result: %s" edebug-previous-value)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3771 (if edebug-unwrap-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3772 (setq edebug-previous-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3773 (edebug-unwrap* edebug-previous-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3774 (concat "Result: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3775 (edebug-safe-prin1-to-string edebug-previous-value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3777 (defun edebug-previous-result ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3778 "Print the previous result."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3779 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3780 (message "%s" edebug-previous-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3781
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3782 ;;; Read, Eval and Print
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3784 (defun edebug-eval-expression (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3785 "Evaluate an expression in the outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3786 If interactive, prompt for the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3787 Print result in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3788 (interactive "xEval: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3789 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3790 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3791 (setq values (cons (edebug-eval edebug-expr) values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3792 (edebug-safe-prin1-to-string (car values)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3794 (defun edebug-eval-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3795 "Evaluate sexp before point in the outside environment;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3796 print value in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3797 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3798 (edebug-eval-expression (edebug-last-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3800 (defun edebug-eval-print-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3801 "Evaluate sexp before point in the outside environment;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3802 print value into current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3803 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3804 (let* ((edebug-form (edebug-last-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3805 (edebug-result-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3806 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3807 (edebug-safe-prin1-to-string (edebug-safe-eval edebug-form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3808 (standard-output (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3809 (princ "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3810 ;; princ the string to get rid of quotes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3811 (princ edebug-result-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3812 (princ "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3813 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3814
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3815 ;;; Edebug Minor Mode
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3816
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3817 ;; Global GUD bindings for all emacs-lisp-mode buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3818 (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
3819 (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
3820 (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
3821 (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
3822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3824 (defvar edebug-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3825 (if edebug-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3826 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3827 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3828 (setq edebug-mode-map (copy-keymap emacs-lisp-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3829 ;; control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3830 (define-key edebug-mode-map " " 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3831 (define-key edebug-mode-map "n" 'edebug-next-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3832 (define-key edebug-mode-map "g" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3833 (define-key edebug-mode-map "G" 'edebug-Go-nonstop-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3834 (define-key edebug-mode-map "t" 'edebug-trace-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3835 (define-key edebug-mode-map "T" 'edebug-Trace-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3836 (define-key edebug-mode-map "c" 'edebug-continue-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3837 (define-key edebug-mode-map "C" 'edebug-Continue-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3839 ;;(define-key edebug-mode-map "f" 'edebug-forward) not implemented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3840 (define-key edebug-mode-map "f" 'edebug-forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3841 (define-key edebug-mode-map "h" 'edebug-goto-here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3843 (define-key edebug-mode-map "I" 'edebug-instrument-callee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3844 (define-key edebug-mode-map "i" 'edebug-step-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3845 (define-key edebug-mode-map "o" 'edebug-step-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3847 ;; quitting and stopping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3848 (define-key edebug-mode-map "q" 'top-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3849 (define-key edebug-mode-map "Q" 'edebug-top-level-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3850 (define-key edebug-mode-map "a" 'abort-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3851 (define-key edebug-mode-map "S" 'edebug-stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3853 ;; breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3854 (define-key edebug-mode-map "b" 'edebug-set-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3855 (define-key edebug-mode-map "u" 'edebug-unset-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3856 (define-key edebug-mode-map "B" 'edebug-next-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3857 (define-key edebug-mode-map "x" 'edebug-set-conditional-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3858 (define-key edebug-mode-map "X" 'edebug-set-global-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3860 ;; evaluation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3861 (define-key edebug-mode-map "r" 'edebug-previous-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3862 (define-key edebug-mode-map "e" 'edebug-eval-expression)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3863 (define-key edebug-mode-map "\C-x\C-e" 'edebug-eval-last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3864 (define-key edebug-mode-map "E" 'edebug-visit-eval-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3866 ;; views
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3867 (define-key edebug-mode-map "w" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3868 (define-key edebug-mode-map "v" 'edebug-view-outside) ;; maybe obsolete??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3869 (define-key edebug-mode-map "p" 'edebug-bounce-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3870 (define-key edebug-mode-map "P" 'edebug-view-outside) ;; same as v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3871 (define-key edebug-mode-map "W" 'edebug-toggle-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3873 ;; misc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3874 (define-key edebug-mode-map "?" 'edebug-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3875 (define-key edebug-mode-map "d" 'edebug-backtrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3877 (define-key edebug-mode-map "-" 'negative-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3879 ;; statistics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3880 (define-key edebug-mode-map "=" 'edebug-temp-display-freq-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3882 ;; GUD bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3883 (define-key edebug-mode-map "\C-c\C-s" 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3884 (define-key edebug-mode-map "\C-c\C-n" 'edebug-next-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3885 (define-key edebug-mode-map "\C-c\C-c" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3887 (define-key edebug-mode-map "\C-x " 'edebug-set-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3888 (define-key edebug-mode-map "\C-c\C-d" 'edebug-unset-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3889 (define-key edebug-mode-map "\C-c\C-t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3890 (function (lambda () (edebug-set-breakpoint t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3891 (define-key edebug-mode-map "\C-c\C-l" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3892 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3893
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3894 ;; Autoloading these global bindings doesn't make sense because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3895 ;; they cannot be used anyway unless Edebug is already loaded and active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3897 (defvar global-edebug-prefix "\^XX"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3898 "Prefix key for global edebug commands, available from any buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3900 (defvar global-edebug-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3901 "Global map of edebug commands, available from any buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3903 (if global-edebug-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3904 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3905 (setq global-edebug-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3907 (global-unset-key global-edebug-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3908 (global-set-key global-edebug-prefix global-edebug-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3910 (define-key global-edebug-map " " 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3911 (define-key global-edebug-map "g" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3912 (define-key global-edebug-map "G" 'edebug-Go-nonstop-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3913 (define-key global-edebug-map "t" 'edebug-trace-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3914 (define-key global-edebug-map "T" 'edebug-Trace-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3915 (define-key global-edebug-map "c" 'edebug-continue-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3916 (define-key global-edebug-map "C" 'edebug-Continue-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3918 ;; breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3919 (define-key global-edebug-map "b" 'edebug-set-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3920 (define-key global-edebug-map "u" 'edebug-unset-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3921 (define-key global-edebug-map "x" 'edebug-set-conditional-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3922 (define-key global-edebug-map "X" 'edebug-set-global-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3924 ;; views
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3925 (define-key global-edebug-map "w" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3926 (define-key global-edebug-map "W" 'edebug-toggle-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3928 ;; quitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3929 (define-key global-edebug-map "q" 'top-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3930 (define-key global-edebug-map "Q" 'edebug-top-level-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3931 (define-key global-edebug-map "a" 'abort-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3933 ;; statistics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3934 (define-key global-edebug-map "=" 'edebug-display-freq-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3935 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3937 (defun edebug-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3938 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3939 (describe-function 'edebug-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3941 (defun edebug-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3942 "Mode for Emacs Lisp buffers while in Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3944 In addition to all Emacs Lisp commands (except those that modify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3945 buffer) there are local and global key bindings to several Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3946 specific commands. E.g. `edebug-step-mode' is bound to \\[edebug-step-mode]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3947 in the Edebug buffer and \\<global-map>\\[edebug-step-mode] in any buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3949 Also see bindings for the eval list buffer, *edebug*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3951 The edebug buffer commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3952 \\{edebug-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3954 Global commands prefixed by `global-edebug-prefix':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3955 \\{global-edebug-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3957 Options:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3958 edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3959 edebug-all-defs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3960 edebug-all-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3961 edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3962 edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3963 edebug-initial-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3964 edebug-trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3965 edebug-test-coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3966 edebug-continue-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3967 edebug-print-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3968 edebug-print-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3969 edebug-print-circle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3970 edebug-on-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3971 edebug-on-quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3972 edebug-on-signal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3973 edebug-unwrap-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3974 edebug-global-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3975 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3976 (use-local-map edebug-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3977
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3978 ;;; edebug eval list mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
3979
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3980 ;; A list of expressions and their evaluations is displayed in *edebug*.
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-eval-result-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3983 "Return a list of evaluations of edebug-eval-list"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3984 ;; Assumes in outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3985 ;; Don't do any edebug things now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3986 (let ((edebug-execution-mode 'Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3987 (edebug-trace nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3988 (mapcar 'edebug-safe-eval edebug-eval-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3990 (defun edebug-eval-display-list (edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3991 ;; Assumes edebug-eval-buffer exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3992 (let ((edebug-eval-list-temp edebug-eval-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3993 (standard-output edebug-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3994 (edebug-comment-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3995 (format ";%s\n" (make-string (- (window-width) 2) ?-))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3996 (set-buffer edebug-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3997 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3998 (while edebug-eval-list-temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3999 (prin1 (car edebug-eval-list-temp)) (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4000 (prin1 (car edebug-eval-result-list)) (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4001 (princ edebug-comment-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4002 (setq edebug-eval-list-temp (cdr edebug-eval-list-temp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4003 (setq edebug-eval-result-list (cdr edebug-eval-result-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4004 (edebug-pop-to-buffer edebug-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4005 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4007 (defun edebug-create-eval-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4008 (if (not (and edebug-eval-buffer (buffer-name edebug-eval-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4009 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4010 (set-buffer (setq edebug-eval-buffer (get-buffer-create "*edebug*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4011 (edebug-eval-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4013 ;; Should generalize this to be callable outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4014 ;; with calls in user functions, e.g. (edebug-eval-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4016 (defun edebug-eval-display (edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4017 "Display expressions and evaluations in EVAL-LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4018 It modifies the context by popping up the eval display."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4019 (if edebug-eval-result-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4020 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4021 (edebug-create-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4022 (edebug-eval-display-list edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4023 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4025 (defun edebug-eval-redisplay ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4026 "Redisplay eval list in outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4027 May only be called from within edebug-recursive-edit."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4028 (edebug-create-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4029 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4030 (edebug-eval-display-list (edebug-eval-result-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4031 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4033 (defun edebug-visit-eval-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4034 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4035 (edebug-eval-redisplay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4036 (edebug-pop-to-buffer edebug-eval-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4039 (defun edebug-update-eval-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4040 "Replace the evaluation list with the sexps now in the eval buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4041 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4042 (let ((starting-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4043 new-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4044 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4045 ;; get the first expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4046 (edebug-skip-whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4047 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4048 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4049 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4050 (setq new-list (cons (edebug-last-sexp) new-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4052 (while (re-search-forward "^;" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4053 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4054 (skip-chars-forward " \t\n\r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4055 (if (and (/= ?\; (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4056 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4057 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4058 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4059 (setq new-list (cons (edebug-last-sexp) new-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4061 (setq edebug-eval-list (nreverse new-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4062 (edebug-eval-redisplay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4063 (goto-char starting-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4066 (defun edebug-delete-eval-item ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4067 "Delete the item under point and redisplay."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4068 ;; could add arg to do repeatedly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4069 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4070 (if (re-search-backward "^;" nil 'nofail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4071 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4072 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4073 (point) (progn (re-search-forward "^;" nil 'nofail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4074 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4075 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4076 (edebug-update-eval-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4078
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4080 (defvar edebug-eval-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4081 "Keymap for edebug-eval-mode. Superset of lisp-interaction-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4083 (if edebug-eval-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4084 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4085 (setq edebug-eval-mode-map (copy-keymap lisp-interaction-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4087 (define-key edebug-eval-mode-map "\C-c\C-w" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4088 (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
4089 (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
4090 (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
4091 (define-key edebug-eval-mode-map "\C-j" 'edebug-eval-print-last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4092 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4095 (defun edebug-eval-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4096 "Mode for evaluation list buffer while in Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4098 In addition to all Interactive Emacs Lisp commands there are local and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4099 global key bindings to several Edebug specific commands. E.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4100 `edebug-step-mode' is bound to \\[edebug-step-mode] in the Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4101 buffer and \\<global-map>\\[edebug-step-mode] in any buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4103 Eval list buffer commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4104 \\{edebug-eval-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4106 Global commands prefixed by global-edebug-prefix:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4107 \\{global-edebug-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4108 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4109 (lisp-interaction-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4110 (setq major-mode 'edebug-eval-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4111 (setq mode-name "Edebug-Eval")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4112 (use-local-map edebug-eval-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4113
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4114 ;;; Interface with standard debugger.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4116 ;; (setq debugger 'edebug) ; to use the edebug debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4117 ;; (setq debugger 'debug) ; use the standard debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4119 ;; Note that debug and its utilities must be byte-compiled to work,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4120 ;; since they depend on the backtrace looking a certain way. But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4121 ;; edebug is not dependent on this, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4123 (defun edebug (&optional edebug-arg-mode &rest debugger-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4124 "Replacement for debug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4125 If we are running an edebugged function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4126 show where we last were. Otherwise call debug normally."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4127 ;; (message "entered: %s depth: %s edebug-recursion-depth: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4128 ;; edebug-entered (recursion-depth) edebug-recursion-depth) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4129 (if (and edebug-entered ; anything active?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4130 (eq (recursion-depth) edebug-recursion-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4131 (let (;; Where were we before the error occurred?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4132 (edebug-offset-index (car edebug-offset-indices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4133 ;; Bind variables required by edebug-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4134 (edebug-value (car debugger-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4135 edebug-breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4136 edebug-break-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4137 edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4138 edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4139 (edebug-break (null edebug-arg-mode)) ;; if called explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4140 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4141 (edebug-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4142 (if (eq edebug-arg-mode 'error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4143 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4144 edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4146 ;; Otherwise call debug normally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4147 ;; Still need to remove extraneous edebug calls from stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4148 (apply 'debug edebug-arg-mode debugger-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4149 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4152 (defun edebug-backtrace ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4153 "Display a non-working backtrace. Better than nothing..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4154 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4155 (if (or (not edebug-backtrace-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4156 (null (buffer-name edebug-backtrace-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4157 (setq edebug-backtrace-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4158 (generate-new-buffer "*Backtrace*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4159 ;; else, could just display edebug-backtrace-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4160 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4161 (with-output-to-temp-buffer (buffer-name edebug-backtrace-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4162 (setq edebug-backtrace-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4163 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4164 (print-length 50)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4165 last-ok-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4166 (backtrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4168 ;; Clean up the backtrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4169 ;; Not quite right for current edebug scheme.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4170 (set-buffer edebug-backtrace-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4171 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4172 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4173 (setq last-ok-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4174 (if t (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4176 ;; Delete interspersed edebug internals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4177 (while (re-search-forward "^ \(?edebug" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4178 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4179 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4180 ((looking-at "^ \(edebug-after")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4181 ;; Previous lines may contain code, so just delete this line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4182 (setq last-ok-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4183 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4184 (delete-region last-ok-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4186 ((looking-at "^ edebug")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4187 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4188 (delete-region last-ok-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4189 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4190 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4192
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4193 ;;; Trace display
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4195 (defun edebug-trace-display (buf-name fmt &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4196 "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
4197 The buffer is created if it does not exist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4198 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
4199 ;; e.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4200 ;; (edebug-trace-display "*trace-point*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4201 ;; "saving: point = %s window-start = %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4202 ;; (point) (window-start))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4203 (let* ((oldbuf (current-buffer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4204 (selected-window (selected-window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4205 (buffer (get-buffer-create buf-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4206 buf-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4207 ;; (message "before pop-to-buffer") (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4208 (edebug-pop-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4209 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4210 (setq buf-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4211 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4212 (insert (apply 'edebug-format fmt args) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4213 ;; Make it visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4214 (vertical-motion (- 1 (window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4215 (set-window-start buf-window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4216 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4217 ;; (set-window-point buf-window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4218 ;; (edebug-sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4219 (bury-buffer buffer)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4220 (select-window selected-window)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4221 (set-buffer oldbuf))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4222 buf-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4225 (defun edebug-trace (fmt &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4226 "Convenience call to edebug-trace-display using edebug-trace-buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4227 (apply 'edebug-trace-display edebug-trace-buffer fmt args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4229
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4230 ;;; Frequency count and coverage
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4232 (defun edebug-display-freq-count ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4233 "Display the frequency count data for each line of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4234 definition. The frequency counts are inserted as comment lines after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4235 each line, and you can undo all insertions with one `undo' command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4237 The counts are inserted starting under the `(' before an expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4238 or the `)' after an expression, or on the last char of a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4239 The counts are only displayed when they differ from previous counts on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4240 the same line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4242 If coverage is being tested, whenever all known results of an expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4243 are `eq', the char `=' will be appended after the count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4244 for that expression. Note that this is always the case for an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4245 expression only evaluated once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4247 To clear the frequency count and coverage data for a definition,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4248 reinstrument it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4249 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4250 (let* ((function (edebug-form-data-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4251 (counts (get function 'edebug-freq-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4252 (coverages (get function 'edebug-coverage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4253 (data (get function 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4254 (def-mark (car data)) ; mark at def start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4255 (edebug-points (nth 2 data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4256 (i (1- (length edebug-points)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4257 (last-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4258 (first-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4259 (start-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4260 (start-of-count-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4261 (last-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4262 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4263 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4264 ;; Traverse in reverse order so offsets are correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4265 (while (<= 0 i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4266 ;; Start at last expression in line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4267 (goto-char (+ def-mark (aref edebug-points i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4268 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4269 (setq start-of-line (- (point) def-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4270 last-index i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4272 ;; Find all indexes on same line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4273 (while (and (<= 0 (setq i (1- i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4274 (<= start-of-line (aref edebug-points i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4275 ;; Insert all the indices for this line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4276 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4277 (setq start-of-count-line (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4278 first-index i ; really last index for line above this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4279 last-count -1) ; cause first count to always appear.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4280 (insert ";#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4281 ;; i == first-index still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4282 (while (<= (setq i (1+ i)) last-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4283 (let ((count (aref counts i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4284 (coverage (aref coverages i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4285 (col (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4286 (goto-char (+ (aref edebug-points i) def-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4287 (- (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4288 (if (= ?\( (following-char)) 0 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4289 (insert (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4290 (max 0 (- col (- (point) start-of-count-line))) ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4291 (if (and (< 0 count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4292 (not (memq coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4293 '(unknown ok-coverage))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4294 "=" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4295 (if (= count last-count) "" (int-to-string count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4296 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4297 (setq last-count count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4298 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4299 (setq i first-index)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4301 (defun edebug-temp-display-freq-count ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4302 "Temporarily display the frequency count data for the current definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4303 It is removed when you hit any char."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4304 ;; This seems not to work with Emacs 18.59. It undoes too far.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4305 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4306 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4307 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4308 (edebug-display-freq-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4309 (setq unread-command-char (read-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4310 (undo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4312
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4313 ;;; Menus
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4315 (defun edebug-toggle (variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4316 (set variable (not (eval variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4317 (message "%s: %s" variable (eval variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4319 ;; We have to require easymenu (even for Emacs 18) just so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4320 ;; the easy-menu-define macro call is compiled correctly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4321 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4323 (defconst edebug-mode-menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4324 '("Edebug"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4325 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4326 ["Stop" edebug-stop t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4327 ["Step" edebug-step-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4328 ["Next" edebug-next-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4329 ["Trace" edebug-trace-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4330 ["Trace Fast" edebug-Trace-fast-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4331 ["Continue" edebug-continue-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4332 ["Continue Fast" edebug-Continue-fast-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4333 ["Go" edebug-go-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4334 ["Go Nonstop" edebug-Go-nonstop-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4335 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4336 ["Help" edebug-help t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4337 ["Abort" abort-recursive-edit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4338 ["Quit to Top Level" top-level t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4339 ["Quit Nonstop" edebug-top-level-nonstop t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4340 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4341 ("Jumps"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4342 ["Forward Sexp" edebug-forward-sexp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4343 ["Step In" edebug-step-in t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4344 ["Step Out" edebug-step-out t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4345 ["Goto Here" edebug-goto-here t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4347 ("Breaks"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4348 ["Set Breakpoint" edebug-set-breakpoint t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4349 ["Unset Breakpoint" edebug-unset-breakpoint t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4350 ["Set Conditional Breakpoint" edebug-set-conditional-breakpoint t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4351 ["Set Global Break Condition" edebug-set-global-break-condition t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4352 ["Show Next Breakpoint" edebug-next-breakpoint t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4354 ("Views"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4355 ["Where am I?" edebug-where t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4356 ["Bounce to Current Point" edebug-bounce-point t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4357 ["View Outside Windows" edebug-view-outside t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4358 ["Previous Result" edebug-previous-result t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4359 ["Show Backtrace" edebug-backtrace t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4360 ["Display Freq Count" edebug-display-freq-count t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4362 ("Eval"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4363 ["Expression" edebug-eval-expression t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4364 ["Last Sexp" edebug-eval-last-sexp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4365 ["Visit Eval List" edebug-visit-eval-list t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4367 ("Options"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4368 ["Edebug All Defs" edebug-all-defs t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4369 ["Edebug All Forms" edebug-all-forms t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4370 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4371 ["Toggle Tracing" (edebug-toggle 'edebug-trace) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4372 ["Toggle Coverage Testing" (edebug-toggle 'edebug-test-coverage) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4373 ["Toggle Window Saving" edebug-toggle-save-windows t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4374 ["Toggle Point Saving"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4375 (edebug-toggle 'edebug-save-displayed-buffer-points) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4376 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4377 "XEmacs style menus for Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4379
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4380 ;;; Emacs version specific code
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4381
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4382 ;;; The default for all above is Emacs 18, because it is easier to compile
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4383 ;;; Emacs 18 code in Emacs 19 than vice versa. This default will
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4384 ;;; change once most people are using Emacs 19 or derivatives.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4385
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4386 ;; Epoch specific code is in a separate file: edebug-epoch.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4388 ;; The byte-compiler will complain about changes in number of arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4389 ;; to functions like mark and read-from-minibuffer. These warnings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4390 ;; may be ignored because the right call should always be made.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4392 (defun edebug-emacs-19-specific ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4394 (defalias 'edebug-window-live-p 'window-live-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4396 ;; Mark takes an argument in Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4397 (defun edebug-mark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4398 (mark t));; Does this work for XEmacs too?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4400 ;; Use minibuffer-history when reading expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4401 (defvar read-expression-history) ;; hush bytecomp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4402 (defvar read-expression-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4404 (defun edebug-set-conditional-breakpoint (arg condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4405 "Set a conditional breakpoint at nearest sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4406 The condition is evaluated in the outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4407 With prefix argument, make it a temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4408 ;; (interactive "P\nxCondition: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4409 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4410 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4411 current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4412 ;; Read condition as follows; getting previous condition is cumbersome:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4413 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4414 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4415 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4416 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4417 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4418 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4419 (edebug-break-data (assq index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4420 (edebug-break-condition (car (cdr edebug-break-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4421 (edebug-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4422 ;; Prepend the current condition, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4423 (if edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4424 (cons edebug-break-condition read-expression-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4425 read-expression-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4426 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4427 (read-from-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4428 "Condition: " nil read-expression-map t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4429 'edebug-expression-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4430 (setq read-expression-history edebug-expression-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4431 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4432 (edebug-modify-breakpoint t condition arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4434 (defun edebug-eval-expression (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4435 "Evaluate an expression in the outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4436 If interactive, prompt for the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4437 Print result in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4438 (interactive (list (read-from-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4439 "Eval: " nil read-expression-map t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4440 'read-expression-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4441 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4442 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4443 (setq values (cons (edebug-eval edebug-expr) values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4444 (edebug-safe-prin1-to-string (car values)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4446 (easy-menu-define edebug-menu edebug-mode-map "Edebug menus" edebug-mode-menus)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4447 (if (eq (console-type) 'x) ; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4448 (x-popup-menu nil (lookup-key edebug-mode-map [menu-bar Edebug])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4449 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4452 (defun edebug-xemacs-specific ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4454 ;; 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
4455 ;; `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
4456 ;; that is, don't interfere with the binding the user might see while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4457 ;; executing a command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4459 (defvar zmacs-regions)
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 edebug-mark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4462 (let ((zmacs-regions nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4463 (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4465 (defun edebug-mark-marker ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4466 (let ((zmacs-regions nil));; for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4467 (mark-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4470 (defun edebug-mode-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4471 (interactive "@event")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4472 (popup-menu edebug-mode-menus))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4474 (define-key edebug-mode-map 'button3 'edebug-mode-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4475 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4477 (defun edebug-emacs-version-specific ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4478 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4479 ((string-match "XEmacs" emacs-version);; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4480 (edebug-xemacs-specific))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4482 ((and (boundp 'epoch::version) epoch::version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4483 (require 'edebug-epoch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4485 ((not (string-match "^18" emacs-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4486 (edebug-emacs-19-specific))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4488 (edebug-emacs-version-specific)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4490
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4491 ;;; Byte-compiler
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4492
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4493 ;; Extension for bytecomp to resolve undefined function references.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4494 ;; Requires new byte compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4496 ;; Reenable byte compiler warnings about unread-command-char and -event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4497 ;; Disabled before edebug-recursive-edit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4498 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4499 (if edebug-unread-command-char-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4500 (put 'unread-command-char 'byte-obsolete-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4501 edebug-unread-command-char-warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4502 (if edebug-unread-command-event-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4503 (put 'unread-command-event 'byte-obsolete-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4504 edebug-unread-command-event-warning)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4506 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4507 ;; The body of eval-when-compile seems to get evaluated with eval-defun.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4508 ;; We only want to evaluate when actually byte compiling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4509 ;; 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
4510 (if (featurep 'byte-compile) (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4512 (defun byte-compile-resolve-functions (funcs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4513 "Say it is OK for the named functions to be unresolved."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4514 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4515 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4516 (lambda (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4517 (setq byte-compile-unresolved-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4518 (delq (assq func byte-compile-unresolved-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4519 byte-compile-unresolved-functions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4520 funcs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4521 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4523 '(defun byte-compile-resolve-free-references (vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4524 "Say it is OK for the named variables to be referenced."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4525 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4526 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4527 (lambda (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4528 (setq byte-compile-free-references
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4529 (delq var byte-compile-free-references))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4530 vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4531 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4533 '(defun byte-compile-resolve-free-assignments (vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4534 "Say it is OK for the named variables to be assigned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4535 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4536 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4537 (lambda (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4538 (setq byte-compile-free-assignments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4539 (delq var byte-compile-free-assignments))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4540 vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4541 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4543 (byte-compile-resolve-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4544 '(reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4545 edebug-gensym ;; also in cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4546 ;; Interfaces to standard functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4547 edebug-original-eval-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4548 edebug-original-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4549 edebug-get-buffer-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4550 edebug-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4551 edebug-mark-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4552 edebug-input-pending-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4553 edebug-sit-for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4554 edebug-prin1-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4555 edebug-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4556 edebug-original-signal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4557 ;; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4558 zmacs-deactivate-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4559 popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4560 ;; CL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4561 cl-macroexpand-all
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4562 ;; And believe it or not, the byte compiler doesn't know about:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4563 byte-compile-resolve-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4564 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4566 '(byte-compile-resolve-free-references
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4567 '(read-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4568 read-expression-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4570 '(byte-compile-resolve-free-assignments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4571 '(read-expression-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4573 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4575
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4576 ;;; Autoloading of Edebug accessories
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4578 (if (featurep 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4579 (add-hook 'edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4580 (function (lambda () (require 'cl-specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4581 ;; The following causes cl-specs to be loaded if you load cl.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4582 (add-hook 'cl-load-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4583 (function (lambda () (require 'cl-specs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4585 ;;; edebug-cl-read and cl-read are available from liberte@cs.uiuc.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4586 (if (featurep 'cl-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4587 (add-hook 'edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4588 (function (lambda () (require 'edebug-cl-read))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4589 ;; 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
4590 (add-hook 'cl-read-load-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4591 (function (lambda () (require 'edebug-cl-read)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4593
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4594 ;;; Finalize Loading
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4595
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4596 ;;; Finally, hook edebug into the rest of Emacs.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 72
diff changeset
4597 ;;; There are probably some other things that could go here.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4599 ;; Install edebug read and eval functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4600 (edebug-install-read-eval-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4602 (provide 'edebug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4604 ;;; edebug.el ends here