Mercurial > hg > xemacs-beta
comparison lisp/edebug/edebug.el @ 4:b82b59fe008d r19-15b3
Import from CVS: tag r19-15b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:56 +0200 |
parents | 376386a54a3c |
children | 441bb1e64a06 |
comparison
equal
deleted
inserted
replaced
3:30df88044ec6 | 4:b82b59fe008d |
---|---|
2 | 2 |
3 ;; Copyright (C) 1988,'89,'90,'91,'92,'93,'94,'95 Free Software Foundation, Inc | 3 ;; Copyright (C) 1988,'89,'90,'91,'92,'93,'94,'95 Free Software Foundation, Inc |
4 | 4 |
5 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> | 5 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> |
6 ;; Keywords: lisp, tools, maint | 6 ;; Keywords: lisp, tools, maint |
7 | |
8 ;; This file is part of XEmacs. | |
9 | |
10 ;; XEmacs is free software; you can redistribute it and/or modify it | |
11 ;; under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; XEmacs is distributed in the hope that it will be useful, but | |
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 ;; General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
23 ;; 02111-1307, USA. | |
24 | |
25 ;;; Synched up with: Not in FSF | |
26 | |
27 ;;; Commentary: | |
7 | 28 |
8 ;; LCD Archive Entry: | 29 ;; LCD Archive Entry: |
9 ;; edebug|Daniel LaLiberte|liberte@cs.uiuc.edu | 30 ;; edebug|Daniel LaLiberte|liberte@cs.uiuc.edu |
10 ;; |A source level debugger for Emacs Lisp. | 31 ;; |A source level debugger for Emacs Lisp. |
11 ;; |$Date: 1996/12/18 03:33:28 $|$Revision: 1.1.1.1 $|~/modes/edebug.el| | 32 ;; |$Date: 1996/12/18 03:54:30 $|$Revision: 1.1.1.2 $|~/modes/edebug.el| |
12 | 33 |
13 ;; This file is part of GNU Emacs. | 34 ;; This minor mode allows programmers to step through Emacs Lisp |
14 | 35 ;; source code while executing functions. You can also set |
15 ;; GNU Emacs is free software; you can redistribute it and/or modify | 36 ;; breakpoints, trace (stopping at each expression), evaluate |
16 ;; it under the terms of the GNU General Public License as published by | 37 ;; expressions as if outside Edebug, reevaluate and display a list of |
17 ;; the Free Software Foundation; either version 2, or (at your option) | 38 ;; expressions, trap errors normally caught by debug, and display a |
18 ;; any later version. | 39 ;; debug style backtrace. |
19 | 40 |
20 ;; GNU Emacs is distributed in the hope that it will be useful, | 41 ;; Installation |
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 42 ;; ============= |
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 43 |
23 ;; GNU General Public License for more details. | 44 ;; Put edebug.el in some directory in your load-path and |
24 | 45 ;; byte-compile it. Also read the beginning of edebug-epoch.el, |
25 ;; You should have received a copy of the GNU General Public License | 46 ;; cl-specs.el, and edebug-cl-read.el if they apply to you. |
26 ;; along with GNU Emacs; see the file COPYING. If not, write to | 47 |
27 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 48 ;; Unless you are using Emacs 19 which is already set up to use Edebug, |
28 | 49 ;; put the following forms in your .emacs file. |
29 ;;;; Commentary: | 50 ;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form) |
30 | 51 ;; (autoload 'edebug-eval-top-level-form "edebug") |
31 ;;; This minor mode allows programmers to step through Emacs Lisp | 52 |
32 ;;; source code while executing functions. You can also set | 53 ;; If you wish to change the default edebug global command prefix, change: |
33 ;;; breakpoints, trace (stopping at each expression), evaluate | 54 ;; (setq edebug-global-prefix "\C-xX") |
34 ;;; expressions as if outside Edebug, reevaluate and display a list of | 55 |
35 ;;; expressions, trap errors normally caught by debug, and display a | 56 ;; Other options, are described in the manual. |
36 ;;; debug style backtrace. | 57 |
37 | 58 ;; In previous versions of Edebug, users were directed to set |
38 ;;;; Installation | 59 ;; `debugger' to `edebug-debug'. This is no longer necessary |
39 ;;; ============= | 60 ;; since Edebug automatically sets it whenever Edebug is active. |
40 | 61 |
41 ;;; Put edebug.el in some directory in your load-path and | 62 ;; Minimal Instructions |
42 ;;; byte-compile it. Also read the beginning of edebug-epoch.el, | 63 ;; ===================== |
43 ;;; cl-specs.el, and edebug-cl-read.el if they apply to you. | 64 |
44 | 65 ;; First evaluate a defun with C-xx, then run the function. Step |
45 ;;; Unless you are using Emacs 19 which is already set up to use Edebug, | 66 ;; through the code with SPC, mark breakpoints with b, go until a |
46 ;;; put the following forms in your .emacs file. | 67 ;; breakpoint is reached with g, and quit execution with q. Use the |
47 ;;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form) | 68 ;; "?" command in edebug to describe other commands. See edebug.tex |
48 ;;; (autoload 'edebug-eval-top-level-form "edebug") | 69 ;; or the Emacs 19 Lisp Reference Manual for more instructions. |
49 | 70 |
50 ;;; If you wish to change the default edebug global command prefix, change: | 71 ;; Send me your enhancements, ideas, bugs, or fixes. |
51 ;;; (setq edebug-global-prefix "\C-xX") | 72 ;; For bugs, you can call edebug-submit-bug-report if you have reporter.el. |
52 | 73 ;; There is an edebug mailing list if you want to keep up |
53 ;;; Other options, are described in the manual. | 74 ;; with the latest developments. Requests to: edebug-request@cs.uiuc.edu |
54 | 75 |
55 ;;; In previous versions of Edebug, users were directed to set | 76 ;; Daniel LaLiberte 217-398-4114 |
56 ;;; `debugger' to `edebug-debug'. This is no longer necessary | 77 ;; University of Illinois, Urbana-Champaign |
57 ;;; since Edebug automatically sets it whenever Edebug is active. | 78 ;; Department of Computer Science |
58 | 79 ;; 1304 W Springfield |
59 ;;;; Minimal Instructions | 80 ;; Urbana, IL 61801 |
60 ;;; ===================== | 81 |
61 | 82 ;; uiucdcs!liberte |
62 ;;; First evaluate a defun with C-xx, then run the function. Step | 83 ;; liberte@cs.uiuc.edu |
63 ;;; through the code with SPC, mark breakpoints with b, go until a | 84 |
64 ;;; breakpoint is reached with g, and quit execution with q. Use the | 85 ;; =============================== |
65 ;;; "?" command in edebug to describe other commands. See edebug.tex | 86 ;; For the early revision history, see edebug-history. |
66 ;;; or the Emacs 19 Lisp Reference Manual for more instructions. | 87 |
67 | 88 ;;; Code: |
68 ;;; Send me your enhancements, ideas, bugs, or fixes. | |
69 ;;; For bugs, you can call edebug-submit-bug-report if you have reporter.el. | |
70 ;;; There is an edebug mailing list if you want to keep up | |
71 ;;; with the latest developments. Requests to: edebug-request@cs.uiuc.edu | |
72 | |
73 ;;; Daniel LaLiberte 217-398-4114 | |
74 ;;; University of Illinois, Urbana-Champaign | |
75 ;;; Department of Computer Science | |
76 ;;; 1304 W Springfield | |
77 ;;; Urbana, IL 61801 | |
78 | |
79 ;;; uiucdcs!liberte | |
80 ;;; liberte@cs.uiuc.edu | |
81 | |
82 ;;; =============================== | |
83 ;;; For the early revision history, see edebug-history. | |
84 | 89 |
85 (defconst edebug-version | 90 (defconst edebug-version |
86 (let ((raw-version "$Revision: 1.1.1.1 $")) | 91 (let ((raw-version "$Revision: 1.1.1.2 $")) |
87 (substring raw-version (string-match "[0-9.]*" raw-version) | 92 (substring raw-version (string-match "[0-9.]*" raw-version) |
88 (match-end 0)))) | 93 (match-end 0)))) |
89 | 94 |
90 (require 'backquote) | 95 (require 'backquote) |
91 | 96 |
92 ;; Emacs 18 doesnt have defalias. | 97 ;; Emacs 18 doesnt have defalias. |
93 (eval-and-compile | 98 (eval-and-compile |
94 (or (fboundp 'defalias) (fset 'defalias 'fset))) | 99 (or (fboundp 'defalias) (fset 'defalias 'fset))) |
95 | 100 |
96 | 101 |
97 ;;;; Bug reporting | 102 ;; Bug reporting |
98 ;;; ============== | 103 ;; ============== |
99 | 104 |
100 (defconst edebug-maintainer-address "liberte@cs.uiuc.edu") | 105 (defconst edebug-maintainer-address "liberte@cs.uiuc.edu") |
101 | 106 |
102 (defun edebug-submit-bug-report () | 107 (defun edebug-submit-bug-report () |
103 "Submit, via mail, a bug report on edebug." | 108 "Submit, via mail, a bug report on edebug." |
122 'edebug-print-level | 127 'edebug-print-level |
123 'edebug-print-circle | 128 'edebug-print-circle |
124 )))) | 129 )))) |
125 | 130 |
126 | 131 |
127 ;;;; Options | 132 ;; Options |
128 ;;; =============================== | 133 ;; =============================== |
129 | 134 |
130 (defvar edebug-setup-hook nil | 135 (defvar edebug-setup-hook nil |
131 "*Functions to call before edebug is used. | 136 "*Functions to call before edebug is used. |
132 Each time it is set to a new value, Edebug will call those functions | 137 Each time it is set to a new value, Edebug will call those functions |
133 once and then `edebug-setup-hook' is reset to nil. You could use this | 138 once and then `edebug-setup-hook' is reset to nil. You could use this |
246 (defvar edebug-global-break-condition nil | 251 (defvar edebug-global-break-condition nil |
247 "*If non-nil, an expression to test for at every stop point. | 252 "*If non-nil, an expression to test for at every stop point. |
248 If the result is non-nil, then break. Errors are ignored.") | 253 If the result is non-nil, then break. Errors are ignored.") |
249 | 254 |
250 | 255 |
251 ;;;; Form spec utilities. | 256 ;; Form spec utilities. |
252 ;;; =============================== | 257 ;; =============================== |
253 | 258 |
254 ;;;###autoload | 259 ;;;###autoload |
255 (defmacro def-edebug-spec (symbol spec) | 260 (defmacro def-edebug-spec (symbol spec) |
256 "Set the edebug-form-spec property of SYMBOL according to SPEC. | 261 "Set the edebug-form-spec property of SYMBOL according to SPEC. |
257 Both SYMBOL and SPEC are unevaluated. The SPEC can be 0, t, a symbol | 262 Both SYMBOL and SPEC are unevaluated. The SPEC can be 0, t, a symbol |
273 (setq edebug-form-spec indirect)) | 278 (setq edebug-form-spec indirect)) |
274 edebug-form-spec | 279 edebug-form-spec |
275 )) | 280 )) |
276 | 281 |
277 | 282 |
278 ;;;; Utilities | 283 ;; Utilities |
279 ;;; =============================== | 284 ;; =============================== |
280 | 285 |
281 ;; Define edebug-gensym - from old cl.el | 286 ;; Define edebug-gensym - from old cl.el |
282 (defvar edebug-gensym-index 0 | 287 (defvar edebug-gensym-index 0 |
283 "Integer used by `edebug-gensym' to produce new names.") | 288 "Integer used by `edebug-gensym' to produce new names.") |
284 | 289 |
365 | 370 |
366 (defun edebug-functionp (object) | 371 (defun edebug-functionp (object) |
367 "Returns the function named by OBJECT, or nil if it is not a function." | 372 "Returns the function named by OBJECT, or nil if it is not a function." |
368 (setq object (edebug-lookup-function object)) | 373 (setq object (edebug-lookup-function object)) |
369 (if (or (subrp object) | 374 (if (or (subrp object) |
370 (byte-code-function-p object) | 375 (compiled-function-p object) |
371 (and (listp object) | 376 (and (listp object) |
372 (eq (car object) 'lambda) | 377 (eq (car object) 'lambda) |
373 (listp (car (cdr object))))) | 378 (listp (car (cdr object))))) |
374 object)) | 379 object)) |
375 | 380 |
396 (progn (,@ body)) | 401 (progn (,@ body)) |
397 (save-excursion | 402 (save-excursion |
398 (set-buffer (marker-buffer edebug:s-r-beg)) | 403 (set-buffer (marker-buffer edebug:s-r-beg)) |
399 (narrow-to-region edebug:s-r-beg edebug:s-r-end)))))) | 404 (narrow-to-region edebug:s-r-beg edebug:s-r-end)))))) |
400 | 405 |
401 ;;;; Display | 406 ;; Display |
402 ;;; ============ | 407 ;; ============ |
403 | 408 |
404 (defconst edebug-trace-buffer "*edebug-trace*" | 409 (defconst edebug-trace-buffer "*edebug-trace*" |
405 "Name of the buffer to put trace info in.") | 410 "Name of the buffer to put trace info in.") |
406 | 411 |
407 (defun edebug-pop-to-buffer (buffer &optional window) | 412 (defun edebug-pop-to-buffer (buffer &optional window) |
491 (defalias 'edebug-get-buffer-window 'get-buffer-window) | 496 (defalias 'edebug-get-buffer-window 'get-buffer-window) |
492 (defalias 'edebug-sit-for 'sit-for) | 497 (defalias 'edebug-sit-for 'sit-for) |
493 (defalias 'edebug-input-pending-p 'input-pending-p) | 498 (defalias 'edebug-input-pending-p 'input-pending-p) |
494 | 499 |
495 | 500 |
496 ;;;; Redefine read and eval functions | 501 ;; Redefine read and eval functions |
497 ;;; ================================= | 502 ;; ================================= |
498 ;;; read is redefined to maybe instrument forms. | 503 ;; read is redefined to maybe instrument forms. |
499 ;;; eval-defun is redefined to check edebug-all-forms and edebug-all-defs. | 504 ;; eval-defun is redefined to check edebug-all-forms and edebug-all-defs. |
500 | 505 |
501 ;;; Use the Lisp version of eval-region. | 506 ;; Use the Lisp version of eval-region. |
502 (require 'eval-reg "eval-reg") | 507 (require 'eval-reg "eval-reg") |
503 | 508 |
504 ;; Save the original read function | 509 ;; Save the original read function |
505 (or (fboundp 'edebug-original-read) | 510 (or (fboundp 'edebug-original-read) |
506 (defalias 'edebug-original-read (symbol-function 'read))) | 511 (defalias 'edebug-original-read (symbol-function 'read))) |
609 (elisp-eval-region-uninstall) | 614 (elisp-eval-region-uninstall) |
610 (defalias 'read (symbol-function 'edebug-original-read)) | 615 (defalias 'read (symbol-function 'edebug-original-read)) |
611 (defalias 'eval-defun (symbol-function 'edebug-original-eval-defun))) | 616 (defalias 'eval-defun (symbol-function 'edebug-original-eval-defun))) |
612 | 617 |
613 | 618 |
614 ;;;; Edebug internal data | 619 ;; Edebug internal data |
615 ;;; =============================== | 620 ;; =============================== |
616 | 621 |
617 ;;; The internal data that is needed for edebugging is kept in the | 622 ;; The internal data that is needed for edebugging is kept in the |
618 ;;; buffer-local variable `edebug-form-data'. | 623 ;; buffer-local variable `edebug-form-data'. |
619 | 624 |
620 ;; XEmacs change? | 625 ;; XEmacs change? |
621 (defconst edebug-form-data nil) | 626 (defconst edebug-form-data nil) |
622 (make-variable-buffer-local 'edebug-form-data) | 627 (make-variable-buffer-local 'edebug-form-data) |
623 | 628 |
696 ;; (set-marker (nth 1 entry) nil) | 701 ;; (set-marker (nth 1 entry) nil) |
697 ;; (set-marker (nth 2 entry) nil) | 702 ;; (set-marker (nth 2 entry) nil) |
698 (setq edebug-form-data (delq entry edebug-form-data))))) | 703 (setq edebug-form-data (delq entry edebug-form-data))))) |
699 | 704 |
700 | 705 |
701 ;;;; Parser utilities | 706 ;; Parser utilities |
702 ;;; =============================== | 707 ;; =============================== |
703 | 708 |
704 | 709 |
705 (defun edebug-syntax-error (&rest args) | 710 (defun edebug-syntax-error (&rest args) |
706 ;; Signal an invalid-read-syntax with ARGS. | 711 ;; Signal an invalid-read-syntax with ARGS. |
707 (signal 'invalid-read-syntax args)) | 712 (signal 'invalid-read-syntax args)) |
769 (list 'quote (edebug-read-sexp))) | 774 (list 'quote (edebug-read-sexp))) |
770 (t ; anything else, just read it. | 775 (t ; anything else, just read it. |
771 (edebug-original-read (current-buffer)))))) | 776 (edebug-original-read (current-buffer)))))) |
772 | 777 |
773 | 778 |
774 ;;;; Offsets for reader | 779 ;; Offsets for reader |
775 ;;; ============================== | 780 ;; ============================== |
776 | 781 |
777 ;; Define a structure to represent offset positions of expressions. | 782 ;; Define a structure to represent offset positions of expressions. |
778 ;; Each offset structure looks like: (before . after) for constituents, | 783 ;; Each offset structure looks like: (before . after) for constituents, |
779 ;; or for structures that have elements: (before <subexpressions> . after) | 784 ;; or for structures that have elements: (before <subexpressions> . after) |
780 ;; where the <subexpressions> are the offset structures for subexpressions | 785 ;; where the <subexpressions> are the offset structures for subexpressions |
845 (edebug-store-before-offset (, point)) | 850 (edebug-store-before-offset (, point)) |
846 (,@ body)) | 851 (,@ body)) |
847 (edebug-store-after-offset (point))))) | 852 (edebug-store-after-offset (point))))) |
848 | 853 |
849 | 854 |
850 ;;;; Reader for Emacs Lisp. | 855 ;; Reader for Emacs Lisp. |
851 ;;; ========================================== | 856 ;; ========================================== |
852 ;; Uses edebug-next-token-class (and edebug-skip-whitespace) above. | 857 ;; Uses edebug-next-token-class (and edebug-skip-whitespace) above. |
853 | 858 |
854 (defconst edebug-read-alist | 859 (defconst edebug-read-alist |
855 '((symbol . edebug-read-symbol) | 860 '((symbol . edebug-read-symbol) |
856 (lparen . edebug-read-list) | 861 (lparen . edebug-read-list) |
932 (forward-char 1) ; skip \] | 937 (forward-char 1) ; skip \] |
933 )) | 938 )) |
934 | 939 |
935 | 940 |
936 | 941 |
937 ;;;; Cursors for traversal of list and vector elements with offsets. | 942 ;; Cursors for traversal of list and vector elements with offsets. |
938 ;;;==================================================================== | 943 ;;==================================================================== |
939 | 944 |
940 (defvar edebug-dotted-spec nil) | 945 (defvar edebug-dotted-spec nil) |
941 | 946 |
942 (defun edebug-new-cursor (expressions offsets) | 947 (defun edebug-new-cursor (expressions offsets) |
943 ;; Return a new cursor for EXPRESSIONS with OFFSETS. | 948 ;; Return a new cursor for EXPRESSIONS with OFFSETS. |
1010 (let ((offset (edebug-top-offset cursor))) | 1015 (let ((offset (edebug-top-offset cursor))) |
1011 (while (consp offset) | 1016 (while (consp offset) |
1012 (setq offset (cdr offset))) | 1017 (setq offset (cdr offset))) |
1013 offset)) | 1018 offset)) |
1014 | 1019 |
1015 ;;;; The Parser | 1020 ;; The Parser |
1016 ;;; =============================== | 1021 ;; =============================== |
1017 | 1022 |
1018 ;;; The top level function for parsing forms is | 1023 ;; The top level function for parsing forms is |
1019 ;;; edebug-read-and-maybe-wrap-form; it calls all the rest. It checks the | 1024 ;; edebug-read-and-maybe-wrap-form; it calls all the rest. It checks the |
1020 ;;; syntax a bit and leaves point at any error it finds, but otherwise | 1025 ;; syntax a bit and leaves point at any error it finds, but otherwise |
1021 ;;; should appear to work like eval-defun. | 1026 ;; should appear to work like eval-defun. |
1022 | 1027 |
1023 ;;; The basic plan is to surround each expression with a call to | 1028 ;; The basic plan is to surround each expression with a call to |
1024 ;;; the edebug debugger together with indexes into a table of positions of | 1029 ;; the edebug debugger together with indexes into a table of positions of |
1025 ;;; all expressions. Thus an expression "exp" becomes: | 1030 ;; all expressions. Thus an expression "exp" becomes: |
1026 | 1031 |
1027 ;;; (edebug-after (edebug-before 1) 2 exp) | 1032 ;; (edebug-after (edebug-before 1) 2 exp) |
1028 | 1033 |
1029 ;;; When this is evaluated, first point is moved to the beginning of | 1034 ;; When this is evaluated, first point is moved to the beginning of |
1030 ;;; exp at offset 1 of the current function. The expression is | 1035 ;; exp at offset 1 of the current function. The expression is |
1031 ;;; evaluated, which may cause more edebug calls, and then point is | 1036 ;; evaluated, which may cause more edebug calls, and then point is |
1032 ;;; moved to offset 2 after the end of exp. | 1037 ;; moved to offset 2 after the end of exp. |
1033 | 1038 |
1034 ;;; The highest level expressions of the function are wrapped in a call to | 1039 ;; The highest level expressions of the function are wrapped in a call to |
1035 ;;; edebug-enter, which supplies the function name and the actual | 1040 ;; edebug-enter, which supplies the function name and the actual |
1036 ;;; arguments to the function. See functions edebug-enter, edebug-before, | 1041 ;; arguments to the function. See functions edebug-enter, edebug-before, |
1037 ;;; and edebug-after for more details. | 1042 ;; and edebug-after for more details. |
1038 | 1043 |
1039 ;; Dynamically bound vars, left unbound, but globally declared. | 1044 ;; Dynamically bound vars, left unbound, but globally declared. |
1040 ;; This is to quiet the byte compiler. | 1045 ;; This is to quiet the byte compiler. |
1041 | 1046 |
1042 ;; Window data of the highest definition being wrapped. | 1047 ;; Window data of the highest definition being wrapped. |
1106 ;; This is incorrect in general!! But OK most of the time. | 1111 ;; This is incorrect in general!! But OK most of the time. |
1107 def-name (if (and defining-form-p | 1112 def-name (if (and defining-form-p |
1108 (eq 'name (car (cdr spec))) | 1113 (eq 'name (car (cdr spec))) |
1109 (eq 'symbol (edebug-next-token-class))) | 1114 (eq 'symbol (edebug-next-token-class))) |
1110 (edebug-original-read (current-buffer)))))) | 1115 (edebug-original-read (current-buffer)))))) |
1111 ;;;(message "all defs: %s all forms: %s" edebug-all-defs edebug-all-forms) | 1116 ;;(message "all defs: %s all forms: %s" edebug-all-defs edebug-all-forms) |
1112 (cond | 1117 (cond |
1113 (defining-form-p | 1118 (defining-form-p |
1114 (if (or edebug-all-defs edebug-all-forms) | 1119 (if (or edebug-all-defs edebug-all-forms) |
1115 ;; If it is a defining form and we are edebugging defs, | 1120 ;; If it is a defining form and we are edebugging defs, |
1116 ;; then let edebug-list-form start it. | 1121 ;; then let edebug-list-form start it. |
1489 (t (edebug-syntax-error | 1494 (t (edebug-syntax-error |
1490 "Head of list form must be a symbol or lambda expression."))) | 1495 "Head of list form must be a symbol or lambda expression."))) |
1491 )) | 1496 )) |
1492 | 1497 |
1493 | 1498 |
1494 ;;;; Matching of specs. | 1499 ;; Matching of specs. |
1495 ;;; =================== | 1500 ;; =================== |
1496 | 1501 |
1497 (defvar edebug-after-dotted-spec nil) | 1502 (defvar edebug-after-dotted-spec nil) |
1498 | 1503 |
1499 (defvar edebug-matching-depth 0) ;; initial value | 1504 (defvar edebug-matching-depth 0) ;; initial value |
1500 (defconst edebug-max-depth 150) ;; maximum number of matching recursions. | 1505 (defconst edebug-max-depth 150) ;; maximum number of matching recursions. |
1501 | 1506 |
1502 | 1507 |
1503 ;;;; Failure to match | 1508 ;; Failure to match |
1504 ;;; ================== | 1509 ;; ================== |
1505 ;; This throws to no-match, if there are higher alternatives. | 1510 ;; This throws to no-match, if there are higher alternatives. |
1506 ;; Otherwise it signals an error. The place of the error is found | 1511 ;; Otherwise it signals an error. The place of the error is found |
1507 ;; with the two before- and after-offset functions. | 1512 ;; with the two before- and after-offset functions. |
1508 | 1513 |
1509 (defun edebug-no-match (cursor &rest edebug-args) | 1514 (defun edebug-no-match (cursor &rest edebug-args) |
1925 ;; Not to be used otherwise. | 1930 ;; Not to be used otherwise. |
1926 (let ((edebug-inside-func t)) | 1931 (let ((edebug-inside-func t)) |
1927 (list (edebug-wrap-def-body (edebug-forms cursor))))) | 1932 (list (edebug-wrap-def-body (edebug-forms cursor))))) |
1928 | 1933 |
1929 | 1934 |
1930 ;;;; Edebug Form Specs | 1935 ;; Edebug Form Specs |
1931 ;;; ========================================================== | 1936 ;; ========================================================== |
1932 ;;; See cl-specs.el for common lisp specs. | 1937 ;; See cl-specs.el for common lisp specs. |
1933 | 1938 |
1934 ;;;;* Spec for def-edebug-spec | 1939 ;;* Spec for def-edebug-spec |
1935 ;;; Out of date. | 1940 ;; Out of date. |
1936 | 1941 |
1937 (defun edebug-spec-p (object) | 1942 (defun edebug-spec-p (object) |
1938 "Return non-nil if OBJECT is a symbol with an edebug-form-spec property." | 1943 "Return non-nil if OBJECT is a symbol with an edebug-form-spec property." |
1939 (and (symbolp object) | 1944 (and (symbolp object) |
1940 (get object 'edebug-form-spec))) | 1945 (get object 'edebug-form-spec))) |
1960 edebug-spec-p ;; Including all the special ones e.g. form. | 1965 edebug-spec-p ;; Including all the special ones e.g. form. |
1961 symbolp;; a predicate | 1966 symbolp;; a predicate |
1962 )) | 1967 )) |
1963 | 1968 |
1964 | 1969 |
1965 ;;;;* Emacs special forms and some functions. | 1970 ;;* Emacs special forms and some functions. |
1966 | 1971 |
1967 ;; quote expects only one argument, although it allows any number. | 1972 ;; quote expects only one argument, although it allows any number. |
1968 (def-edebug-spec quote sexp) | 1973 (def-edebug-spec quote sexp) |
1969 | 1974 |
1970 ;; The standard defining forms. | 1975 ;; The standard defining forms. |
2097 [&optional stringp] | 2102 [&optional stringp] |
2098 [&optional ("interactive" interactive)] | 2103 [&optional ("interactive" interactive)] |
2099 def-body)) | 2104 def-body)) |
2100 | 2105 |
2101 | 2106 |
2102 ;;;; The debugger itself | 2107 ;; The debugger itself |
2103 ;;; =============================== | 2108 ;; =============================== |
2104 | 2109 |
2105 (defvar edebug-active nil) ;; Non-nil when edebug is active | 2110 (defvar edebug-active nil) ;; Non-nil when edebug is active |
2106 | 2111 |
2107 ;;; add minor-mode-alist entry | 2112 ;; add minor-mode-alist entry |
2108 (or (assq 'edebug-active minor-mode-alist) | 2113 (or (assq 'edebug-active minor-mode-alist) |
2109 (setq minor-mode-alist (cons (list 'edebug-active " *Debugging*") | 2114 (setq minor-mode-alist (cons (list 'edebug-active " *Debugging*") |
2110 minor-mode-alist))) | 2115 minor-mode-alist))) |
2111 | 2116 |
2112 (defvar edebug-stack nil) | 2117 (defvar edebug-stack nil) |
2164 (defvar post-command-hook nil) | 2169 (defvar post-command-hook nil) |
2165 (defvar post-command-idle-hook nil) | 2170 (defvar post-command-idle-hook nil) |
2166 | 2171 |
2167 (defvar cl-lexical-debug) ;; Defined in cl.el | 2172 (defvar cl-lexical-debug) ;; Defined in cl.el |
2168 | 2173 |
2169 ;;; Handling signals | 2174 ;; Handling signals |
2170 ;;; ================= | 2175 ;; ================= |
2171 | 2176 |
2172 (if (not (fboundp 'edebug-original-signal)) | 2177 (if (not (fboundp 'edebug-original-signal)) |
2173 (defalias 'edebug-original-signal (symbol-function 'signal))) | 2178 (defalias 'edebug-original-signal (symbol-function 'signal))) |
2174 ;; We should use advise for this!! | 2179 ;; We should use advise for this!! |
2175 | 2180 |
2193 ;; If we reach here without another non-local exit, then send signal again. | 2198 ;; If we reach here without another non-local exit, then send signal again. |
2194 ;; i.e. the signal is not continuable, yet. | 2199 ;; i.e. the signal is not continuable, yet. |
2195 (edebug-original-signal edebug-signal-name edebug-signal-data)) | 2200 (edebug-original-signal edebug-signal-name edebug-signal-data)) |
2196 | 2201 |
2197 | 2202 |
2198 ;;; Entering Edebug | 2203 ;; Entering Edebug |
2199 ;;; ================== | 2204 ;; ================== |
2200 | 2205 |
2201 (defun edebug-enter (edebug-function edebug-args edebug-body) | 2206 (defun edebug-enter (edebug-function edebug-args edebug-body) |
2202 ;; Entering FUNC. The arguments are ARGS, and the body is BODY. | 2207 ;; Entering FUNC. The arguments are ARGS, and the body is BODY. |
2203 ;; Setup edebug variables and evaluate BODY. This function is called | 2208 ;; Setup edebug variables and evaluate BODY. This function is called |
2204 ;; when a function evaluated with edebug-eval-top-level-form is entered. | 2209 ;; when a function evaluated with edebug-eval-top-level-form is entered. |
2225 | 2230 |
2226 ;; Lexical bindings must be uncompiled for this to work. | 2231 ;; Lexical bindings must be uncompiled for this to work. |
2227 (cl-lexical-debug t) | 2232 (cl-lexical-debug t) |
2228 | 2233 |
2229 ;; Save the outside value of executing macro. (here??) | 2234 ;; Save the outside value of executing macro. (here??) |
2230 (edebug-outside-executing-macro executing-macro) | 2235 (edebug-outside-executing-macro executing-kbd-macro) |
2231 (edebug-outside-pre-command-hook pre-command-hook) | 2236 (edebug-outside-pre-command-hook pre-command-hook) |
2232 (edebug-outside-post-command-hook post-command-hook) | 2237 (edebug-outside-post-command-hook post-command-hook) |
2233 (edebug-outside-post-command-idle-hook post-command-idle-hook)) | 2238 (edebug-outside-post-command-idle-hook post-command-idle-hook)) |
2234 (unwind-protect | 2239 (unwind-protect |
2235 (let (;; Don't keep reading from an executing kbd macro | 2240 (let (;; Don't keep reading from an executing kbd macro |
2236 ;; within edebug unless edebug-continue-kbd-macro is | 2241 ;; within edebug unless edebug-continue-kbd-macro is |
2237 ;; non-nil. Again, local binding may not be best. | 2242 ;; non-nil. Again, local binding may not be best. |
2238 (executing-macro | 2243 (executing-kbd-macro |
2239 (if edebug-continue-kbd-macro executing-macro)) | 2244 (if edebug-continue-kbd-macro executing-kbd-macro)) |
2240 | 2245 |
2241 ;; Disable command hooks. This is essential when | 2246 ;; Disable command hooks. This is essential when |
2242 ;; a hook function is instrumented - to avoid infinite loop. | 2247 ;; a hook function is instrumented - to avoid infinite loop. |
2243 ;; This may be more than we need, however. | 2248 ;; This may be more than we need, however. |
2244 (pre-command-hook nil) | 2249 (pre-command-hook nil) |
2252 (fset 'signal 'edebug-signal) | 2257 (fset 'signal 'edebug-signal) |
2253 (unwind-protect | 2258 (unwind-protect |
2254 (edebug-enter edebug-function edebug-args edebug-body) | 2259 (edebug-enter edebug-function edebug-args edebug-body) |
2255 (fset 'signal (symbol-function 'edebug-original-signal)))) | 2260 (fset 'signal (symbol-function 'edebug-original-signal)))) |
2256 ;; Reset global variables in case outside value was changed. | 2261 ;; Reset global variables in case outside value was changed. |
2257 (setq executing-macro edebug-outside-executing-macro | 2262 (setq executing-kbd-macro edebug-outside-executing-macro |
2258 pre-command-hook edebug-outside-pre-command-hook | 2263 pre-command-hook edebug-outside-pre-command-hook |
2259 post-command-hook edebug-outside-post-command-hook | 2264 post-command-hook edebug-outside-post-command-hook |
2260 post-command-idle-hook edebug-outside-post-command-idle-hook | 2265 post-command-idle-hook edebug-outside-post-command-idle-hook |
2261 ))) | 2266 ))) |
2262 | 2267 |
2897 defining-kbd-macro edebug-outside-defining-kbd-macro | 2902 defining-kbd-macro edebug-outside-defining-kbd-macro |
2898 )) | 2903 )) |
2899 )) | 2904 )) |
2900 | 2905 |
2901 | 2906 |
2902 ;;; Display related functions | 2907 ;; Display related functions |
2903 ;;; =============================== | 2908 ;; =============================== |
2904 | 2909 |
2905 (defun edebug-adjust-window (old-start) | 2910 (defun edebug-adjust-window (old-start) |
2906 ;; If pos is not visible, adjust current window to fit following context. | 2911 ;; If pos is not visible, adjust current window to fit following context. |
2907 ;;; (message "window: %s old-start: %s window-start: %s pos: %s" | 2912 ;; (message "window: %s old-start: %s window-start: %s pos: %s" |
2908 ;;; (selected-window) old-start (window-start) (point)) (sit-for 5) | 2913 ;; (selected-window) old-start (window-start) (point)) (sit-for 5) |
2909 (if (not (pos-visible-in-window-p)) | 2914 (if (not (pos-visible-in-window-p)) |
2910 (progn | 2915 (progn |
2911 ;; First try old-start | 2916 ;; First try old-start |
2912 (if old-start | 2917 (if old-start |
2913 (set-window-start (selected-window) old-start)) | 2918 (set-window-start (selected-window) old-start)) |
3072 (cons buffer edebug-display-buffer-list))) | 3077 (cons buffer edebug-display-buffer-list))) |
3073 (message "Displaying %s %s" buffer | 3078 (message "Displaying %s %s" buffer |
3074 (if already-displaying "off" "on")))) | 3079 (if already-displaying "off" "on")))) |
3075 | 3080 |
3076 | 3081 |
3077 ;;; Breakpoint related functions | 3082 ;; Breakpoint related functions |
3078 ;;; =============================== | 3083 ;; =============================== |
3079 | 3084 |
3080 (defun edebug-find-stop-point () | 3085 (defun edebug-find-stop-point () |
3081 ;; Return (function . index) of the nearest edebug stop point. | 3086 ;; Return (function . index) of the nearest edebug stop point. |
3082 (let* ((edebug-def-name (edebug-form-data-symbol)) | 3087 (let* ((edebug-def-name (edebug-form-data-symbol)) |
3083 (edebug-data | 3088 (edebug-data |
3231 "Global Condition: " | 3236 "Global Condition: " |
3232 (format "%s" edebug-global-break-condition)))) | 3237 (format "%s" edebug-global-break-condition)))) |
3233 (setq edebug-global-break-condition expression)) | 3238 (setq edebug-global-break-condition expression)) |
3234 | 3239 |
3235 | 3240 |
3236 ;;; Mode switching functions | 3241 ;; Mode switching functions |
3237 ;;; =============================== | 3242 ;; =============================== |
3238 | 3243 |
3239 (defun edebug-set-mode (mode shortmsg msg) | 3244 (defun edebug-set-mode (mode shortmsg msg) |
3240 ;; Set the edebug mode to MODE. | 3245 ;; Set the edebug mode to MODE. |
3241 ;; Display SHORTMSG, or MSG if not within edebug. | 3246 ;; Display SHORTMSG, or MSG if not within edebug. |
3242 (if (eq (1+ edebug-recursion-depth) (recursion-depth)) | 3247 (if (eq (1+ edebug-recursion-depth) (recursion-depth)) |
3457 ;; "Go until the current function exits." | 3462 ;; "Go until the current function exits." |
3458 ;; (interactive) | 3463 ;; (interactive) |
3459 ;; (edebug-set-mode 'exiting "Exit...")) | 3464 ;; (edebug-set-mode 'exiting "Exit...")) |
3460 | 3465 |
3461 | 3466 |
3462 ;;; ----------------------------------------------------------------- | 3467 ;; ----------------------------------------------------------------- |
3463 ;;; The following initial mode setting definitions are not used yet. | 3468 ;; The following initial mode setting definitions are not used yet. |
3464 | 3469 |
3465 '(defconst edebug-initial-mode-alist | 3470 '(defconst edebug-initial-mode-alist |
3466 '((edebug-Continue-fast . Continue-fast) | 3471 '((edebug-Continue-fast . Continue-fast) |
3467 (edebug-Trace-fast . Trace-fast) | 3472 (edebug-Trace-fast . Trace-fast) |
3468 (edebug-continue . continue) | 3473 (edebug-continue . continue) |
3504 this-function mode)) | 3509 this-function mode)) |
3505 (error "Key must map to one of the mode changing commands") | 3510 (error "Key must map to one of the mode changing commands") |
3506 ))) | 3511 ))) |
3507 | 3512 |
3508 | 3513 |
3509 ;;; Evaluation of expressions | 3514 ;; Evaluation of expressions |
3510 ;;; =============================== | 3515 ;; =============================== |
3511 | 3516 |
3512 (def-edebug-spec edebug-outside-excursion t) | 3517 (def-edebug-spec edebug-outside-excursion t) |
3513 | 3518 |
3514 (defmacro edebug-outside-excursion (&rest body) | 3519 (defmacro edebug-outside-excursion (&rest body) |
3515 "Evaluate an expression list in the outside context. | 3520 "Evaluate an expression list in the outside context. |
3542 (last-nonmenu-event edebug-outside-last-nonmenu-event) | 3547 (last-nonmenu-event edebug-outside-last-nonmenu-event) |
3543 (track-mouse edebug-outside-track-mouse) | 3548 (track-mouse edebug-outside-track-mouse) |
3544 (standard-output edebug-outside-standard-output) | 3549 (standard-output edebug-outside-standard-output) |
3545 (standard-input edebug-outside-standard-input) | 3550 (standard-input edebug-outside-standard-input) |
3546 | 3551 |
3547 (executing-macro edebug-outside-executing-macro) | 3552 (executing-kbd-macro edebug-outside-executing-macro) |
3548 (defining-kbd-macro edebug-outside-defining-kbd-macro) | 3553 (defining-kbd-macro edebug-outside-defining-kbd-macro) |
3549 (pre-command-hook edebug-outside-pre-command-hook) | 3554 (pre-command-hook edebug-outside-pre-command-hook) |
3550 (post-command-hook edebug-outside-post-command-hook) | 3555 (post-command-hook edebug-outside-post-command-hook) |
3551 (post-command-idle-hook edebug-outside-post-command-idle-hook) | 3556 (post-command-idle-hook edebug-outside-post-command-idle-hook) |
3552 | 3557 |
3584 edebug-outside-last-nonmenu-event last-nonmenu-event | 3589 edebug-outside-last-nonmenu-event last-nonmenu-event |
3585 edebug-outside-track-mouse track-mouse | 3590 edebug-outside-track-mouse track-mouse |
3586 edebug-outside-standard-output standard-output | 3591 edebug-outside-standard-output standard-output |
3587 edebug-outside-standard-input standard-input | 3592 edebug-outside-standard-input standard-input |
3588 | 3593 |
3589 edebug-outside-executing-macro executing-macro | 3594 edebug-outside-executing-macro executing-kbd-macro |
3590 edebug-outside-defining-kbd-macro defining-kbd-macro | 3595 edebug-outside-defining-kbd-macro defining-kbd-macro |
3591 edebug-outside-pre-command-hook pre-command-hook | 3596 edebug-outside-pre-command-hook pre-command-hook |
3592 edebug-outside-post-command-hook post-command-hook | 3597 edebug-outside-post-command-hook post-command-hook |
3593 edebug-outside-post-command-idle-hook post-command-idle-hook | 3598 edebug-outside-post-command-idle-hook post-command-idle-hook |
3594 | 3599 |
3613 (edebug-eval edebug-expr) | 3618 (edebug-eval edebug-expr) |
3614 (error (edebug-format "%s: %s" ;; could | 3619 (error (edebug-format "%s: %s" ;; could |
3615 (get (car edebug-err) 'error-message) | 3620 (get (car edebug-err) 'error-message) |
3616 (car (cdr edebug-err)))))) | 3621 (car (cdr edebug-err)))))) |
3617 | 3622 |
3618 ;;;; Printing | 3623 ;; Printing |
3619 ;;; ========= | 3624 ;; ========= |
3620 ;; Replace printing functions. | 3625 ;; Replace printing functions. |
3621 | 3626 |
3622 ;; obsolete names | 3627 ;; obsolete names |
3623 (defalias 'edebug-install-custom-print-funcs 'edebug-install-custom-print) | 3628 (defalias 'edebug-install-custom-print-funcs 'edebug-install-custom-print) |
3624 (defalias 'edebug-reset-print-funcs 'edebug-uninstall-custom-print) | 3629 (defalias 'edebug-reset-print-funcs 'edebug-uninstall-custom-print) |
3696 (defun edebug-previous-result () | 3701 (defun edebug-previous-result () |
3697 "Print the previous result." | 3702 "Print the previous result." |
3698 (interactive) | 3703 (interactive) |
3699 (message "%s" edebug-previous-result)) | 3704 (message "%s" edebug-previous-result)) |
3700 | 3705 |
3701 ;;;; Read, Eval and Print | 3706 ;; Read, Eval and Print |
3702 ;;; ===================== | 3707 ;; ===================== |
3703 | 3708 |
3704 (defun edebug-eval-expression (edebug-expr) | 3709 (defun edebug-eval-expression (edebug-expr) |
3705 "Evaluate an expression in the outside environment. | 3710 "Evaluate an expression in the outside environment. |
3706 If interactive, prompt for the expression. | 3711 If interactive, prompt for the expression. |
3707 Print result in minibuffer." | 3712 Print result in minibuffer." |
3731 (princ edebug-result-string) | 3736 (princ edebug-result-string) |
3732 (princ "\n") | 3737 (princ "\n") |
3733 )) | 3738 )) |
3734 | 3739 |
3735 | 3740 |
3736 ;;;; Edebug Minor Mode | 3741 ;; Edebug Minor Mode |
3737 ;;; =============================== | 3742 ;; =============================== |
3738 | 3743 |
3739 ;; Global GUD bindings for all emacs-lisp-mode buffers. | 3744 ;; Global GUD bindings for all emacs-lisp-mode buffers. |
3740 (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode) | 3745 (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode) |
3741 (define-key emacs-lisp-mode-map "\C-x\C-a\C-n" 'edebug-next-mode) | 3746 (define-key emacs-lisp-mode-map "\C-x\C-a\C-n" 'edebug-next-mode) |
3742 (define-key emacs-lisp-mode-map "\C-x\C-a\C-c" 'edebug-go-mode) | 3747 (define-key emacs-lisp-mode-map "\C-x\C-a\C-c" 'edebug-go-mode) |
3896 edebug-global-break-condition | 3901 edebug-global-break-condition |
3897 " | 3902 " |
3898 (use-local-map edebug-mode-map)) | 3903 (use-local-map edebug-mode-map)) |
3899 | 3904 |
3900 | 3905 |
3901 ;;;; edebug eval list mode | 3906 ;; edebug eval list mode |
3902 ;;; =============================================== | 3907 ;; =============================================== |
3903 ;; A list of expressions and their evaluations is displayed in *edebug*. | 3908 ;; A list of expressions and their evaluations is displayed in *edebug*. |
3904 | 3909 |
3905 (defun edebug-eval-result-list () | 3910 (defun edebug-eval-result-list () |
3906 "Return a list of evaluations of edebug-eval-list" | 3911 "Return a list of evaluations of edebug-eval-list" |
3907 ;; Assumes in outside environment. | 3912 ;; Assumes in outside environment. |
4033 (setq major-mode 'edebug-eval-mode) | 4038 (setq major-mode 'edebug-eval-mode) |
4034 (setq mode-name "Edebug-Eval") | 4039 (setq mode-name "Edebug-Eval") |
4035 (use-local-map edebug-eval-mode-map)) | 4040 (use-local-map edebug-eval-mode-map)) |
4036 | 4041 |
4037 | 4042 |
4038 ;;;; Interface with standard debugger. | 4043 ;; Interface with standard debugger. |
4039 ;;; ======================================== | 4044 ;; ======================================== |
4040 | 4045 |
4041 ;; (setq debugger 'edebug) ; to use the edebug debugger | 4046 ;; (setq debugger 'edebug) ; to use the edebug debugger |
4042 ;; (setq debugger 'debug) ; use the standard debugger | 4047 ;; (setq debugger 'debug) ; use the standard debugger |
4043 | 4048 |
4044 ;; Note that debug and its utilities must be byte-compiled to work, | 4049 ;; Note that debug and its utilities must be byte-compiled to work, |
4113 (delete-region last-ok-point (point)) | 4118 (delete-region last-ok-point (point)) |
4114 ))) | 4119 ))) |
4115 ))))) | 4120 ))))) |
4116 | 4121 |
4117 | 4122 |
4118 ;;;; Trace display | 4123 ;; Trace display |
4119 ;; =============================== | 4124 ;; =============================== |
4120 | 4125 |
4121 (defun edebug-trace-display (buf-name fmt &rest args) | 4126 (defun edebug-trace-display (buf-name fmt &rest args) |
4122 "In buffer BUF-NAME, display FMT and ARGS at the end and make it visible. | 4127 "In buffer BUF-NAME, display FMT and ARGS at the end and make it visible. |
4123 The buffer is created if it does not exist. | 4128 The buffer is created if it does not exist. |
4149 (defun edebug-trace (fmt &rest args) | 4154 (defun edebug-trace (fmt &rest args) |
4150 "Convenience call to edebug-trace-display using edebug-trace-buffer" | 4155 "Convenience call to edebug-trace-display using edebug-trace-buffer" |
4151 (apply 'edebug-trace-display edebug-trace-buffer fmt args)) | 4156 (apply 'edebug-trace-display edebug-trace-buffer fmt args)) |
4152 | 4157 |
4153 | 4158 |
4154 ;;;; Frequency count and coverage | 4159 ;; Frequency count and coverage |
4155 ;;; ============================== | 4160 ;; ============================== |
4156 | 4161 |
4157 (defun edebug-display-freq-count () | 4162 (defun edebug-display-freq-count () |
4158 "Display the frequency count data for each line of the current | 4163 "Display the frequency count data for each line of the current |
4159 definition. The frequency counts are inserted as comment lines after | 4164 definition. The frequency counts are inserted as comment lines after |
4160 each line, and you can undo all insertions with one `undo' command. | 4165 each line, and you can undo all insertions with one `undo' command. |
4233 (edebug-display-freq-count) | 4238 (edebug-display-freq-count) |
4234 (setq unread-command-char (read-char)) | 4239 (setq unread-command-char (read-char)) |
4235 (undo))) | 4240 (undo))) |
4236 | 4241 |
4237 | 4242 |
4238 ;;;; Menus | 4243 ;; Menus |
4239 ;;;========= | 4244 ;;========= |
4240 | 4245 |
4241 (defun edebug-toggle (variable) | 4246 (defun edebug-toggle (variable) |
4242 (set variable (not (eval variable))) | 4247 (set variable (not (eval variable))) |
4243 (message "%s: %s" variable (eval variable))) | 4248 (message "%s: %s" variable (eval variable))) |
4244 | 4249 |
4301 (edebug-toggle 'edebug-save-displayed-buffer-points) t] | 4306 (edebug-toggle 'edebug-save-displayed-buffer-points) t] |
4302 )) | 4307 )) |
4303 "XEmacs style menus for Edebug.") | 4308 "XEmacs style menus for Edebug.") |
4304 | 4309 |
4305 | 4310 |
4306 ;;;; Emacs version specific code | 4311 ;; Emacs version specific code |
4307 ;;;============================= | 4312 ;;============================= |
4308 ;;; The default for all above is Emacs 18, because it is easier to compile | 4313 ;; The default for all above is Emacs 18, because it is easier to compile |
4309 ;;; Emacs 18 code in Emacs 19 than vice versa. This default will | 4314 ;; Emacs 18 code in Emacs 19 than vice versa. This default will |
4310 ;;; change once most people are using Emacs 19 or derivatives. | 4315 ;; change once most people are using Emacs 19 or derivatives. |
4311 | 4316 |
4312 ;; Epoch specific code is in a separate file: edebug-epoch.el. | 4317 ;; Epoch specific code is in a separate file: edebug-epoch.el. |
4313 | 4318 |
4314 ;; The byte-compiler will complain about changes in number of arguments | 4319 ;; The byte-compiler will complain about changes in number of arguments |
4315 ;; to functions like mark and read-from-minibuffer. These warnings | 4320 ;; to functions like mark and read-from-minibuffer. These warnings |
4368 (edebug-outside-excursion | 4373 (edebug-outside-excursion |
4369 (setq values (cons (edebug-eval edebug-expr) values)) | 4374 (setq values (cons (edebug-eval edebug-expr) values)) |
4370 (edebug-safe-prin1-to-string (car values))))) | 4375 (edebug-safe-prin1-to-string (car values))))) |
4371 | 4376 |
4372 (easy-menu-define edebug-menu edebug-mode-map "Edebug menus" edebug-mode-menus) | 4377 (easy-menu-define edebug-menu edebug-mode-map "Edebug menus" edebug-mode-menus) |
4373 (if window-system | 4378 (if (eq (console-type) 'x) |
4374 (x-popup-menu nil (lookup-key edebug-mode-map [menu-bar Edebug]))) | 4379 (x-popup-menu nil (lookup-key edebug-mode-map [menu-bar Edebug]))) |
4375 ) | 4380 ) |
4376 | 4381 |
4377 | 4382 |
4378 (defun edebug-xemacs-specific () | 4383 (defun edebug-xemacs-specific () |
4412 (edebug-emacs-19-specific)))) | 4417 (edebug-emacs-19-specific)))) |
4413 | 4418 |
4414 (edebug-emacs-version-specific) | 4419 (edebug-emacs-version-specific) |
4415 | 4420 |
4416 | 4421 |
4417 ;;;; Byte-compiler | 4422 ;; Byte-compiler |
4418 ;;; ==================== | 4423 ;; ==================== |
4419 ;; Extension for bytecomp to resolve undefined function references. | 4424 ;; Extension for bytecomp to resolve undefined function references. |
4420 ;; Requires new byte compiler. | 4425 ;; Requires new byte compiler. |
4421 | 4426 |
4422 ;; Reenable byte compiler warnings about unread-command-char and -event. | 4427 ;; Reenable byte compiler warnings about unread-command-char and -event. |
4423 ;; Disabled before edebug-recursive-edit. | 4428 ;; Disabled before edebug-recursive-edit. |
4497 '(read-expression-history)) | 4502 '(read-expression-history)) |
4498 | 4503 |
4499 ))) | 4504 ))) |
4500 | 4505 |
4501 | 4506 |
4502 ;;;; Autoloading of Edebug accessories | 4507 ;; Autoloading of Edebug accessories |
4503 ;;;=================================== | 4508 ;;=================================== |
4504 | 4509 |
4505 (if (featurep 'cl) | 4510 (if (featurep 'cl) |
4506 (add-hook 'edebug-setup-hook | 4511 (add-hook 'edebug-setup-hook |
4507 (function (lambda () (require 'cl-specs)))) | 4512 (function (lambda () (require 'cl-specs)))) |
4508 ;; The following causes cl-specs to be loaded if you load cl.el. | 4513 ;; The following causes cl-specs to be loaded if you load cl.el. |
4516 ;; The following causes edebug-cl-read to be loaded when you load cl-read.el. | 4521 ;; The following causes edebug-cl-read to be loaded when you load cl-read.el. |
4517 (add-hook 'cl-read-load-hooks | 4522 (add-hook 'cl-read-load-hooks |
4518 (function (lambda () (require 'edebug-cl-read))))) | 4523 (function (lambda () (require 'edebug-cl-read))))) |
4519 | 4524 |
4520 | 4525 |
4521 ;;;; Finalize Loading | 4526 ;; Finalize Loading |
4522 ;;;=================== | 4527 ;;=================== |
4523 | 4528 |
4524 ;;; Finally, hook edebug into the rest of Emacs. | 4529 ;; Finally, hook edebug into the rest of Emacs. |
4525 ;;; There are probably some other things that could go here. | 4530 ;; There are probably some other things that could go here. |
4526 | 4531 |
4527 ;; Install edebug read and eval functions. | 4532 ;; Install edebug read and eval functions. |
4528 (edebug-install-read-eval-functions) | 4533 (edebug-install-read-eval-functions) |
4529 | 4534 |
4530 (provide 'edebug) | 4535 (provide 'edebug) |
4531 | 4536 |
4532 ;;; edebug.el ends here | 4537 ;;; edebug.el ends here |
4533 | |
4534 |