Mercurial > emacs
annotate lisp/emacs-lisp/debug.el @ 108006:452f0cc5f879
Remove references to (default-)direction-reversed.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Wed, 21 Apr 2010 01:05:30 +0200 |
parents | 1d1d5d9bd884 |
children | c87f89486bb7 376148b31b5e |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
477
diff
changeset
|
1 ;;; debug.el --- debuggers and related commands for Emacs |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
477
diff
changeset
|
2 |
64751
5b1a238fcbb4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64209
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1994, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
845 | 5 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
6 ;; Maintainer: FSF |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
7 ;; Keywords: lisp, tools, maint |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
8 |
473 | 9 ;; This file is part of GNU Emacs. |
10 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94140
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
473 | 12 ;; it under the terms of the GNU General Public License as published by |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94140
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94140
diff
changeset
|
14 ;; (at your option) any later version. |
473 | 15 |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94140
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
473 | 23 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
24 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
25 |
60316
c2f592ab6807
(debug-on-entry-1): Reimplement to make sure that debug-entry-code can
Lute Kamstra <lute@gnu.org>
parents:
60308
diff
changeset
|
26 ;; This is a major mode documented in the Emacs Lisp manual. |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
27 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
28 ;;; Code: |
473 | 29 |
43911 | 30 (require 'button) |
31 | |
21365 | 32 (defgroup debugger nil |
33 "Debuggers and related commands for Emacs." | |
34 :prefix "debugger-" | |
35 :group 'debug) | |
36 | |
37 (defcustom debugger-mode-hook nil | |
104024
cce8d50c4566
Remove leading * from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
38 "Hooks run when `debugger-mode' is turned on." |
21365 | 39 :type 'hook |
21669
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21365
diff
changeset
|
40 :group 'debugger |
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21365
diff
changeset
|
41 :version "20.3") |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
42 |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
43 (defcustom debugger-batch-max-lines 40 |
104024
cce8d50c4566
Remove leading * from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
44 "Maximum lines to show in debugger buffer in a noninteractive Emacs. |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
45 When the debugger is entered and Emacs is running in batch mode, |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
46 if the backtrace text has more than this many lines, |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
47 the middle is discarded, and just the beginning and end are displayed." |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
48 :type 'integer |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
49 :group 'debugger |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
50 :version "21.1") |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
51 |
60374
e68c831d220c
(debugger-step-after-exit): Make it a defvar.
Lute Kamstra <lute@gnu.org>
parents:
60350
diff
changeset
|
52 (defvar debug-function-list nil |
e68c831d220c
(debugger-step-after-exit): Make it a defvar.
Lute Kamstra <lute@gnu.org>
parents:
60350
diff
changeset
|
53 "List of functions currently set for debug on entry.") |
473 | 54 |
60374
e68c831d220c
(debugger-step-after-exit): Make it a defvar.
Lute Kamstra <lute@gnu.org>
parents:
60350
diff
changeset
|
55 (defvar debugger-step-after-exit nil |
e68c831d220c
(debugger-step-after-exit): Make it a defvar.
Lute Kamstra <lute@gnu.org>
parents:
60350
diff
changeset
|
56 "Non-nil means \"single-step\" after the debugger exits.") |
10731
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
57 |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
58 (defvar debugger-value nil |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
59 "This is the value for the debugger to return, when it returns.") |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
60 |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
61 (defvar debugger-old-buffer nil |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
62 "This is the buffer that was current when the debugger was entered.") |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
63 |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
64 (defvar debugger-previous-backtrace nil |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
65 "The contents of the previous backtrace (including text properties). |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
66 This is to optimize `debugger-make-xrefs'.") |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
67 |
6926
027b7de8a571
(debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents:
6567
diff
changeset
|
68 (defvar debugger-outer-match-data) |
11062
302f676eeca0
(debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10731
diff
changeset
|
69 (defvar debugger-outer-load-read-function) |
302f676eeca0
(debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10731
diff
changeset
|
70 (defvar debugger-outer-overriding-local-map) |
18166
84c0a412aa71
(debug, debugger-eval-expression):
Richard M. Stallman <rms@gnu.org>
parents:
17262
diff
changeset
|
71 (defvar debugger-outer-overriding-terminal-local-map) |
5544
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
72 (defvar debugger-outer-track-mouse) |
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
73 (defvar debugger-outer-last-command) |
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
74 (defvar debugger-outer-this-command) |
46722 | 75 ;; unread-command-char is obsolete, |
76 ;; but we still save and restore it | |
77 ;; in case some user program still tries to set it. | |
5544
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
78 (defvar debugger-outer-unread-command-char) |
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
79 (defvar debugger-outer-unread-command-events) |
22921
48b85e4a4dd3
(debugger-outer-unread-post-input-method-events): New variable.
Kenichi Handa <handa@m17n.org>
parents:
22114
diff
changeset
|
80 (defvar debugger-outer-unread-post-input-method-events) |
5544
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
81 (defvar debugger-outer-last-input-event) |
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
82 (defvar debugger-outer-last-command-event) |
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
83 (defvar debugger-outer-last-nonmenu-event) |
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
84 (defvar debugger-outer-last-event-frame) |
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
85 (defvar debugger-outer-standard-input) |
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
86 (defvar debugger-outer-standard-output) |
24741
00ef85c8a0ff
(debugger-outer-inhibit-redisplay): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
24524
diff
changeset
|
87 (defvar debugger-outer-inhibit-redisplay) |
5544
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
88 (defvar debugger-outer-cursor-in-echo-area) |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
89 (defvar debugger-will-be-back nil |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
90 "Non-nil if we expect to get back in the debugger soon.") |
5544
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
91 |
60350
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
92 (defvar inhibit-debug-on-entry nil |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
93 "Non-nil means that debug-on-entry is disabled.") |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
94 |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
95 (defvar debugger-jumping-flag nil |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
96 "Non-nil means that debug-on-entry is disabled. |
60519
2433720b755c
(debugger-step-through): Make sure that stepping into the debugger's
Lute Kamstra <lute@gnu.org>
parents:
60490
diff
changeset
|
97 This variable is used by `debugger-jump', `debugger-step-through', |
2433720b755c
(debugger-step-through): Make sure that stepping into the debugger's
Lute Kamstra <lute@gnu.org>
parents:
60490
diff
changeset
|
98 and `debugger-reenable' to temporarily disable debug-on-entry.") |
60308
9bc793e5120d
(inhibit-debug-on-entry): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60279
diff
changeset
|
99 |
63143
95e4ef649d27
(debug): Don't iconify if we know we'll re-enter the debugger immediately
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63092
diff
changeset
|
100 (defvar inhibit-trace) ;Not yet implemented. |
63058
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
101 |
473 | 102 ;;;###autoload |
103 (setq debugger 'debug) | |
104 ;;;###autoload | |
105 (defun debug (&rest debugger-args) | |
6048
ff40882c5578
(debug, debug-on-entry): Doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5585
diff
changeset
|
106 "Enter debugger. To return, type \\<debugger-mode-map>`\\[debugger-continue]'. |
473 | 107 Arguments are mainly for use when this is called from the internals |
108 of the evaluator. | |
109 | |
110 You may call with no args, or you may pass nil as the first arg and | |
111 any other args you like. In that case, the list of args after the | |
112 first will be printed into the backtrace buffer." | |
11069
ee94cf4fd05a
(debug): Now interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11062
diff
changeset
|
113 (interactive) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
114 (if inhibit-redisplay |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
115 ;; Don't really try to enter debugger within an eval from redisplay. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
116 debugger-value |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
117 (unless noninteractive |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
118 (message "Entering debugger...")) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
119 (let (debugger-value |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
120 (debug-on-error nil) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
121 (debug-on-quit nil) |
104681
91afee51b252
* textmodes/ispell.el (ispell-check-version, ispell-send-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104024
diff
changeset
|
122 (debugger-buffer (get-buffer-create "*Backtrace*")) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
123 (debugger-old-buffer (current-buffer)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
124 (debugger-step-after-exit nil) |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
125 (debugger-will-be-back nil) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
126 ;; Don't keep reading from an executing kbd macro! |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
127 (executing-kbd-macro nil) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
128 ;; Save the outer values of these vars for the `e' command |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
129 ;; before we replace the values. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
130 (debugger-outer-match-data (match-data)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
131 (debugger-outer-load-read-function load-read-function) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
132 (debugger-outer-overriding-local-map overriding-local-map) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
133 (debugger-outer-overriding-terminal-local-map |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
134 overriding-terminal-local-map) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
135 (debugger-outer-track-mouse track-mouse) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
136 (debugger-outer-last-command last-command) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
137 (debugger-outer-this-command this-command) |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
138 (debugger-outer-unread-command-char |
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
139 (with-no-warnings unread-command-char)) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
140 (debugger-outer-unread-command-events unread-command-events) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
141 (debugger-outer-unread-post-input-method-events |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
142 unread-post-input-method-events) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
143 (debugger-outer-last-input-event last-input-event) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
144 (debugger-outer-last-command-event last-command-event) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
145 (debugger-outer-last-nonmenu-event last-nonmenu-event) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
146 (debugger-outer-last-event-frame last-event-frame) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
147 (debugger-outer-standard-input standard-input) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
148 (debugger-outer-standard-output standard-output) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
149 (debugger-outer-inhibit-redisplay inhibit-redisplay) |
64209
193c8e4fb4d1
(debug): Call with-timeout-suspend and with-timeout-unsuspend.
Richard M. Stallman <rms@gnu.org>
parents:
64207
diff
changeset
|
150 (debugger-outer-cursor-in-echo-area cursor-in-echo-area) |
193c8e4fb4d1
(debug): Call with-timeout-suspend and with-timeout-unsuspend.
Richard M. Stallman <rms@gnu.org>
parents:
64207
diff
changeset
|
151 (debugger-with-timeout-suspend (with-timeout-suspend))) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
152 ;; Set this instead of binding it, so that `q' |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
153 ;; will not restore it. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
154 (setq overriding-terminal-local-map nil) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
155 ;; Don't let these magic variables affect the debugger itself. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
156 (let ((last-command nil) this-command track-mouse |
60308
9bc793e5120d
(inhibit-debug-on-entry): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60279
diff
changeset
|
157 (inhibit-trace t) |
9bc793e5120d
(inhibit-debug-on-entry): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60279
diff
changeset
|
158 (inhibit-debug-on-entry t) |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
159 unread-command-events |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
160 unread-post-input-method-events |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
161 last-input-event last-command-event last-nonmenu-event |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
162 last-event-frame |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
163 overriding-local-map |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
164 load-read-function |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
165 ;; If we are inside a minibuffer, allow nesting |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
166 ;; so that we don't get an error from the `e' command. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
167 (enable-recursive-minibuffers |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
168 (or enable-recursive-minibuffers (> (minibuffer-depth) 0))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
169 (standard-input t) (standard-output t) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
170 inhibit-redisplay |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
171 (cursor-in-echo-area nil)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
172 (unwind-protect |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
173 (save-excursion |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
174 (save-window-excursion |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
175 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
176 (setq unread-command-char -1)) |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
177 (when (eq (car debugger-args) 'debug) |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
178 ;; Skip the frames for backtrace-debug, byte-code, |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
179 ;; and implement-debug-on-entry. |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
180 (backtrace-debug 4 t) |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
181 ;; Place an extra debug-on-exit for macro's. |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
182 (when (eq 'lambda (car-safe (cadr (backtrace-frame 4)))) |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
183 (backtrace-debug 5 t))) |
63143
95e4ef649d27
(debug): Don't iconify if we know we'll re-enter the debugger immediately
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63092
diff
changeset
|
184 (pop-to-buffer debugger-buffer) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
185 (debugger-mode) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
186 (debugger-setup-buffer debugger-args) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
187 (when noninteractive |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
188 ;; If the backtrace is long, save the beginning |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
189 ;; and the end, but discard the middle. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
190 (when (> (count-lines (point-min) (point-max)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
191 debugger-batch-max-lines) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
192 (goto-char (point-min)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
193 (forward-line (/ 2 debugger-batch-max-lines)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
194 (let ((middlestart (point))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
195 (goto-char (point-max)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
196 (forward-line (- (/ 2 debugger-batch-max-lines) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
197 debugger-batch-max-lines)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
198 (delete-region middlestart (point))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
199 (insert "...\n")) |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
200 (goto-char (point-min)) |
51588
fc00b549e161
(debug): Fix call to message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
201 (message "%s" (buffer-string)) |
97790
95a7fbb6dd68
(debug): When killing a noninteractive Emacs, give exit status -1.
Chong Yidong <cyd@stupidchicken.com>
parents:
96188
diff
changeset
|
202 (kill-emacs -1)) |
5544
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
203 (message "") |
60308
9bc793e5120d
(inhibit-debug-on-entry): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60279
diff
changeset
|
204 (let ((standard-output nil) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
205 (buffer-read-only t)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
206 (message "") |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
207 ;; Make sure we unbind buffer-read-only in the right buffer. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
208 (save-excursion |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
209 (recursive-edit))))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
210 ;; Kill or at least neuter the backtrace buffer, so that users |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
211 ;; don't try to execute debugger commands in an invalid context. |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
212 (if (get-buffer-window debugger-buffer 0) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
213 ;; Still visible despite the save-window-excursion? Maybe it |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
214 ;; it's in a pop-up frame. It would be annoying to delete and |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
215 ;; recreate it every time the debugger stops, so instead we'll |
63092
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
216 ;; erase it (and maybe hide it) but keep it alive. |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
217 (with-current-buffer debugger-buffer |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
218 (erase-buffer) |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
219 (fundamental-mode) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
220 (with-selected-window (get-buffer-window debugger-buffer 0) |
63143
95e4ef649d27
(debug): Don't iconify if we know we'll re-enter the debugger immediately
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63092
diff
changeset
|
221 (when (and (window-dedicated-p (selected-window)) |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
222 (not debugger-will-be-back)) |
63092
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
223 ;; If the window is not dedicated, burying the buffer |
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
224 ;; will mean that the frame created for it is left |
63143
95e4ef649d27
(debug): Don't iconify if we know we'll re-enter the debugger immediately
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63092
diff
changeset
|
225 ;; around showing some random buffer, and next time we |
63092
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
226 ;; pop to the debugger buffer we'll create yet |
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
227 ;; another frame. |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
228 ;; If debugger-will-be-back is non-nil, the frame |
63143
95e4ef649d27
(debug): Don't iconify if we know we'll re-enter the debugger immediately
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63092
diff
changeset
|
229 ;; would need to be de-iconified anyway immediately |
95e4ef649d27
(debug): Don't iconify if we know we'll re-enter the debugger immediately
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63092
diff
changeset
|
230 ;; after when we re-enter the debugger, so iconifying it |
95e4ef649d27
(debug): Don't iconify if we know we'll re-enter the debugger immediately
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63092
diff
changeset
|
231 ;; here would cause flashing. |
94140
6436fd5155ce
(debug): Revert to bury-buffer since quit-window is not better anyway.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93804
diff
changeset
|
232 ;; Drew Adams is not happy with this: he wants to frame |
6436fd5155ce
(debug): Revert to bury-buffer since quit-window is not better anyway.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93804
diff
changeset
|
233 ;; to be left at the top-level, still working on how |
6436fd5155ce
(debug): Revert to bury-buffer since quit-window is not better anyway.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93804
diff
changeset
|
234 ;; best to do that. |
6436fd5155ce
(debug): Revert to bury-buffer since quit-window is not better anyway.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93804
diff
changeset
|
235 (bury-buffer)))) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
236 (kill-buffer debugger-buffer)) |
64209
193c8e4fb4d1
(debug): Call with-timeout-suspend and with-timeout-unsuspend.
Richard M. Stallman <rms@gnu.org>
parents:
64207
diff
changeset
|
237 (with-timeout-unsuspend debugger-with-timeout-suspend) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
238 (set-match-data debugger-outer-match-data))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
239 ;; Put into effect the modified values of these variables |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
240 ;; in case the user set them with the `e' command. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
241 (setq load-read-function debugger-outer-load-read-function) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
242 (setq overriding-local-map debugger-outer-overriding-local-map) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
243 (setq overriding-terminal-local-map |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
244 debugger-outer-overriding-terminal-local-map) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
245 (setq track-mouse debugger-outer-track-mouse) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
246 (setq last-command debugger-outer-last-command) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
247 (setq this-command debugger-outer-this-command) |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
248 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
249 (setq unread-command-char debugger-outer-unread-command-char)) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
250 (setq unread-command-events debugger-outer-unread-command-events) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
251 (setq unread-post-input-method-events |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
252 debugger-outer-unread-post-input-method-events) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
253 (setq last-input-event debugger-outer-last-input-event) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
254 (setq last-command-event debugger-outer-last-command-event) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
255 (setq last-nonmenu-event debugger-outer-last-nonmenu-event) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
256 (setq last-event-frame debugger-outer-last-event-frame) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
257 (setq standard-input debugger-outer-standard-input) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
258 (setq standard-output debugger-outer-standard-output) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
259 (setq inhibit-redisplay debugger-outer-inhibit-redisplay) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
260 (setq cursor-in-echo-area debugger-outer-cursor-in-echo-area) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
261 (setq debug-on-next-call debugger-step-after-exit) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
262 debugger-value))) |
473 | 263 |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
264 (defun debugger-setup-buffer (debugger-args) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
265 "Initialize the `*Backtrace*' buffer for entry to the debugger. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
266 That buffer should be current already." |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
267 (setq buffer-read-only nil) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
268 (erase-buffer) |
104731
5e848e9d48e2
(debugger-setup-buffer): Make it multibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104681
diff
changeset
|
269 (set-buffer-multibyte t) ;Why was it nil ? -stef |
79032
c7c8f45a4546
(debugger-setup-buffer): Disable undo in *Backtrace*.
Richard M. Stallman <rms@gnu.org>
parents:
78217
diff
changeset
|
270 (setq buffer-undo-list t) |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
271 (let ((standard-output (current-buffer)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
272 (print-escape-newlines t) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
273 (print-level 8) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
274 (print-length 50)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
275 (backtrace)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
276 (goto-char (point-min)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
277 (delete-region (point) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
278 (progn |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
279 (search-forward "\n debug(") |
60329
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
280 (forward-line (if (eq (car debugger-args) 'debug) |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
281 2 ; Remove implement-debug-on-entry frame. |
60329
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
282 1)) |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
283 (point))) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
284 (insert "Debugger entered") |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
285 ;; lambda is for debug-on-call when a function call is next. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
286 ;; debug is for debug-on-entry function called. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
287 (cond ((memq (car debugger-args) '(lambda debug)) |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
288 (insert "--entering a function:\n")) |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
289 ;; Exiting a function. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
290 ((eq (car debugger-args) 'exit) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
291 (insert "--returning value: ") |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
292 (setq debugger-value (nth 1 debugger-args)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
293 (prin1 debugger-value (current-buffer)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
294 (insert ?\n) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
295 (delete-char 1) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
296 (insert ? ) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
297 (beginning-of-line)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
298 ;; Debugger entered for an error. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
299 ((eq (car debugger-args) 'error) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
300 (insert "--Lisp error: ") |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
301 (prin1 (nth 1 debugger-args) (current-buffer)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
302 (insert ?\n)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
303 ;; debug-on-call, when the next thing is an eval. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
304 ((eq (car debugger-args) t) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
305 (insert "--beginning evaluation of function call form:\n")) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
306 ;; User calls debug directly. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
307 (t |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
308 (insert ": ") |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
309 (prin1 (if (eq (car debugger-args) 'nil) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
310 (cdr debugger-args) debugger-args) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
311 (current-buffer)) |
40583
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
312 (insert ?\n))) |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
313 ;; After any frame that uses eval-buffer, |
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
314 ;; insert a line that states the buffer position it's reading at. |
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
315 (save-excursion |
64206
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
316 (let ((tem eval-buffer-list)) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
317 (while (and tem |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
318 (re-search-forward "^ eval-\\(buffer\\|region\\)(" nil t)) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
319 (end-of-line) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
320 (insert (format " ; Reading at buffer position %d" |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
321 ;; This will get the wrong result |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
322 ;; if there are two nested eval-region calls |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
323 ;; for the same buffer. That's not a very useful case. |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
324 (with-current-buffer (car tem) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
325 (point)))) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
326 (pop tem)))) |
40583
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
327 (debugger-make-xrefs)) |
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
328 |
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
329 (defun debugger-make-xrefs (&optional buffer) |
60600
4cc59db6dfeb
(debugger-make-xrefs): Docstring fix. Ignore a `*' at the beginning
Lute Kamstra <lute@gnu.org>
parents:
60587
diff
changeset
|
330 "Attach cross-references to function names in the `*Backtrace*' buffer." |
40583
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
331 (interactive "b") |
105813
df4934f25eef
* textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105372
diff
changeset
|
332 (with-current-buffer (or buffer (current-buffer)) |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
333 (setq buffer (current-buffer)) |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
334 (let ((inhibit-read-only t) |
44517
5496c590d5ad
(debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43911
diff
changeset
|
335 (old-end (point-min)) (new-end (point-min))) |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
336 ;; If we saved an old backtrace, find the common part |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
337 ;; between the new and the old. |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
338 ;; Compare line by line, starting from the end, |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
339 ;; because that's the part that is likely to be unchanged. |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
340 (if debugger-previous-backtrace |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
341 (let (old-start new-start (all-match t)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
342 (goto-char (point-max)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
343 (with-temp-buffer |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
344 (insert debugger-previous-backtrace) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
345 (while (and all-match (not (bobp))) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
346 (setq old-end (point)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
347 (forward-line -1) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
348 (setq old-start (point)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
349 (with-current-buffer buffer |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
350 (setq new-end (point)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
351 (forward-line -1) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
352 (setq new-start (point))) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
353 (if (not (zerop |
66368
db684dc70440
(debugger-make-xrefs): Don't assume case-fold-search is nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65680
diff
changeset
|
354 (let ((case-fold-search nil)) |
db684dc70440
(debugger-make-xrefs): Don't assume case-fold-search is nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65680
diff
changeset
|
355 (compare-buffer-substrings |
db684dc70440
(debugger-make-xrefs): Don't assume case-fold-search is nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65680
diff
changeset
|
356 (current-buffer) old-start old-end |
db684dc70440
(debugger-make-xrefs): Don't assume case-fold-search is nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65680
diff
changeset
|
357 buffer new-start new-end)))) |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
358 (setq all-match nil)))) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
359 ;; Now new-end is the position of the start of the |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
360 ;; unchanged part in the current buffer, and old-end is |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
361 ;; the position of that same text in the saved old |
44517
5496c590d5ad
(debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43911
diff
changeset
|
362 ;; backtrace. But we must subtract (point-min) since strings are |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
363 ;; indexed in origin 0. |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
364 |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
365 ;; Replace the unchanged part of the backtrace |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
366 ;; with the text from debugger-previous-backtrace, |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
367 ;; since that already has the proper xrefs. |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
368 ;; With this optimization, we only need to scan |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
369 ;; the changed part of the backtrace. |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
370 (delete-region new-end (point-max)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
371 (goto-char (point-max)) |
44517
5496c590d5ad
(debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43911
diff
changeset
|
372 (insert (substring debugger-previous-backtrace |
5496c590d5ad
(debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43911
diff
changeset
|
373 (- old-end (point-min)))) |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
374 ;; Make the unchanged part of the backtrace inaccessible |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
375 ;; so it won't be scanned. |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
376 (narrow-to-region (point-min) new-end))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46722
diff
changeset
|
377 |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
378 ;; Scan the new part of the backtrace, inserting xrefs. |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
379 (goto-char (point-min)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
380 (while (progn |
60600
4cc59db6dfeb
(debugger-make-xrefs): Docstring fix. Ignore a `*' at the beginning
Lute Kamstra <lute@gnu.org>
parents:
60587
diff
changeset
|
381 (goto-char (+ (point) 2)) |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
382 (skip-syntax-forward "^w_") |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
383 (not (eobp))) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
384 (let* ((beg (point)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
385 (end (progn (skip-syntax-forward "w_") (point))) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
386 (sym (intern-soft (buffer-substring-no-properties |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
387 beg end))) |
59123
f9293296e0cb
(debugger-make-xrefs): Call symbol-file with `defun'.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
388 (file (and sym (symbol-file sym 'defun)))) |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
389 (when file |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
390 (goto-char beg) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
391 ;; help-xref-button needs to operate on something matched |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
392 ;; by a regexp, so set that up for it. |
60600
4cc59db6dfeb
(debugger-make-xrefs): Docstring fix. Ignore a `*' at the beginning
Lute Kamstra <lute@gnu.org>
parents:
60587
diff
changeset
|
393 (re-search-forward "\\(\\sw\\|\\s_\\)+") |
4cc59db6dfeb
(debugger-make-xrefs): Docstring fix. Ignore a `*' at the beginning
Lute Kamstra <lute@gnu.org>
parents:
60587
diff
changeset
|
394 (help-xref-button 0 'help-function-def sym file))) |
42304
8e051a31d2cd
(debugger-mode-map): Bind C-m, not `RET'.
Richard M. Stallman <rms@gnu.org>
parents:
42078
diff
changeset
|
395 (forward-line 1)) |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
396 (widen)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
397 (setq debugger-previous-backtrace (buffer-string)))) |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
398 |
473 | 399 (defun debugger-step-through () |
400 "Proceed, stepping through subexpressions of this expression. | |
401 Enter another debugger on next entry to eval, apply or funcall." | |
402 (interactive) | |
403 (setq debugger-step-after-exit t) | |
60519
2433720b755c
(debugger-step-through): Make sure that stepping into the debugger's
Lute Kamstra <lute@gnu.org>
parents:
60490
diff
changeset
|
404 (setq debugger-jumping-flag t) |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
405 (setq debugger-will-be-back t) |
60519
2433720b755c
(debugger-step-through): Make sure that stepping into the debugger's
Lute Kamstra <lute@gnu.org>
parents:
60490
diff
changeset
|
406 (add-hook 'post-command-hook 'debugger-reenable) |
473 | 407 (message "Proceeding, will debug on next eval or call.") |
408 (exit-recursive-edit)) | |
409 | |
410 (defun debugger-continue () | |
411 "Continue, evaluating this expression without stopping." | |
412 (interactive) | |
26948
5385b12ef9a8
(debugger-continue): Don't continue If
Gerd Moellmann <gerd@gnu.org>
parents:
26428
diff
changeset
|
413 (unless debugger-may-continue |
5385b12ef9a8
(debugger-continue): Don't continue If
Gerd Moellmann <gerd@gnu.org>
parents:
26428
diff
changeset
|
414 (error "Cannot continue")) |
473 | 415 (message "Continuing.") |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
416 (save-excursion |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
417 ;; Check to see if we've flagged some frame for debug-on-exit, in which |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
418 ;; case we'll probably come back to the debugger soon. |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
419 (goto-char (point-min)) |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
420 (if (re-search-forward "^\\* " nil t) |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
421 (setq debugger-will-be-back t))) |
473 | 422 (exit-recursive-edit)) |
423 | |
424 (defun debugger-return-value (val) | |
425 "Continue, specifying value to return. | |
426 This is only useful when the value returned from the debugger | |
427 will be used, such as in a debug on exit from a frame." | |
428 (interactive "XReturn value (evaluated): ") | |
429 (setq debugger-value val) | |
430 (princ "Returning " t) | |
431 (prin1 debugger-value) | |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
432 (save-excursion |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
433 ;; Check to see if we've flagged some frame for debug-on-exit, in which |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
434 ;; case we'll probably come back to the debugger soon. |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
435 (goto-char (point-min)) |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
436 (if (re-search-forward "^\\* " nil t) |
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
437 (setq debugger-will-be-back t))) |
473 | 438 (exit-recursive-edit)) |
439 | |
440 (defun debugger-jump () | |
441 "Continue to exit from this frame, with all debug-on-entry suspended." | |
442 (interactive) | |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
443 (debugger-frame) |
60350
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
444 (setq debugger-jumping-flag t) |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
445 (add-hook 'post-command-hook 'debugger-reenable) |
473 | 446 (message "Continuing through this frame") |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
447 (setq debugger-will-be-back t) |
473 | 448 (exit-recursive-edit)) |
449 | |
450 (defun debugger-reenable () | |
60350
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
451 "Turn all debug-on-entry functions back on. |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
452 This function is put on `post-command-hook' by `debugger-jump' and |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
453 removes itself from that hook." |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
454 (setq debugger-jumping-flag nil) |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
455 (remove-hook 'post-command-hook 'debugger-reenable)) |
473 | 456 |
457 (defun debugger-frame-number () | |
458 "Return number of frames in backtrace before the one point points at." | |
459 (save-excursion | |
460 (beginning-of-line) | |
461 (let ((opoint (point)) | |
462 (count 0)) | |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
463 (while (not (eq (cadr (backtrace-frame count)) 'debug)) |
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
464 (setq count (1+ count))) |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
465 ;; Skip implement-debug-on-entry frame. |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
466 (when (eq 'implement-debug-on-entry (cadr (backtrace-frame (1+ count)))) |
60329
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
467 (setq count (1+ count))) |
473 | 468 (goto-char (point-min)) |
60329
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
469 (when (looking-at "Debugger entered--\\(Lisp error\\|returning value\\):") |
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
470 (goto-char (match-end 0)) |
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
471 (forward-sexp 1)) |
473 | 472 (forward-line 1) |
473 (while (progn | |
474 (forward-char 2) | |
475 (if (= (following-char) ?\() | |
476 (forward-sexp 1) | |
477 (forward-sexp 2)) | |
478 (forward-line 1) | |
479 (<= (point) opoint)) | |
43033
9af85e74c287
(debugger-setup-buffer): When an eval-buffer frame was reading from a buffer,
Richard M. Stallman <rms@gnu.org>
parents:
42304
diff
changeset
|
480 (if (looking-at " *;;;") |
9af85e74c287
(debugger-setup-buffer): When an eval-buffer frame was reading from a buffer,
Richard M. Stallman <rms@gnu.org>
parents:
42304
diff
changeset
|
481 (forward-line 1)) |
473 | 482 (setq count (1+ count))) |
483 count))) | |
484 | |
485 (defun debugger-frame () | |
486 "Request entry to debugger when this frame exits. | |
487 Applies to the frame whose line point is on in the backtrace." | |
488 (interactive) | |
43034
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
489 (save-excursion |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
490 (beginning-of-line) |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
491 (if (looking-at " *;;;\\|[a-z]") |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
492 (error "This line is not a function call"))) |
473 | 493 (beginning-of-line) |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
494 (backtrace-debug (debugger-frame-number) t) |
473 | 495 (if (= (following-char) ? ) |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
496 (let ((inhibit-read-only t)) |
473 | 497 (delete-char 1) |
498 (insert ?*))) | |
499 (beginning-of-line)) | |
500 | |
501 (defun debugger-frame-clear () | |
22114
0fbcff056c0f
(debugger-frame-clear): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
502 "Do not enter debugger when this frame exits. |
473 | 503 Applies to the frame whose line point is on in the backtrace." |
504 (interactive) | |
43034
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
505 (save-excursion |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
506 (beginning-of-line) |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
507 (if (looking-at " *;;;\\|[a-z]") |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
508 (error "This line is not a function call"))) |
473 | 509 (beginning-of-line) |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
510 (backtrace-debug (debugger-frame-number) nil) |
473 | 511 (if (= (following-char) ?*) |
63157
4a4691a3100d
(debugger-will-be-back): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63143
diff
changeset
|
512 (let ((inhibit-read-only t)) |
473 | 513 (delete-char 1) |
514 (insert ? ))) | |
515 (beginning-of-line)) | |
516 | |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
517 (put 'debugger-env-macro 'lisp-indent-function 0) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
518 (defmacro debugger-env-macro (&rest body) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
519 "Run BODY in original environment." |
26428
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
520 `(save-excursion |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
521 (if (null (buffer-name debugger-old-buffer)) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
522 ;; old buffer deleted |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
523 (setq debugger-old-buffer (current-buffer))) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
524 (set-buffer debugger-old-buffer) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
525 (let ((load-read-function debugger-outer-load-read-function) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
526 (overriding-terminal-local-map |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
527 debugger-outer-overriding-terminal-local-map) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
528 (overriding-local-map debugger-outer-overriding-local-map) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
529 (track-mouse debugger-outer-track-mouse) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
530 (last-command debugger-outer-last-command) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
531 (this-command debugger-outer-this-command) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
532 (unread-command-events debugger-outer-unread-command-events) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
533 (unread-post-input-method-events |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
534 debugger-outer-unread-post-input-method-events) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
535 (last-input-event debugger-outer-last-input-event) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
536 (last-command-event debugger-outer-last-command-event) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
537 (last-nonmenu-event debugger-outer-last-nonmenu-event) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
538 (last-event-frame debugger-outer-last-event-frame) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
539 (standard-input debugger-outer-standard-input) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
540 (standard-output debugger-outer-standard-output) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
541 (inhibit-redisplay debugger-outer-inhibit-redisplay) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
542 (cursor-in-echo-area debugger-outer-cursor-in-echo-area)) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
543 (set-match-data debugger-outer-match-data) |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
544 (prog1 |
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
545 (let ((save-ucc (with-no-warnings unread-command-char))) |
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
546 (unwind-protect |
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
547 (progn |
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
548 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
549 (setq unread-command-char debugger-outer-unread-command-char)) |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
550 (prog1 (progn ,@body) |
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
551 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
552 (setq debugger-outer-unread-command-char unread-command-char)))) |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
553 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
554 (setq unread-command-char save-ucc)))) |
26428
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
555 (setq debugger-outer-match-data (match-data)) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
556 (setq debugger-outer-load-read-function load-read-function) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
557 (setq debugger-outer-overriding-terminal-local-map |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
558 overriding-terminal-local-map) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
559 (setq debugger-outer-overriding-local-map overriding-local-map) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
560 (setq debugger-outer-track-mouse track-mouse) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
561 (setq debugger-outer-last-command last-command) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
562 (setq debugger-outer-this-command this-command) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
563 (setq debugger-outer-unread-command-events unread-command-events) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
564 (setq debugger-outer-unread-post-input-method-events |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
565 unread-post-input-method-events) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
566 (setq debugger-outer-last-input-event last-input-event) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
567 (setq debugger-outer-last-command-event last-command-event) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
568 (setq debugger-outer-last-nonmenu-event last-nonmenu-event) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
569 (setq debugger-outer-last-event-frame last-event-frame) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
570 (setq debugger-outer-standard-input standard-input) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
571 (setq debugger-outer-standard-output standard-output) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
572 (setq debugger-outer-inhibit-redisplay inhibit-redisplay) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
573 (setq debugger-outer-cursor-in-echo-area cursor-in-echo-area) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
574 )))) |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
575 |
473 | 576 (defun debugger-eval-expression (exp) |
6468
b0c731997544
(debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents:
6048
diff
changeset
|
577 "Eval an expression, in an environment like that outside the debugger." |
b0c731997544
(debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents:
6048
diff
changeset
|
578 (interactive |
b0c731997544
(debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents:
6048
diff
changeset
|
579 (list (read-from-minibuffer "Eval: " |
b0c731997544
(debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents:
6048
diff
changeset
|
580 nil read-expression-map t |
b0c731997544
(debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents:
6048
diff
changeset
|
581 'read-expression-history))) |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
582 (debugger-env-macro (eval-expression exp))) |
473 | 583 |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
584 (defvar debugger-mode-map |
93535
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
585 (let ((map (make-keymap)) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
586 (menu-map (make-sparse-keymap))) |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
587 (set-keymap-parent map button-buffer-map) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
588 (suppress-keymap map) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
589 (define-key map "-" 'negative-argument) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
590 (define-key map "b" 'debugger-frame) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
591 (define-key map "c" 'debugger-continue) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
592 (define-key map "j" 'debugger-jump) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
593 (define-key map "r" 'debugger-return-value) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
594 (define-key map "u" 'debugger-frame-clear) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
595 (define-key map "d" 'debugger-step-through) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
596 (define-key map "l" 'debugger-list-functions) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
597 (define-key map "h" 'describe-mode) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
598 (define-key map "q" 'top-level) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
599 (define-key map "e" 'debugger-eval-expression) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
600 (define-key map " " 'next-line) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
601 (define-key map "R" 'debugger-record-expression) |
64206
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
602 (define-key map "\C-m" 'debug-help-follow) |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
603 (define-key map [mouse-2] 'push-button) |
93535
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
604 (define-key map [menu-bar debugger] (cons "Debugger" menu-map)) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
605 (define-key menu-map [deb-top] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
606 '(menu-item "Quit" top-level |
93804
0b281e7eac04
*** empty log message ***
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93535
diff
changeset
|
607 :help "Quit debugging and return to top level")) |
93535
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
608 (define-key menu-map [deb-s0] '("--")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
609 (define-key menu-map [deb-descr] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
610 '(menu-item "Describe Debugger Mode" describe-mode |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
611 :help "Display documentation for debugger-mode")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
612 (define-key menu-map [deb-hfol] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
613 '(menu-item "Help Follow" debug-help-follow |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
614 :help "Follow cross-reference")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
615 (define-key menu-map [deb-nxt] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
616 '(menu-item "Next Line" next-line |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
617 :help "Move cursor down")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
618 (define-key menu-map [deb-s1] '("--")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
619 (define-key menu-map [deb-lfunc] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
620 '(menu-item "List debug on entry functions" debugger-list-functions |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
621 :help "Display a list of all the functions now set to debug on entry")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
622 (define-key menu-map [deb-fclear] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
623 '(menu-item "Cancel debug frame" debugger-frame-clear |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
624 :help "Do not enter debugger when this frame exits")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
625 (define-key menu-map [deb-frame] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
626 '(menu-item "Debug frame" debugger-frame |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
627 :help "Request entry to debugger when this frame exits")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
628 (define-key menu-map [deb-s2] '("--")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
629 (define-key menu-map [deb-ret] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
630 '(menu-item "Return value..." debugger-return-value |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
631 :help "Continue, specifying value to return.")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
632 (define-key menu-map [deb-rec] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
633 '(menu-item "Display and Record Expression" debugger-record-expression |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
634 :help "Display a variable's value and record it in `*Backtrace-record*' buffer")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
635 (define-key menu-map [deb-eval] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
636 '(menu-item "Eval Expression..." debugger-eval-expression |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
637 :help "Eval an expression, in an environment like that outside the debugger")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
638 (define-key menu-map [deb-jump] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
639 '(menu-item "Jump" debugger-jump |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
640 :help "Continue to exit from this frame, with all debug-on-entry suspended")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
641 (define-key menu-map [deb-cont] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
642 '(menu-item "Continue" debugger-continue |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
643 :help "Continue, evaluating this expression without stopping")) |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
644 (define-key menu-map [deb-step] |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
645 '(menu-item "Step through" debugger-step-through |
a128a4284881
* emacs-lisp/debug.el (debugger-mode-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79704
diff
changeset
|
646 :help "Proceed, stepping through subexpressions of this expression")) |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
647 map)) |
64207
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
648 |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
649 (put 'debugger-mode 'mode-class 'special) |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
650 |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
651 (defun debugger-mode () |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
652 "Mode for backtrace buffers, selected in debugger. |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
653 \\<debugger-mode-map> |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
654 A line starts with `*' if exiting that frame will call the debugger. |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
655 Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'. |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
656 |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
657 When in debugger due to frame being exited, |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
658 use the \\[debugger-return-value] command to override the value |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
659 being returned from that frame. |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
660 |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
661 Use \\[debug-on-entry] and \\[cancel-debug-on-entry] to control |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
662 which functions will enter the debugger when called. |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
663 |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
664 Complete list of commands: |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
665 \\{debugger-mode-map}" |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
666 (kill-all-local-variables) |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
667 (setq major-mode 'debugger-mode) |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
668 (setq mode-name "Debugger") |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
669 (setq truncate-lines t) |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
670 (set-syntax-table emacs-lisp-mode-syntax-table) |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
671 (use-local-map debugger-mode-map) |
c08c2bf5cec8
Move debugger-mode to a more natural place.
Richard M. Stallman <rms@gnu.org>
parents:
64206
diff
changeset
|
672 (run-mode-hooks 'debugger-mode-hook)) |
64206
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
673 |
21365 | 674 (defcustom debugger-record-buffer "*Debugger-record*" |
104024
cce8d50c4566
Remove leading * from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
675 "Buffer name for expression values, for \\[debugger-record-expression]." |
21365 | 676 :type 'string |
21669
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21365
diff
changeset
|
677 :group 'debugger |
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21365
diff
changeset
|
678 :version "20.3") |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
679 |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
680 (defun debugger-record-expression (exp) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
681 "Display a variable's value and record it in `*Backtrace-record*' buffer." |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
682 (interactive |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
683 (list (read-from-minibuffer |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
684 "Record Eval: " |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
685 nil |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
686 read-expression-map t |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
687 'read-expression-history))) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
688 (let* ((buffer (get-buffer-create debugger-record-buffer)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
689 (standard-output buffer)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
690 (princ (format "Debugger Eval (%s): " exp)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
691 (princ (debugger-eval-expression exp)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
692 (terpri)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
693 |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
694 (with-current-buffer (get-buffer debugger-record-buffer) |
63330
e51dacaad0d0
(debug-on-entry, cancel-debug-on-entry): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
63157
diff
changeset
|
695 (message "%s" |
60972
d874c232323c
(debugger-record-expression): Add a missing format to `message'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60600
diff
changeset
|
696 (buffer-substring (line-beginning-position 0) |
d874c232323c
(debugger-record-expression): Add a missing format to `message'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60600
diff
changeset
|
697 (line-end-position 0))))) |
473 | 698 |
96188
147544bdb96f
(help-xref-interned): Declare.
Glenn Morris <rgm@gnu.org>
parents:
94655
diff
changeset
|
699 (declare-function help-xref-interned "help-mode" (symbol)) |
147544bdb96f
(help-xref-interned): Declare.
Glenn Morris <rgm@gnu.org>
parents:
94655
diff
changeset
|
700 |
64206
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
701 (defun debug-help-follow (&optional pos) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
702 "Follow cross-reference at POS, defaulting to point. |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
703 |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
704 For the cross-reference format, see `help-make-xrefs'." |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
705 (interactive "d") |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
706 (require 'help-mode) |
69592
0d9d539167cf
(debug-help-follow): Revert last change.
Luc Teirlinck <teirllm@auburn.edu>
parents:
69586
diff
changeset
|
707 ;; Ideally we'd just do (call-interactively 'help-follow) except that this |
0d9d539167cf
(debug-help-follow): Revert last change.
Luc Teirlinck <teirllm@auburn.edu>
parents:
69586
diff
changeset
|
708 ;; assumes we're already in a *Help* buffer and reuses it, so it ends up |
0d9d539167cf
(debug-help-follow): Revert last change.
Luc Teirlinck <teirllm@auburn.edu>
parents:
69586
diff
changeset
|
709 ;; incorrectly "reusing" the *Backtrace* buffer to show the help info. |
64206
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
710 (unless pos |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
711 (setq pos (point))) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
712 (unless (push-button pos) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
713 ;; check if the symbol under point is a function or variable |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
714 (let ((sym |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
715 (intern |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
716 (save-excursion |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
717 (goto-char pos) (skip-syntax-backward "w_") |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
718 (buffer-substring (point) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
719 (progn (skip-syntax-forward "w_") |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
720 (point))))))) |
4900890ed6a6
(debug-help-follow): New function.
Richard M. Stallman <rms@gnu.org>
parents:
64189
diff
changeset
|
721 (when (or (boundp sym) (fboundp sym) (facep sym)) |
66368
db684dc70440
(debugger-make-xrefs): Don't assume case-fold-search is nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65680
diff
changeset
|
722 (help-xref-interned sym))))) |
473 | 723 |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
724 ;; When you change this, you may also need to change the number of |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
725 ;; frames that the debugger skips. |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
726 (defun implement-debug-on-entry () |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
727 "Conditionally call the debugger. |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
728 A call to this function is inserted by `debug-on-entry' to cause |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
729 functions to break on entry." |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
730 (if (or inhibit-debug-on-entry debugger-jumping-flag) |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
731 nil |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
732 (funcall debugger 'debug))) |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
733 |
63686
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
734 (defun debugger-special-form-p (symbol) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
735 "Return whether SYMBOL is a special form." |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
736 (and (fboundp symbol) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
737 (subrp (symbol-function symbol)) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
738 (eq (cdr (subr-arity (symbol-function symbol))) 'unevalled))) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
739 |
473 | 740 ;;;###autoload |
741 (defun debug-on-entry (function) | |
742 "Request FUNCTION to invoke debugger each time it is called. | |
63408
feca8cc40862
(debug-on-entry): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
63390
diff
changeset
|
743 |
63330
e51dacaad0d0
(debug-on-entry, cancel-debug-on-entry): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
63157
diff
changeset
|
744 When called interactively, prompt for FUNCTION in the minibuffer. |
63408
feca8cc40862
(debug-on-entry): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
63390
diff
changeset
|
745 |
feca8cc40862
(debug-on-entry): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
63390
diff
changeset
|
746 This works by modifying the definition of FUNCTION. If you tell the |
feca8cc40862
(debug-on-entry): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
63390
diff
changeset
|
747 debugger to continue, FUNCTION's execution proceeds. If FUNCTION is a |
feca8cc40862
(debug-on-entry): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
63390
diff
changeset
|
748 normal function or a macro written in Lisp, you can also step through |
feca8cc40862
(debug-on-entry): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
63390
diff
changeset
|
749 its execution. FUNCTION can also be a primitive that is not a special |
feca8cc40862
(debug-on-entry): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
63390
diff
changeset
|
750 form, in which case stepping is not possible. Break-on-entry for |
feca8cc40862
(debug-on-entry): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
63390
diff
changeset
|
751 primitive functions only works when that function is called from Lisp. |
feca8cc40862
(debug-on-entry): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
63390
diff
changeset
|
752 |
473 | 753 Use \\[cancel-debug-on-entry] to cancel the effect of this command. |
6048
ff40882c5578
(debug, debug-on-entry): Doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5585
diff
changeset
|
754 Redefining FUNCTION also cancels it." |
63686
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
755 (interactive |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
756 (let ((fn (function-called-at-point)) val) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
757 (when (debugger-special-form-p fn) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
758 (setq fn nil)) |
64751
5b1a238fcbb4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64209
diff
changeset
|
759 (setq val (completing-read |
63686
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
760 (if fn |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
761 (format "Debug on entry to function (default %s): " fn) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
762 "Debug on entry to function: ") |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
763 obarray |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
764 #'(lambda (symbol) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
765 (and (fboundp symbol) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
766 (not (debugger-special-form-p symbol)))) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
767 t nil nil (symbol-name fn))) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
768 (list (if (equal val "") fn (intern val))))) |
9f00cb6e413e
(debugger-special-form-p): New defun.
Lute Kamstra <lute@gnu.org>
parents:
63408
diff
changeset
|
769 (when (debugger-special-form-p function) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
770 (error "Function %s is a special form" function)) |
63330
e51dacaad0d0
(debug-on-entry, cancel-debug-on-entry): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
63157
diff
changeset
|
771 (if (or (symbolp (symbol-function function)) |
46217
4a0f567d3c5f
(debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45906
diff
changeset
|
772 (subrp (symbol-function function))) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
773 ;; The function is built-in or aliased to another function. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
774 ;; Create a wrapper in which we can add the debug call. |
20404
7cce7f974c78
(debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents:
20403
diff
changeset
|
775 (fset function `(lambda (&rest debug-on-entry-args) |
46217
4a0f567d3c5f
(debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45906
diff
changeset
|
776 ,(interactive-form (symbol-function function)) |
63330
e51dacaad0d0
(debug-on-entry, cancel-debug-on-entry): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
63157
diff
changeset
|
777 (apply ',(symbol-function function) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
778 debug-on-entry-args))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
779 (when (eq (car-safe (symbol-function function)) 'autoload) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
780 ;; The function is autoloaded. Load its real definition. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
781 (load (cadr (symbol-function function)) nil noninteractive nil t)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
782 (when (or (not (consp (symbol-function function))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
783 (and (eq (car (symbol-function function)) 'macro) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
784 (not (consp (cdr (symbol-function function)))))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
785 ;; The function is byte-compiled. Create a wrapper in which |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
786 ;; we can add the debug call. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
787 (debug-convert-byte-code function))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
788 (unless (consp (symbol-function function)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
789 (error "Definition of %s is not a list" function)) |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
790 (fset function (debug-on-entry-1 function t)) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
791 (unless (memq function debug-function-list) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
792 (push function debug-function-list)) |
473 | 793 function) |
794 | |
795 ;;;###autoload | |
796 (defun cancel-debug-on-entry (&optional function) | |
797 "Undo effect of \\[debug-on-entry] on FUNCTION. | |
63363
8420228eae66
(cancel-debug-on-entry): Make the empty string argument obsolete.
Lute Kamstra <lute@gnu.org>
parents:
63330
diff
changeset
|
798 If FUNCTION is nil, cancel debug-on-entry for all functions. |
63330
e51dacaad0d0
(debug-on-entry, cancel-debug-on-entry): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
63157
diff
changeset
|
799 When called interactively, prompt for FUNCTION in the minibuffer. |
e51dacaad0d0
(debug-on-entry, cancel-debug-on-entry): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
63157
diff
changeset
|
800 To specify a nil argument interactively, exit with an empty minibuffer." |
477 | 801 (interactive |
802 (list (let ((name | |
63390
cb9b98ba1f83
(cancel-debug-on-entry): Mention default in minibuffer prompt.
Luc Teirlinck <teirllm@auburn.edu>
parents:
63363
diff
changeset
|
803 (completing-read |
65680
ed770a0a7846
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
804 "Cancel debug on entry to function (default all functions): " |
63390
cb9b98ba1f83
(cancel-debug-on-entry): Mention default in minibuffer prompt.
Luc Teirlinck <teirllm@auburn.edu>
parents:
63363
diff
changeset
|
805 (mapcar 'symbol-name debug-function-list) nil t))) |
63363
8420228eae66
(cancel-debug-on-entry): Make the empty string argument obsolete.
Lute Kamstra <lute@gnu.org>
parents:
63330
diff
changeset
|
806 (when name |
8420228eae66
(cancel-debug-on-entry): Make the empty string argument obsolete.
Lute Kamstra <lute@gnu.org>
parents:
63330
diff
changeset
|
807 (unless (string= name "") |
8420228eae66
(cancel-debug-on-entry): Make the empty string argument obsolete.
Lute Kamstra <lute@gnu.org>
parents:
63330
diff
changeset
|
808 (intern name)))))) |
8420228eae66
(cancel-debug-on-entry): Make the empty string argument obsolete.
Lute Kamstra <lute@gnu.org>
parents:
63330
diff
changeset
|
809 (if (and function |
8420228eae66
(cancel-debug-on-entry): Make the empty string argument obsolete.
Lute Kamstra <lute@gnu.org>
parents:
63330
diff
changeset
|
810 (not (string= function ""))) ; Pre 22.1 compatibility test. |
473 | 811 (progn |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
812 (let ((defn (debug-on-entry-1 function nil))) |
46217
4a0f567d3c5f
(debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45906
diff
changeset
|
813 (condition-case nil |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
814 (when (and (equal (nth 1 defn) '(&rest debug-on-entry-args)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
815 (eq (car (nth 3 defn)) 'apply)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
816 ;; `defn' is a wrapper introduced in debug-on-entry. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
817 ;; Get rid of it since we don't need it any more. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
818 (setq defn (nth 1 (nth 1 (nth 3 defn))))) |
46217
4a0f567d3c5f
(debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45906
diff
changeset
|
819 (error nil)) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
820 (fset function defn)) |
473 | 821 (setq debug-function-list (delq function debug-function-list)) |
822 function) | |
823 (message "Cancelling debug-on-entry for all functions") | |
824 (mapcar 'cancel-debug-on-entry debug-function-list))) | |
825 | |
826 (defun debug-convert-byte-code (function) | |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
827 (let* ((defn (symbol-function function)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
828 (macro (eq (car-safe defn) 'macro))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
829 (when macro (setq defn (cdr defn))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
830 (unless (consp defn) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
831 ;; Assume a compiled code object. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
832 (let* ((contents (append defn nil)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
833 (body |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
834 (list (list 'byte-code (nth 1 contents) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
835 (nth 2 contents) (nth 3 contents))))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
836 (if (nthcdr 5 contents) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
837 (setq body (cons (list 'interactive (nth 5 contents)) body))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
838 (if (nth 4 contents) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
839 ;; Use `documentation' here, to get the actual string, |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
840 ;; in case the compiled function has a reference |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
841 ;; to the .elc file. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
842 (setq body (cons (documentation function) body))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
843 (setq defn (cons 'lambda (cons (car contents) body)))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
844 (when macro (setq defn (cons 'macro defn))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
845 (fset function defn)))) |
473 | 846 |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
847 (defun debug-on-entry-1 (function flag) |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
848 (let* ((defn (symbol-function function)) |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
849 (tail defn)) |
63330
e51dacaad0d0
(debug-on-entry, cancel-debug-on-entry): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
63157
diff
changeset
|
850 (when (eq (car-safe tail) 'macro) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
851 (setq tail (cdr tail))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
852 (if (not (eq (car-safe tail) 'lambda)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
853 ;; Only signal an error when we try to set debug-on-entry. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
854 ;; When we try to clear debug-on-entry, we are now done. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
855 (when flag |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
856 (error "%s is not a user-defined Lisp function" function)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
857 (setq tail (cdr tail)) |
60490
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
858 ;; Skip the docstring. |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
859 (when (and (stringp (cadr tail)) (cddr tail)) |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
860 (setq tail (cdr tail))) |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
861 ;; Skip the interactive form. |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
862 (when (eq 'interactive (car-safe (cadr tail))) |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
863 (setq tail (cdr tail))) |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
864 (unless (eq flag (equal (cadr tail) '(implement-debug-on-entry))) |
60490
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
865 ;; Add/remove debug statement as needed. |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
866 (if flag |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
867 (setcdr tail (cons '(implement-debug-on-entry) (cdr tail))) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
868 (setcdr tail (cddr tail))))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
869 defn)) |
473 | 870 |
871 (defun debugger-list-functions () | |
872 "Display a list of all the functions now set to debug on entry." | |
873 (interactive) | |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
874 (require 'help-mode) |
105372
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
104731
diff
changeset
|
875 (help-setup-xref '(debugger-list-functions) |
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
104731
diff
changeset
|
876 (called-interactively-p 'interactive)) |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
877 (with-output-to-temp-buffer (help-buffer) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
878 (with-current-buffer standard-output |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
879 (if (null debug-function-list) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
880 (princ "No debug-on-entry functions now\n") |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
881 (princ "Functions set to debug on entry:\n\n") |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
882 (dolist (fun debug-function-list) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
883 (make-text-button (point) (progn (prin1 fun) (point)) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
884 'type 'help-function |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
885 'help-args (list fun)) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
886 (terpri)) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
887 (terpri) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
888 (princ "Note: if you have redefined a function, then it may no longer\n") |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
889 (princ "be set to debug on entry, even if it is in the list."))))) |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
477
diff
changeset
|
890 |
18383 | 891 (provide 'debug) |
892 | |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
893 ;; arch-tag: b6ec7047-f801-4103-9c63-d69322db9d3b |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
477
diff
changeset
|
894 ;;; debug.el ends here |