Mercurial > hg > xemacs-beta
comparison lisp/edebug/edebug.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
| author | cvs |
|---|---|
| date | Mon, 13 Aug 2007 09:02:59 +0200 |
| parents | 56c54cf7c5b6 |
| children | b9518feda344 |
comparison
equal
deleted
inserted
replaced
| 69:804d1389bcd6 | 70:131b0175ea99 |
|---|---|
| 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: FSF 19.34. | |
| 26 | |
| 27 ;;; Commentary: | |
| 28 | 7 |
| 29 ;; LCD Archive Entry: | 8 ;; LCD Archive Entry: |
| 30 ;; edebug|Daniel LaLiberte|liberte@cs.uiuc.edu | 9 ;; edebug|Daniel LaLiberte|liberte@cs.uiuc.edu |
| 31 ;; |A source level debugger for Emacs Lisp. | 10 ;; |A source level debugger for Emacs Lisp. |
| 32 ;; |$Date: 1997/08/21 06:23:41 $|$Revision: 1.3 $|~/modes/edebug.el| | 11 ;; |$Date: 1996/12/18 22:43:07 $|$Revision: 1.1.1.1 $|~/modes/edebug.el| |
| 33 | 12 |
| 34 ;; This minor mode allows programmers to step through Emacs Lisp | 13 ;; This file is part of GNU Emacs. |
| 35 ;; source code while executing functions. You can also set | 14 |
| 36 ;; breakpoints, trace (stopping at each expression), evaluate | 15 ;; GNU Emacs is free software; you can redistribute it and/or modify |
| 37 ;; expressions as if outside Edebug, reevaluate and display a list of | 16 ;; it under the terms of the GNU General Public License as published by |
| 38 ;; expressions, trap errors normally caught by debug, and display a | 17 ;; the Free Software Foundation; either version 2, or (at your option) |
| 39 ;; debug style backtrace. | 18 ;; any later version. |
| 40 | 19 |
| 41 ;;; Installation | 20 ;; GNU Emacs is distributed in the hope that it will be useful, |
| 42 ;; ============= | 21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 43 | 22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 44 ;; Put edebug.el in some directory in your load-path and | 23 ;; GNU General Public License for more details. |
| 45 ;; byte-compile it. Also read the beginning of edebug-epoch.el, | 24 |
| 46 ;; cl-specs.el, and edebug-cl-read.el if they apply to you. | 25 ;; You should have received a copy of the GNU General Public License |
| 47 | 26 ;; along with GNU Emacs; see the file COPYING. If not, write to |
| 48 ;; Unless you are using Emacs 19 which is already set up to use Edebug, | 27 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 49 ;; put the following forms in your .emacs file. | 28 |
| 50 ;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form) | 29 ;;;; Commentary: |
| 51 ;; (autoload 'edebug-eval-top-level-form "edebug") | 30 |
| 52 | 31 ;;; This minor mode allows programmers to step through Emacs Lisp |
| 53 ;; If you wish to change the default edebug global command prefix, change: | 32 ;;; source code while executing functions. You can also set |
| 54 ;; (setq edebug-global-prefix "\C-xX") | 33 ;;; breakpoints, trace (stopping at each expression), evaluate |
| 55 | 34 ;;; expressions as if outside Edebug, reevaluate and display a list of |
| 56 ;; Other options, are described in the manual. | 35 ;;; expressions, trap errors normally caught by debug, and display a |
| 57 | 36 ;;; debug style backtrace. |
| 58 ;; In previous versions of Edebug, users were directed to set | 37 |
| 59 ;; `debugger' to `edebug-debug'. This is no longer necessary | 38 ;;;; Installation |
| 60 ;; since Edebug automatically sets it whenever Edebug is active. | 39 ;;; ============= |
| 61 | 40 |
| 62 ;;; Minimal Instructions | 41 ;;; Put edebug.el in some directory in your load-path and |
| 63 ;; ===================== | 42 ;;; byte-compile it. Also read the beginning of edebug-epoch.el, |
| 64 | 43 ;;; cl-specs.el, and edebug-cl-read.el if they apply to you. |
| 65 ;; First evaluate a defun with C-xx, then run the function. Step | 44 |
| 66 ;; through the code with SPC, mark breakpoints with b, go until a | 45 ;;; Unless you are using Emacs 19 which is already set up to use Edebug, |
| 67 ;; breakpoint is reached with g, and quit execution with q. Use the | 46 ;;; put the following forms in your .emacs file. |
| 68 ;; "?" command in edebug to describe other commands. See edebug.tex | 47 ;;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form) |
| 69 ;; or the Emacs 19 Lisp Reference Manual for more instructions. | 48 ;;; (autoload 'edebug-eval-top-level-form "edebug") |
| 70 | 49 |
| 71 ;; Send me your enhancements, ideas, bugs, or fixes. | 50 ;;; If you wish to change the default edebug global command prefix, change: |
| 72 ;; For bugs, you can call edebug-submit-bug-report if you have reporter.el. | 51 ;;; (setq edebug-global-prefix "\C-xX") |
| 73 ;; There is an edebug mailing list if you want to keep up | 52 |
| 74 ;; with the latest developments. Requests to: edebug-request@cs.uiuc.edu | 53 ;;; Other options, are described in the manual. |
| 75 | 54 |
| 76 ;; Daniel LaLiberte 217-398-4114 | 55 ;;; In previous versions of Edebug, users were directed to set |
| 77 ;; University of Illinois, Urbana-Champaign | 56 ;;; `debugger' to `edebug-debug'. This is no longer necessary |
| 78 ;; Department of Computer Science | 57 ;;; since Edebug automatically sets it whenever Edebug is active. |
| 79 ;; 1304 W Springfield | 58 |
| 80 ;; Urbana, IL 61801 | 59 ;;;; Minimal Instructions |
| 81 | 60 ;;; ===================== |
| 82 ;; uiucdcs!liberte | 61 |
| 83 ;; liberte@cs.uiuc.edu | 62 ;;; First evaluate a defun with C-xx, then run the function. Step |
| 84 | 63 ;;; through the code with SPC, mark breakpoints with b, go until a |
| 85 ;; For the early revision history, see edebug-history. | 64 ;;; breakpoint is reached with g, and quit execution with q. Use the |
| 86 | 65 ;;; "?" command in edebug to describe other commands. See edebug.tex |
| 87 ;;; Code: | 66 ;;; or the Emacs 19 Lisp Reference Manual for more instructions. |
| 67 | |
| 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. | |
| 88 | 84 |
| 89 (defconst edebug-version | 85 (defconst edebug-version |
| 90 (let ((raw-version "$Revision: 1.3 $")) | 86 (let ((raw-version "$Revision: 1.1.1.1 $")) |
| 91 (substring raw-version (string-match "[0-9.]*" raw-version) | 87 (substring raw-version (string-match "[0-9.]*" raw-version) |
| 92 (match-end 0)))) | 88 (match-end 0)))) |
| 93 | 89 |
| 94 (require 'backquote) | 90 (require 'backquote) |
| 95 | 91 |
| 96 ;; Emacs 18 doesn't have defalias. | 92 ;; Emacs 18 doesnt have defalias. |
| 97 (eval-and-compile | 93 (eval-and-compile |
| 98 (or (fboundp 'defalias) (fset 'defalias 'fset))) | 94 (or (fboundp 'defalias) (fset 'defalias 'fset))) |
| 99 | 95 |
| 100 | 96 |
| 101 ;;; Bug reporting | 97 ;;;; Bug reporting |
| 98 ;;; ============== | |
| 102 | 99 |
| 103 (defconst edebug-maintainer-address "liberte@cs.uiuc.edu") | 100 (defconst edebug-maintainer-address "liberte@cs.uiuc.edu") |
| 104 | 101 |
| 105 (defun edebug-submit-bug-report () | 102 (defun edebug-submit-bug-report () |
| 106 "Submit, via mail, a bug report on edebug." | 103 "Submit, via mail, a bug report on edebug." |
| 124 'edebug-print-length | 121 'edebug-print-length |
| 125 'edebug-print-level | 122 'edebug-print-level |
| 126 'edebug-print-circle | 123 'edebug-print-circle |
| 127 )))) | 124 )))) |
| 128 | 125 |
| 129 ;;; Options | 126 |
| 127 ;;;; Options | |
| 128 ;;; =============================== | |
| 130 | 129 |
| 131 (defvar edebug-setup-hook nil | 130 (defvar edebug-setup-hook nil |
| 132 "*Functions to call before edebug is used. | 131 "*Functions to call before edebug is used. |
| 133 Each time it is set to a new value, Edebug will call those functions | 132 Each time it is set to a new value, Edebug will call those functions |
| 134 once and then `edebug-setup-hook' is reset to nil. You could use this | 133 once and then `edebug-setup-hook' is reset to nil. You could use this |
| 246 | 245 |
| 247 (defvar edebug-global-break-condition nil | 246 (defvar edebug-global-break-condition nil |
| 248 "*If non-nil, an expression to test for at every stop point. | 247 "*If non-nil, an expression to test for at every stop point. |
| 249 If the result is non-nil, then break. Errors are ignored.") | 248 If the result is non-nil, then break. Errors are ignored.") |
| 250 | 249 |
| 251 ;;; Form spec utilities. | 250 |
| 251 ;;;; Form spec utilities. | |
| 252 ;;; =============================== | |
| 252 | 253 |
| 253 ;;;###autoload | 254 ;;;###autoload |
| 254 (defmacro def-edebug-spec (symbol spec) | 255 (defmacro def-edebug-spec (symbol spec) |
| 255 "Set the edebug-form-spec property of SYMBOL according to SPEC. | 256 "Set the edebug-form-spec property of SYMBOL according to SPEC. |
| 256 Both SYMBOL and SPEC are unevaluated. The SPEC can be 0, t, a symbol | 257 Both SYMBOL and SPEC are unevaluated. The SPEC can be 0, t, a symbol |
| 271 ;; (edebug-trace "indirection: %s" edebug-form-spec) | 272 ;; (edebug-trace "indirection: %s" edebug-form-spec) |
| 272 (setq edebug-form-spec indirect)) | 273 (setq edebug-form-spec indirect)) |
| 273 edebug-form-spec | 274 edebug-form-spec |
| 274 )) | 275 )) |
| 275 | 276 |
| 276 ;;; Utilities | 277 |
| 278 ;;;; Utilities | |
| 279 ;;; =============================== | |
| 277 | 280 |
| 278 ;; Define edebug-gensym - from old cl.el | 281 ;; Define edebug-gensym - from old cl.el |
| 279 (defvar edebug-gensym-index 0 | 282 (defvar edebug-gensym-index 0 |
| 280 "Integer used by `edebug-gensym' to produce new names.") | 283 "Integer used by `edebug-gensym' to produce new names.") |
| 281 | 284 |
| 320 (point)) | 323 (point)) |
| 321 (point))))) | 324 (point))))) |
| 322 | 325 |
| 323 (defun edebug-window-list () | 326 (defun edebug-window-list () |
| 324 "Return a list of windows, in order of `next-window'." | 327 "Return a list of windows, in order of `next-window'." |
| 325 ;; This doesn't work for epoch. | 328 ;; This doesnt work for epoch. |
| 326 (let* ((first-window (selected-window)) | 329 (let* ((first-window (selected-window)) |
| 327 (window-list (list first-window)) | 330 (window-list (list first-window)) |
| 328 (next (next-window first-window))) | 331 (next (next-window first-window))) |
| 329 (while (not (eq next first-window)) | 332 (while (not (eq next first-window)) |
| 330 (setq window-list (cons next window-list)) | 333 (setq window-list (cons next window-list)) |
| 362 | 365 |
| 363 (defun edebug-functionp (object) | 366 (defun edebug-functionp (object) |
| 364 "Returns the function named by OBJECT, or nil if it is not a function." | 367 "Returns the function named by OBJECT, or nil if it is not a function." |
| 365 (setq object (edebug-lookup-function object)) | 368 (setq object (edebug-lookup-function object)) |
| 366 (if (or (subrp object) | 369 (if (or (subrp object) |
| 367 (compiled-function-p object) ; XEmacs | 370 (byte-code-function-p object) |
| 368 (and (listp object) | 371 (and (listp object) |
| 369 (eq (car object) 'lambda) | 372 (eq (car object) 'lambda) |
| 370 (listp (car (cdr object))))) | 373 (listp (car (cdr object))))) |
| 371 object)) | 374 object)) |
| 372 | 375 |
| 393 (progn (,@ body)) | 396 (progn (,@ body)) |
| 394 (save-excursion | 397 (save-excursion |
| 395 (set-buffer (marker-buffer edebug:s-r-beg)) | 398 (set-buffer (marker-buffer edebug:s-r-beg)) |
| 396 (narrow-to-region edebug:s-r-beg edebug:s-r-end)))))) | 399 (narrow-to-region edebug:s-r-beg edebug:s-r-end)))))) |
| 397 | 400 |
| 398 ;;; Display | 401 ;;;; Display |
| 402 ;;; ============ | |
| 399 | 403 |
| 400 (defconst edebug-trace-buffer "*edebug-trace*" | 404 (defconst edebug-trace-buffer "*edebug-trace*" |
| 401 "Name of the buffer to put trace info in.") | 405 "Name of the buffer to put trace info in.") |
| 402 | 406 |
| 403 (defun edebug-pop-to-buffer (buffer &optional window) | 407 (defun edebug-pop-to-buffer (buffer &optional window) |
| 415 (select-window window) | 419 (select-window window) |
| 416 (if (one-window-p) | 420 (if (one-window-p) |
| 417 (split-window)) | 421 (split-window)) |
| 418 ;; (message "next window: %s" (next-window)) (sit-for 1) | 422 ;; (message "next window: %s" (next-window)) (sit-for 1) |
| 419 (if (eq (get-buffer-window edebug-trace-buffer) (next-window)) | 423 (if (eq (get-buffer-window edebug-trace-buffer) (next-window)) |
| 420 ;; Don't select trace window | 424 ;; Dont select trace window |
| 421 nil | 425 nil |
| 422 (select-window (next-window)))) | 426 (select-window (next-window)))) |
| 423 (set-window-buffer (selected-window) buffer) | 427 (set-window-buffer (selected-window) buffer) |
| 424 (set-window-hscroll (selected-window) 0);; should this be?? | 428 (set-window-hscroll (selected-window) 0);; should this be?? |
| 425 ;; Selecting the window does not set the buffer until command loop. | 429 ;; Selecting the window does not set the buffer until command loop. |
| 487 (defalias 'edebug-get-buffer-window 'get-buffer-window) | 491 (defalias 'edebug-get-buffer-window 'get-buffer-window) |
| 488 (defalias 'edebug-sit-for 'sit-for) | 492 (defalias 'edebug-sit-for 'sit-for) |
| 489 (defalias 'edebug-input-pending-p 'input-pending-p) | 493 (defalias 'edebug-input-pending-p 'input-pending-p) |
| 490 | 494 |
| 491 | 495 |
| 492 ;;; Redefine read and eval functions | 496 ;;;; Redefine read and eval functions |
| 493 ;; read is redefined to maybe instrument forms. | 497 ;;; ================================= |
| 494 ;; eval-defun is redefined to check edebug-all-forms and edebug-all-defs. | 498 ;;; read is redefined to maybe instrument forms. |
| 495 | 499 ;;; eval-defun is redefined to check edebug-all-forms and edebug-all-defs. |
| 496 ;; Use the Lisp version of eval-region. | 500 |
| 501 ;;; Use the Lisp version of eval-region. | |
| 497 (require 'eval-reg "eval-reg") | 502 (require 'eval-reg "eval-reg") |
| 498 | 503 |
| 499 ;; Save the original read function | 504 ;; Save the original read function |
| 500 (or (fboundp 'edebug-original-read) | 505 (or (fboundp 'edebug-original-read) |
| 501 (defalias 'edebug-original-read (symbol-function 'read))) | 506 (defalias 'edebug-original-read (symbol-function 'read))) |
| 510 call it with a char as argument to push a char back) | 515 call it with a char as argument to push a char back) |
| 511 a string (takes text from string, starting at the beginning) | 516 a string (takes text from string, starting at the beginning) |
| 512 t (read text line using minibuffer and use it). | 517 t (read text line using minibuffer and use it). |
| 513 | 518 |
| 514 This version, from Edebug, maybe instruments the expression. But the | 519 This version, from Edebug, maybe instruments the expression. But the |
| 515 STREAM must be the current buffer to do so. Whether it instruments is | 520 STREAM must be the current buffer to do so. Whether it instuments is |
| 516 also dependent on the values of `edebug-all-defs' and | 521 also dependent on the values of `edebug-all-defs' and |
| 517 `edebug-all-forms'." | 522 `edebug-all-forms'." |
| 518 (or stream (setq stream standard-input)) | 523 (or stream (setq stream standard-input)) |
| 519 (if (eq stream (current-buffer)) | 524 (if (eq stream (current-buffer)) |
| 520 (edebug-read-and-maybe-wrap-form) | 525 (edebug-read-and-maybe-wrap-form) |
| 521 (edebug-original-read stream))) | 526 (edebug-original-read stream))) |
| 522 | 527 |
| 523 (or (fboundp 'edebug-original-eval-defun) | 528 (or (fboundp 'edebug-original-eval-defun) |
| 524 (defalias 'edebug-original-eval-defun (symbol-function 'eval-defun))) | 529 (defalias 'edebug-original-eval-defun (symbol-function 'eval-defun))) |
| 525 | 530 |
| 526 ;; We should somehow arrange to be able to do this | |
| 527 ;; without actually replacing the eval-defun command. | |
| 528 (defun edebug-eval-defun (edebug-it) | 531 (defun edebug-eval-defun (edebug-it) |
| 529 "Evaluate the top-level form containing point, or after point. | 532 "Evaluate the top-level form containing point, or after point. |
| 530 | 533 |
| 531 This version, from Edebug, has the following differences: With a | 534 This version, from Edebug, has the following differences: With a |
| 532 prefix argument instrument the code for Edebug. If `edebug-all-defs' is | 535 prefix argument instrument the code for Edebug. If `edebug-all-defs' is |
| 533 non-nil, then the code is instrumented *unless* there is a prefix | 536 non-nil, then the code is instrumented *unless* there is a prefix |
| 534 argument. If instrumenting, it prints: `Edebug: FUNCTIONNAME'. | 537 argument. If instrumenting, it prints: `Edebug: FUNCTIONNAME'. |
| 535 Otherwise, it prints in the minibuffer." | 538 Otherwise, it prints in the minibuffer." |
| 536 (interactive "P") | 539 (interactive "P") |
| 537 (let* ((edebugging (not (eq (not edebug-it) (not edebug-all-defs)))) | 540 (let ((edebugging (not (eq (not edebug-it) (not edebug-all-defs)))) |
| 538 (edebug-result) | 541 (edebug-result)) |
| 539 (form | 542 (setq edebug-result |
| 540 (let ((edebug-all-forms edebugging) | 543 (eval |
| 541 (edebug-all-defs (eq edebug-all-defs (not edebug-it)))) | 544 (let ((edebug-all-forms edebugging) |
| 542 (edebug-read-top-level-form)))) | 545 (edebug-all-defs (eq edebug-all-defs (not edebug-it)))) |
| 543 (if (and (eq (car form) 'defvar) | 546 (edebug-read-top-level-form)))) |
| 544 (cdr-safe (cdr-safe form))) | |
| 545 (setq form (cons 'defconst (cdr form)))) | |
| 546 (setq edebug-result (eval form)) | |
| 547 (if (not edebugging) | 547 (if (not edebugging) |
| 548 (princ edebug-result) | 548 (princ edebug-result) |
| 549 edebug-result))) | 549 edebug-result))) |
| 550 | 550 |
| 551 | 551 |
| 558 This is like `eval-defun', but the code is always instrumented for Edebug. | 558 This is like `eval-defun', but the code is always instrumented for Edebug. |
| 559 Print its name in the minibuffer and leave point where it is, | 559 Print its name in the minibuffer and leave point where it is, |
| 560 or if an error occurs, leave point after it with mark at the original point." | 560 or if an error occurs, leave point after it with mark at the original point." |
| 561 (interactive) | 561 (interactive) |
| 562 (eval | 562 (eval |
| 563 ;; Bind edebug-all-forms only while reading, not while evalling | 563 ;; Bind edebug-all-forms only while reading, not while evaling |
| 564 ;; but this causes problems while edebugging edebug. | 564 ;; but this causes problems while edebugging edebug. |
| 565 (let ((edebug-all-forms t) | 565 (let ((edebug-all-forms t) |
| 566 (edebug-all-defs t)) | 566 (edebug-all-defs t)) |
| 567 (edebug-read-top-level-form)))) | 567 (edebug-read-top-level-form)))) |
| 568 | 568 |
| 609 (elisp-eval-region-uninstall) | 609 (elisp-eval-region-uninstall) |
| 610 (defalias 'read (symbol-function 'edebug-original-read)) | 610 (defalias 'read (symbol-function 'edebug-original-read)) |
| 611 (defalias 'eval-defun (symbol-function 'edebug-original-eval-defun))) | 611 (defalias 'eval-defun (symbol-function 'edebug-original-eval-defun))) |
| 612 | 612 |
| 613 | 613 |
| 614 ;;; Edebug internal data | 614 ;;;; Edebug internal data |
| 615 | 615 ;;; =============================== |
| 616 ;; The internal data that is needed for edebugging is kept in the | 616 |
| 617 ;; buffer-local variable `edebug-form-data'. | 617 ;;; The internal data that is needed for edebugging is kept in the |
| 618 ;;; buffer-local variable `edebug-form-data'. | |
| 618 | 619 |
| 619 ;; XEmacs change? | 620 ;; XEmacs change? |
| 620 (defconst edebug-form-data nil) | 621 (defconst edebug-form-data nil) |
| 621 (make-variable-buffer-local 'edebug-form-data) | 622 (make-variable-buffer-local 'edebug-form-data) |
| 622 | 623 |
| 694 ;; (get (car entry) 'edebug-dependents)) | 695 ;; (get (car entry) 'edebug-dependents)) |
| 695 ;; (set-marker (nth 1 entry) nil) | 696 ;; (set-marker (nth 1 entry) nil) |
| 696 ;; (set-marker (nth 2 entry) nil) | 697 ;; (set-marker (nth 2 entry) nil) |
| 697 (setq edebug-form-data (delq entry edebug-form-data))))) | 698 (setq edebug-form-data (delq entry edebug-form-data))))) |
| 698 | 699 |
| 699 ;;; Parser utilities | 700 |
| 701 ;;;; Parser utilities | |
| 702 ;;; =============================== | |
| 703 | |
| 700 | 704 |
| 701 (defun edebug-syntax-error (&rest args) | 705 (defun edebug-syntax-error (&rest args) |
| 702 ;; Signal an invalid-read-syntax with ARGS. | 706 ;; Signal an invalid-read-syntax with ARGS. |
| 703 (signal 'invalid-read-syntax args)) | 707 (signal 'invalid-read-syntax args)) |
| 704 | 708 |
| 712 (aset table i 'space) | 716 (aset table i 'space) |
| 713 (setq i (1+ i))) | 717 (setq i (1+ i))) |
| 714 (aset table ?\( 'lparen) | 718 (aset table ?\( 'lparen) |
| 715 (aset table ?\) 'rparen) | 719 (aset table ?\) 'rparen) |
| 716 (aset table ?\' 'quote) | 720 (aset table ?\' 'quote) |
| 717 (aset table ?\` 'backquote) | |
| 718 (aset table ?\, 'comma) | |
| 719 (aset table ?\" 'string) | 721 (aset table ?\" 'string) |
| 720 (aset table ?\? 'char) | 722 (aset table ?\? 'char) |
| 721 (aset table ?\[ 'lbracket) | 723 (aset table ?\[ 'lbracket) |
| 722 (aset table ?\] 'rbracket) | 724 (aset table ?\] 'rbracket) |
| 723 (aset table ?\. 'dot) | 725 (aset table ?\. 'dot) |
| 724 (aset table ?\# 'hash) | 726 (aset table ?\# 'hash) |
| 725 ;; We treat numbers as symbols, because of confusion with -, -1, and 1-. | 727 ;; We treat numbers as symbols, because of confusion with -, -1, and 1-. |
| 726 ;; We don't care about any other chars since they won't be seen. | 728 ;; We dont care about any other chars since they wont be seen. |
| 727 table)) | 729 table)) |
| 728 | 730 |
| 729 (defun edebug-next-token-class () | 731 (defun edebug-next-token-class () |
| 730 ;; Move to the next token and return its class. We only care about | 732 ;; Move to the next token and return its class. We only care about |
| 731 ;; lparen, rparen, dot, quote, backquote, comma, string, char, vector, | 733 ;; lparen, rparen, dot, quote, string, char, vector, or symbol. |
| 732 ;; or symbol. | |
| 733 (edebug-skip-whitespace) | 734 (edebug-skip-whitespace) |
| 734 (aref edebug-read-syntax-table (following-char))) | 735 (aref edebug-read-syntax-table (following-char))) |
| 735 | 736 |
| 736 | 737 |
| 737 (defun edebug-skip-whitespace () | 738 (defun edebug-skip-whitespace () |
| 764 (edebug-original-read (current-buffer)) | 765 (edebug-original-read (current-buffer)) |
| 765 (if (/= (preceding-char) ?\") | 766 (if (/= (preceding-char) ?\") |
| 766 (forward-char -1)))) | 767 (forward-char -1)))) |
| 767 ((eq class 'quote) (forward-char 1) | 768 ((eq class 'quote) (forward-char 1) |
| 768 (list 'quote (edebug-read-sexp))) | 769 (list 'quote (edebug-read-sexp))) |
| 769 ((eq class 'backquote) | |
| 770 (list '\` (edebug-read-sexp))) | |
| 771 ((eq class 'comma) | |
| 772 (list '\, (edebug-read-sexp))) | |
| 773 (t ; anything else, just read it. | 770 (t ; anything else, just read it. |
| 774 (edebug-original-read (current-buffer)))))) | 771 (edebug-original-read (current-buffer)))))) |
| 775 | 772 |
| 776 ;;; Offsets for reader | 773 |
| 774 ;;;; Offsets for reader | |
| 775 ;;; ============================== | |
| 777 | 776 |
| 778 ;; Define a structure to represent offset positions of expressions. | 777 ;; Define a structure to represent offset positions of expressions. |
| 779 ;; Each offset structure looks like: (before . after) for constituents, | 778 ;; Each offset structure looks like: (before . after) for constituents, |
| 780 ;; or for structures that have elements: (before <subexpressions> . after) | 779 ;; or for structures that have elements: (before <subexpressions> . after) |
| 781 ;; where the <subexpressions> are the offset structures for subexpressions | 780 ;; where the <subexpressions> are the offset structures for subexpressions |
| 846 (edebug-store-before-offset (, point)) | 845 (edebug-store-before-offset (, point)) |
| 847 (,@ body)) | 846 (,@ body)) |
| 848 (edebug-store-after-offset (point))))) | 847 (edebug-store-after-offset (point))))) |
| 849 | 848 |
| 850 | 849 |
| 851 ;;; Reader for Emacs Lisp. | 850 ;;;; Reader for Emacs Lisp. |
| 852 | 851 ;;; ========================================== |
| 853 ;; Uses edebug-next-token-class (and edebug-skip-whitespace) above. | 852 ;; Uses edebug-next-token-class (and edebug-skip-whitespace) above. |
| 854 | 853 |
| 855 (defconst edebug-read-alist | 854 (defconst edebug-read-alist |
| 856 '((symbol . edebug-read-symbol) | 855 '((symbol . edebug-read-symbol) |
| 857 (lparen . edebug-read-list) | 856 (lparen . edebug-read-list) |
| 858 (string . edebug-read-string) | 857 (string . edebug-read-string) |
| 859 (quote . edebug-read-quote) | 858 (quote . edebug-read-quote) |
| 860 (backquote . edebug-read-backquote) | |
| 861 (comma . edebug-read-comma) | |
| 862 (lbracket . edebug-read-vector) | 859 (lbracket . edebug-read-vector) |
| 863 (hash . edebug-read-function) | 860 (hash . edebug-read-function) |
| 864 )) | 861 )) |
| 865 | 862 |
| 866 (defun edebug-read-storing-offsets (stream) | 863 (defun edebug-read-storing-offsets (stream) |
| 893 (forward-char 1) | 890 (forward-char 1) |
| 894 (list | 891 (list |
| 895 (edebug-storing-offsets (point) 'quote) | 892 (edebug-storing-offsets (point) 'quote) |
| 896 (edebug-read-storing-offsets stream))) | 893 (edebug-read-storing-offsets stream))) |
| 897 | 894 |
| 898 (defun edebug-read-backquote (stream) | |
| 899 ;; Turn `thing into (\` thing) | |
| 900 (let ((opoint (point))) | |
| 901 (forward-char 1) | |
| 902 ;; Generate the same structure of offsets we would have | |
| 903 ;; if the resulting list appeared verbatim in the input text. | |
| 904 (edebug-storing-offsets opoint | |
| 905 (list | |
| 906 (edebug-storing-offsets opoint '\`) | |
| 907 (edebug-read-storing-offsets stream))))) | |
| 908 | |
| 909 (defvar edebug-read-backquote-new nil | |
| 910 "Non-nil if reading the inside of a new-style backquote with no parens around it. | |
| 911 Value of nil means reading the inside of an old-style backquote construct | |
| 912 which is surrounded by an extra set of parentheses. | |
| 913 This controls how we read comma constructs.") | |
| 914 | |
| 915 (defun edebug-read-comma (stream) | |
| 916 ;; Turn ,thing into (\, thing). Handle ,@ and ,. also. | |
| 917 (let ((opoint (point))) | |
| 918 (forward-char 1) | |
| 919 (let ((symbol '\,)) | |
| 920 (cond ((eq (following-char) ?\.) | |
| 921 (setq symbol '\,\.) | |
| 922 (forward-char 1)) | |
| 923 ((eq (following-char) ?\@) | |
| 924 (setq symbol '\,@) | |
| 925 (forward-char 1))) | |
| 926 ;; Generate the same structure of offsets we would have | |
| 927 ;; if the resulting list appeared verbatim in the input text. | |
| 928 (if edebug-read-backquote-new | |
| 929 (list | |
| 930 (edebug-storing-offsets opoint symbol) | |
| 931 (edebug-read-storing-offsets stream)) | |
| 932 (edebug-storing-offsets opoint symbol))))) | |
| 933 | |
| 934 (defun edebug-read-function (stream) | 895 (defun edebug-read-function (stream) |
| 935 ;; Turn #'thing into (function thing) | 896 ;; Turn #'thing into (function thing) |
| 936 (forward-char 1) | 897 (forward-char 1) |
| 937 (if (/= ?\' (following-char)) (edebug-syntax-error "Bad char")) | 898 (if (/= ?\' (following-char)) (edebug-syntax-error "Bad char")) |
| 938 (forward-char 1) | 899 (forward-char 1) |
| 944 (defun edebug-read-list (stream) | 905 (defun edebug-read-list (stream) |
| 945 (forward-char 1) ; skip \( | 906 (forward-char 1) ; skip \( |
| 946 (prog1 | 907 (prog1 |
| 947 (let ((elements)) | 908 (let ((elements)) |
| 948 (while (not (memq (edebug-next-token-class) '(rparen dot))) | 909 (while (not (memq (edebug-next-token-class) '(rparen dot))) |
| 949 (if (eq (edebug-next-token-class) 'backquote) | 910 (setq elements (cons (edebug-read-storing-offsets stream) elements))) |
| 950 (let ((edebug-read-backquote-new (not (null elements))) | |
| 951 (opoint (point))) | |
| 952 (if edebug-read-backquote-new | |
| 953 (setq elements (cons (edebug-read-backquote stream) elements)) | |
| 954 (forward-char 1) ; Skip backquote. | |
| 955 ;; Call edebug-storing-offsets here so that we | |
| 956 ;; produce the same offsets we would have had | |
| 957 ;; if the backquote were an ordinary symbol. | |
| 958 (setq elements (cons (edebug-storing-offsets opoint '\`) | |
| 959 elements)))) | |
| 960 (setq elements (cons (edebug-read-storing-offsets stream) elements)))) | |
| 961 (setq elements (nreverse elements)) | 911 (setq elements (nreverse elements)) |
| 962 (if (eq 'dot (edebug-next-token-class)) | 912 (if (eq 'dot (edebug-next-token-class)) |
| 963 (let (dotted-form) | 913 (let (dotted-form) |
| 964 (forward-char 1) ; skip \. | 914 (forward-char 1) ; skip \. |
| 965 (setq dotted-form (edebug-read-storing-offsets stream)) | 915 (setq dotted-form (edebug-read-storing-offsets stream)) |
| 980 (setq elements (cons (edebug-read-storing-offsets stream) elements))) | 930 (setq elements (cons (edebug-read-storing-offsets stream) elements))) |
| 981 (apply 'vector (nreverse elements))) | 931 (apply 'vector (nreverse elements))) |
| 982 (forward-char 1) ; skip \] | 932 (forward-char 1) ; skip \] |
| 983 )) | 933 )) |
| 984 | 934 |
| 985 ;;; Cursors for traversal of list and vector elements with offsets. | 935 |
| 936 | |
| 937 ;;;; Cursors for traversal of list and vector elements with offsets. | |
| 938 ;;;==================================================================== | |
| 986 | 939 |
| 987 (defvar edebug-dotted-spec nil) | 940 (defvar edebug-dotted-spec nil) |
| 988 | 941 |
| 989 (defun edebug-new-cursor (expressions offsets) | 942 (defun edebug-new-cursor (expressions offsets) |
| 990 ;; Return a new cursor for EXPRESSIONS with OFFSETS. | 943 ;; Return a new cursor for EXPRESSIONS with OFFSETS. |
| 1057 (let ((offset (edebug-top-offset cursor))) | 1010 (let ((offset (edebug-top-offset cursor))) |
| 1058 (while (consp offset) | 1011 (while (consp offset) |
| 1059 (setq offset (cdr offset))) | 1012 (setq offset (cdr offset))) |
| 1060 offset)) | 1013 offset)) |
| 1061 | 1014 |
| 1062 ;;; The Parser | 1015 ;;;; The Parser |
| 1063 | 1016 ;;; =============================== |
| 1064 ;; The top level function for parsing forms is | 1017 |
| 1065 ;; edebug-read-and-maybe-wrap-form; it calls all the rest. It checks the | 1018 ;;; The top level function for parsing forms is |
| 1066 ;; syntax a bit and leaves point at any error it finds, but otherwise | 1019 ;;; edebug-read-and-maybe-wrap-form; it calls all the rest. It checks the |
| 1067 ;; should appear to work like eval-defun. | 1020 ;;; syntax a bit and leaves point at any error it finds, but otherwise |
| 1068 | 1021 ;;; should appear to work like eval-defun. |
| 1069 ;; The basic plan is to surround each expression with a call to | 1022 |
| 1070 ;; the edebug debugger together with indexes into a table of positions of | 1023 ;;; The basic plan is to surround each expression with a call to |
| 1071 ;; all expressions. Thus an expression "exp" becomes: | 1024 ;;; the edebug debugger together with indexes into a table of positions of |
| 1072 | 1025 ;;; all expressions. Thus an expression "exp" becomes: |
| 1073 ;; (edebug-after (edebug-before 1) 2 exp) | 1026 |
| 1074 | 1027 ;;; (edebug-after (edebug-before 1) 2 exp) |
| 1075 ;; When this is evaluated, first point is moved to the beginning of | 1028 |
| 1076 ;; exp at offset 1 of the current function. The expression is | 1029 ;;; When this is evaluated, first point is moved to the beginning of |
| 1077 ;; evaluated, which may cause more edebug calls, and then point is | 1030 ;;; exp at offset 1 of the current function. The expression is |
| 1078 ;; moved to offset 2 after the end of exp. | 1031 ;;; evaluated, which may cause more edebug calls, and then point is |
| 1079 | 1032 ;;; moved to offset 2 after the end of exp. |
| 1080 ;; The highest level expressions of the function are wrapped in a call to | 1033 |
| 1081 ;; edebug-enter, which supplies the function name and the actual | 1034 ;;; The highest level expressions of the function are wrapped in a call to |
| 1082 ;; arguments to the function. See functions edebug-enter, edebug-before, | 1035 ;;; edebug-enter, which supplies the function name and the actual |
| 1083 ;; and edebug-after for more details. | 1036 ;;; arguments to the function. See functions edebug-enter, edebug-before, |
| 1037 ;;; and edebug-after for more details. | |
| 1084 | 1038 |
| 1085 ;; Dynamically bound vars, left unbound, but globally declared. | 1039 ;; Dynamically bound vars, left unbound, but globally declared. |
| 1086 ;; This is to quiet the byte compiler. | 1040 ;; This is to quiet the byte compiler. |
| 1087 | 1041 |
| 1088 ;; Window data of the highest definition being wrapped. | 1042 ;; Window data of the highest definition being wrapped. |
| 1109 (setq edebug-setup-hook nil) | 1063 (setq edebug-setup-hook nil) |
| 1110 | 1064 |
| 1111 (let (result | 1065 (let (result |
| 1112 edebug-top-window-data | 1066 edebug-top-window-data |
| 1113 edebug-def-name;; make sure it is locally nil | 1067 edebug-def-name;; make sure it is locally nil |
| 1114 ;; I don't like these here!! | 1068 ;; I dont like these here!! |
| 1115 edebug-&optional | 1069 edebug-&optional |
| 1116 edebug-&rest | 1070 edebug-&rest |
| 1117 edebug-gate | 1071 edebug-gate |
| 1118 edebug-best-error | 1072 edebug-best-error |
| 1119 edebug-error-point | 1073 edebug-error-point |
| 1133 (defun edebug-read-and-maybe-wrap-form1 () | 1087 (defun edebug-read-and-maybe-wrap-form1 () |
| 1134 (let (spec | 1088 (let (spec |
| 1135 def-kind | 1089 def-kind |
| 1136 defining-form-p | 1090 defining-form-p |
| 1137 def-name | 1091 def-name |
| 1138 ;; These offset things don't belong here, but to support recursive | 1092 ;; These offset things dont belong here, but to support recursive |
| 1139 ;; calls to edebug-read, they need to be here. | 1093 ;; calls to edebug-read, they need to be here. |
| 1140 edebug-offsets | 1094 edebug-offsets |
| 1141 edebug-offsets-stack | 1095 edebug-offsets-stack |
| 1142 edebug-current-offset ; reset to nil | 1096 edebug-current-offset ; reset to nil |
| 1143 ) | 1097 ) |
| 1227 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon"))) | 1181 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon"))) |
| 1228 (` (edebug-enter | 1182 (` (edebug-enter |
| 1229 (quote (, edebug-def-name)) | 1183 (quote (, edebug-def-name)) |
| 1230 (, (if edebug-inside-func | 1184 (, (if edebug-inside-func |
| 1231 (` (list (,@ | 1185 (` (list (,@ |
| 1232 ;; Doesn't work with more than one def-body!! | 1186 ;; Doesnt work with more than one def-body!! |
| 1233 ;; But the list will just be reversed. | 1187 ;; But the list will just be reversed. |
| 1234 (nreverse edebug-def-args)))) | 1188 (nreverse edebug-def-args)))) |
| 1235 'nil)) | 1189 'nil)) |
| 1236 (function (lambda () (,@ forms))) | 1190 (function (lambda () (,@ forms))) |
| 1237 ))) | 1191 ))) |
| 1256 ;; Return the edebug form for the current function at offset BEFORE-INDEX | 1210 ;; Return the edebug form for the current function at offset BEFORE-INDEX |
| 1257 ;; given FORM. Looks like: | 1211 ;; given FORM. Looks like: |
| 1258 ;; (edebug-after (edebug-before BEFORE-INDEX) AFTER-INDEX FORM) | 1212 ;; (edebug-after (edebug-before BEFORE-INDEX) AFTER-INDEX FORM) |
| 1259 ;; Also increment the offset index for subsequent use. | 1213 ;; Also increment the offset index for subsequent use. |
| 1260 ;; if (not edebug-stop-before-symbols) and form is a symbol, | 1214 ;; if (not edebug-stop-before-symbols) and form is a symbol, |
| 1261 ;; then don't call edebug-before. | 1215 ;; then dont call edebug-before. |
| 1262 (list 'edebug-after | 1216 (list 'edebug-after |
| 1263 (list 'edebug-before before-index) | 1217 (list 'edebug-before before-index) |
| 1264 after-index form)) | 1218 after-index form)) |
| 1265 | 1219 |
| 1266 (defun edebug-make-after-form (form after-index) | 1220 (defun edebug-make-after-form (form after-index) |
| 1445 (edebug-inc-offset (edebug-cursor-offsets new-cursor)))) | 1399 (edebug-inc-offset (edebug-cursor-offsets new-cursor)))) |
| 1446 ))) | 1400 ))) |
| 1447 | 1401 |
| 1448 ((symbolp form) | 1402 ((symbolp form) |
| 1449 (cond | 1403 (cond |
| 1450 ;; Check for constant symbols that don't get wrapped. | 1404 ;; Check for constant symbols that dont get wrapped. |
| 1451 ((or (memq form '(t nil)) | 1405 ((or (memq form '(t nil)) |
| 1452 (and (fboundp 'edebug-keywordp) (edebug-keywordp form))) | 1406 (and (fboundp 'edebug-keywordp) (edebug-keywordp form))) |
| 1453 form) | 1407 form) |
| 1454 | 1408 |
| 1455 ;; This option may go away. | 1409 ;; This option may go away. |
| 1534 | 1488 |
| 1535 (t (edebug-syntax-error | 1489 (t (edebug-syntax-error |
| 1536 "Head of list form must be a symbol or lambda expression."))) | 1490 "Head of list form must be a symbol or lambda expression."))) |
| 1537 )) | 1491 )) |
| 1538 | 1492 |
| 1539 ;;; Matching of specs. | 1493 |
| 1494 ;;;; Matching of specs. | |
| 1495 ;;; =================== | |
| 1540 | 1496 |
| 1541 (defvar edebug-after-dotted-spec nil) | 1497 (defvar edebug-after-dotted-spec nil) |
| 1542 | 1498 |
| 1543 (defvar edebug-matching-depth 0) ;; initial value | 1499 (defvar edebug-matching-depth 0) ;; initial value |
| 1544 (defconst edebug-max-depth 150) ;; maximum number of matching recursions. | 1500 (defconst edebug-max-depth 150) ;; maximum number of matching recursions. |
| 1545 | 1501 |
| 1546 | 1502 |
| 1547 ;;; Failure to match | 1503 ;;;; Failure to match |
| 1548 | 1504 ;;; ================== |
| 1549 ;; This throws to no-match, if there are higher alternatives. | 1505 ;; This throws to no-match, if there are higher alternatives. |
| 1550 ;; Otherwise it signals an error. The place of the error is found | 1506 ;; Otherwise it signals an error. The place of the error is found |
| 1551 ;; with the two before- and after-offset functions. | 1507 ;; with the two before- and after-offset functions. |
| 1552 | 1508 |
| 1553 (defun edebug-no-match (cursor &rest edebug-args) | 1509 (defun edebug-no-match (cursor &rest edebug-args) |
| 1631 (edebug-match-one-spec cursor spec))) | 1587 (edebug-match-one-spec cursor spec))) |
| 1632 (funcall remainder-handler cursor rest remainder-handler))))))) | 1588 (funcall remainder-handler cursor rest remainder-handler))))))) |
| 1633 | 1589 |
| 1634 | 1590 |
| 1635 ;; Define specs for all the symbol specs with functions used to process them. | 1591 ;; Define specs for all the symbol specs with functions used to process them. |
| 1636 ;; Perhaps we shouldn't be doing this with edebug-form-specs since the | 1592 ;; Perhaps we shouldnt be doing this with edebug-form-specs since the |
| 1637 ;; user may want to define macros or functions with the same names. | 1593 ;; user may want to define macros or functions with the same names. |
| 1638 ;; We could use an internal obarray for these primitive specs. | 1594 ;; We could use an internal obarray for these primitive specs. |
| 1639 | 1595 |
| 1640 (mapcar | 1596 (mapcar |
| 1641 (function (lambda (pair) | 1597 (function (lambda (pair) |
| 1749 (catch 'no-match | 1705 (catch 'no-match |
| 1750 (throw 'matched | 1706 (throw 'matched |
| 1751 (let (edebug-gate ;; only while matching each spec | 1707 (let (edebug-gate ;; only while matching each spec |
| 1752 edebug-best-error | 1708 edebug-best-error |
| 1753 edebug-error-point) | 1709 edebug-error-point) |
| 1754 ;; Doesn't support e.g. &or symbolp &rest form | 1710 ;; Doesnt support e.g. &or symbolp &rest form |
| 1755 (edebug-match-one-spec cursor (car specs))))) | 1711 (edebug-match-one-spec cursor (car specs))))) |
| 1756 ;; Match failed, so reset and try again. | 1712 ;; Match failed, so reset and try again. |
| 1757 (setq specs (cdr specs)) | 1713 (setq specs (cdr specs)) |
| 1758 ;; Reset the cursor for the next match. | 1714 ;; Reset the cursor for the next match. |
| 1759 (edebug-set-cursor cursor this-form this-offset)) | 1715 (edebug-set-cursor cursor this-form this-offset)) |
| 1778 (def-edebug-spec &key edebug-match-&key) | 1734 (def-edebug-spec &key edebug-match-&key) |
| 1779 | 1735 |
| 1780 (defun edebug-match-&key (cursor specs) | 1736 (defun edebug-match-&key (cursor specs) |
| 1781 ;; Following specs must look like (<name> <spec>) ... | 1737 ;; Following specs must look like (<name> <spec>) ... |
| 1782 ;; where <name> is the name of a keyword, and spec is its spec. | 1738 ;; where <name> is the name of a keyword, and spec is its spec. |
| 1783 ;; This really doesn't save much over the expanded form and takes time. | 1739 ;; This really doesnt save much over the expanded form and takes time. |
| 1784 (edebug-match-&rest | 1740 (edebug-match-&rest |
| 1785 cursor | 1741 cursor |
| 1786 (cons '&or | 1742 (cons '&or |
| 1787 (mapcar (function (lambda (pair) | 1743 (mapcar (function (lambda (pair) |
| 1788 (vector (format ":%s" (car pair)) | 1744 (vector (format ":%s" (car pair)) |
| 1882 (defun edebug-match-function (cursor) | 1838 (defun edebug-match-function (cursor) |
| 1883 (error "Use function-form instead of function in edebug spec")) | 1839 (error "Use function-form instead of function in edebug spec")) |
| 1884 | 1840 |
| 1885 (defun edebug-match-&define (cursor specs) | 1841 (defun edebug-match-&define (cursor specs) |
| 1886 ;; Match a defining form. | 1842 ;; Match a defining form. |
| 1887 ;; Normally, &define is interpreted specially other places. | 1843 ;; Normally, &define is interpretted specially other places. |
| 1888 ;; This should only be called inside of a spec list to match the remainder | 1844 ;; This should only be called inside of a spec list to match the remainder |
| 1889 ;; of the current list. e.g. ("lambda" &define args def-body) | 1845 ;; of the current list. e.g. ("lambda" &define args def-body) |
| 1890 (edebug-make-form-wrapper | 1846 (edebug-make-form-wrapper |
| 1891 cursor | 1847 cursor |
| 1892 (edebug-before-offset cursor) | 1848 (edebug-before-offset cursor) |
| 2004 edebug-spec-p ;; Including all the special ones e.g. form. | 1960 edebug-spec-p ;; Including all the special ones e.g. form. |
| 2005 symbolp;; a predicate | 1961 symbolp;; a predicate |
| 2006 )) | 1962 )) |
| 2007 | 1963 |
| 2008 | 1964 |
| 2009 ;;;* Emacs special forms and some functions. | 1965 ;;;;* Emacs special forms and some functions. |
| 2010 | 1966 |
| 2011 ;; quote expects only one argument, although it allows any number. | 1967 ;; quote expects only one argument, although it allows any number. |
| 2012 (def-edebug-spec quote sexp) | 1968 (def-edebug-spec quote sexp) |
| 2013 | 1969 |
| 2014 ;; The standard defining forms. | 1970 ;; The standard defining forms. |
| 2021 [&optional ("interactive" interactive)] | 1977 [&optional ("interactive" interactive)] |
| 2022 def-body)) | 1978 def-body)) |
| 2023 (def-edebug-spec defmacro | 1979 (def-edebug-spec defmacro |
| 2024 (&define name lambda-list def-body)) | 1980 (&define name lambda-list def-body)) |
| 2025 | 1981 |
| 2026 (def-edebug-spec arglist lambda-list) ;; deprecated - use lambda-list. | 1982 (def-edebug-spec arglist lambda-list) ;; denegrated - use lambda-list. |
| 2027 | 1983 |
| 2028 (def-edebug-spec lambda-list | 1984 (def-edebug-spec lambda-list |
| 2029 (([&rest arg] | 1985 (([&rest arg] |
| 2030 [&optional ["&optional" arg &rest arg]] | 1986 [&optional ["&optional" arg &rest arg]] |
| 2031 &optional ["&rest" arg] | 1987 &optional ["&rest" arg] |
| 2122 (def-edebug-spec eval-and-compile t) | 2078 (def-edebug-spec eval-and-compile t) |
| 2123 | 2079 |
| 2124 ;; Anything else? | 2080 ;; Anything else? |
| 2125 | 2081 |
| 2126 | 2082 |
| 2083 ;;==================== | |
| 2127 ;; Some miscellaneous specs for macros in public packages. | 2084 ;; Some miscellaneous specs for macros in public packages. |
| 2128 ;; Send me yours. | 2085 ;; Send me yours. |
| 2129 | 2086 |
| 2130 ;; advice.el by Hans Chalupsky (hans@cs.buffalo.edu) | 2087 ;; advice.el by Hans Chalupsky (hans@cs.buffalo.edu) |
| 2131 | 2088 |
| 2139 ) | 2096 ) |
| 2140 [&optional stringp] | 2097 [&optional stringp] |
| 2141 [&optional ("interactive" interactive)] | 2098 [&optional ("interactive" interactive)] |
| 2142 def-body)) | 2099 def-body)) |
| 2143 | 2100 |
| 2144 ;;; The debugger itself | 2101 |
| 2102 ;;;; The debugger itself | |
| 2103 ;;; =============================== | |
| 2145 | 2104 |
| 2146 (defvar edebug-active nil) ;; Non-nil when edebug is active | 2105 (defvar edebug-active nil) ;; Non-nil when edebug is active |
| 2147 | 2106 |
| 2148 ;;; add minor-mode-alist entry | 2107 ;;; add minor-mode-alist entry |
| 2149 (or (assq 'edebug-active minor-mode-alist) | 2108 (or (assq 'edebug-active minor-mode-alist) |
| 2206 (defvar post-command-idle-hook nil) | 2165 (defvar post-command-idle-hook nil) |
| 2207 | 2166 |
| 2208 (defvar cl-lexical-debug) ;; Defined in cl.el | 2167 (defvar cl-lexical-debug) ;; Defined in cl.el |
| 2209 | 2168 |
| 2210 ;;; Handling signals | 2169 ;;; Handling signals |
| 2170 ;;; ================= | |
| 2211 | 2171 |
| 2212 (if (not (fboundp 'edebug-original-signal)) | 2172 (if (not (fboundp 'edebug-original-signal)) |
| 2213 (defalias 'edebug-original-signal (symbol-function 'signal))) | 2173 (defalias 'edebug-original-signal (symbol-function 'signal))) |
| 2214 ;; We should use advise for this!! | 2174 ;; We should use advise for this!! |
| 2215 | 2175 |
| 2234 ;; i.e. the signal is not continuable, yet. | 2194 ;; i.e. the signal is not continuable, yet. |
| 2235 (edebug-original-signal edebug-signal-name edebug-signal-data)) | 2195 (edebug-original-signal edebug-signal-name edebug-signal-data)) |
| 2236 | 2196 |
| 2237 | 2197 |
| 2238 ;;; Entering Edebug | 2198 ;;; Entering Edebug |
| 2199 ;;; ================== | |
| 2239 | 2200 |
| 2240 (defun edebug-enter (edebug-function edebug-args edebug-body) | 2201 (defun edebug-enter (edebug-function edebug-args edebug-body) |
| 2241 ;; Entering FUNC. The arguments are ARGS, and the body is BODY. | 2202 ;; Entering FUNC. The arguments are ARGS, and the body is BODY. |
| 2242 ;; Setup edebug variables and evaluate BODY. This function is called | 2203 ;; Setup edebug variables and evaluate BODY. This function is called |
| 2243 ;; when a function evaluated with edebug-eval-top-level-form is entered. | 2204 ;; when a function evaluated with edebug-eval-top-level-form is entered. |
| 2264 | 2225 |
| 2265 ;; Lexical bindings must be uncompiled for this to work. | 2226 ;; Lexical bindings must be uncompiled for this to work. |
| 2266 (cl-lexical-debug t) | 2227 (cl-lexical-debug t) |
| 2267 | 2228 |
| 2268 ;; Save the outside value of executing macro. (here??) | 2229 ;; Save the outside value of executing macro. (here??) |
| 2269 (edebug-outside-executing-macro executing-kbd-macro) | 2230 (edebug-outside-executing-macro executing-macro) |
| 2270 (edebug-outside-pre-command-hook pre-command-hook) | 2231 (edebug-outside-pre-command-hook pre-command-hook) |
| 2271 (edebug-outside-post-command-hook post-command-hook) | 2232 (edebug-outside-post-command-hook post-command-hook) |
| 2272 (edebug-outside-post-command-idle-hook post-command-idle-hook)) | 2233 (edebug-outside-post-command-idle-hook post-command-idle-hook)) |
| 2273 (unwind-protect | 2234 (unwind-protect |
| 2274 (let (;; Don't keep reading from an executing kbd macro | 2235 (let (;; Don't keep reading from an executing kbd macro |
| 2275 ;; within edebug unless edebug-continue-kbd-macro is | 2236 ;; within edebug unless edebug-continue-kbd-macro is |
| 2276 ;; non-nil. Again, local binding may not be best. | 2237 ;; non-nil. Again, local binding may not be best. |
| 2277 (executing-kbd-macro | 2238 (executing-macro |
| 2278 (if edebug-continue-kbd-macro executing-kbd-macro)) | 2239 (if edebug-continue-kbd-macro executing-macro)) |
| 2279 | 2240 |
| 2280 ;; Disable command hooks. This is essential when | 2241 ;; Disable command hooks. This is essential when |
| 2281 ;; a hook function is instrumented - to avoid infinite loop. | 2242 ;; a hook function is instrumented - to avoid infinite loop. |
| 2282 ;; This may be more than we need, however. | 2243 ;; This may be more than we need, however. |
| 2283 (pre-command-hook nil) | 2244 (pre-command-hook nil) |
| 2291 (fset 'signal 'edebug-signal) | 2252 (fset 'signal 'edebug-signal) |
| 2292 (unwind-protect | 2253 (unwind-protect |
| 2293 (edebug-enter edebug-function edebug-args edebug-body) | 2254 (edebug-enter edebug-function edebug-args edebug-body) |
| 2294 (fset 'signal (symbol-function 'edebug-original-signal)))) | 2255 (fset 'signal (symbol-function 'edebug-original-signal)))) |
| 2295 ;; Reset global variables in case outside value was changed. | 2256 ;; Reset global variables in case outside value was changed. |
| 2296 (setq executing-kbd-macro edebug-outside-executing-macro | 2257 (setq executing-macro edebug-outside-executing-macro |
| 2297 pre-command-hook edebug-outside-pre-command-hook | 2258 pre-command-hook edebug-outside-pre-command-hook |
| 2298 post-command-hook edebug-outside-post-command-hook | 2259 post-command-hook edebug-outside-post-command-hook |
| 2299 post-command-idle-hook edebug-outside-post-command-idle-hook | 2260 post-command-idle-hook edebug-outside-post-command-idle-hook |
| 2300 ))) | 2261 ))) |
| 2301 | 2262 |
| 2550 | 2511 |
| 2551 (if edebug-save-displayed-buffer-points | 2512 (if edebug-save-displayed-buffer-points |
| 2552 (setq edebug-buffer-points (edebug-get-displayed-buffer-points))) | 2513 (setq edebug-buffer-points (edebug-get-displayed-buffer-points))) |
| 2553 | 2514 |
| 2554 ;; First move the edebug buffer point to edebug-point | 2515 ;; First move the edebug buffer point to edebug-point |
| 2555 ;; so that window start doesn't get changed when we display it. | 2516 ;; so that window start doesnt get changed when we display it. |
| 2556 ;; I don't know if this is going to help. | 2517 ;; I dont know if this is going to help. |
| 2557 ;;(set-buffer edebug-buffer) | 2518 ;;(set-buffer edebug-buffer) |
| 2558 ;;(goto-char edebug-point) | 2519 ;;(goto-char edebug-point) |
| 2559 | 2520 |
| 2560 ;; If edebug-buffer is not currently displayed, | 2521 ;; If edebug-buffer is not currently displayed, |
| 2561 ;; first find a window for it. | 2522 ;; first find a window for it. |
| 2646 (if (or edebug-stop | 2607 (if (or edebug-stop |
| 2647 (memq edebug-execution-mode '(step next)) | 2608 (memq edebug-execution-mode '(step next)) |
| 2648 (eq edebug-arg-mode 'error)) | 2609 (eq edebug-arg-mode 'error)) |
| 2649 (progn | 2610 (progn |
| 2650 ;; (setq edebug-execution-mode 'step) | 2611 ;; (setq edebug-execution-mode 'step) |
| 2651 ;; (edebug-overlay-arrow) ; this doesn't always show up. | 2612 ;; (edebug-overlay-arrow) ; this doesnt always show up. |
| 2652 (edebug-recursive-edit))) ; <---------- Recursive edit | 2613 (edebug-recursive-edit))) ; <---------- Recursive edit |
| 2653 | 2614 |
| 2654 ;; Reset the edebug-window-data to whatever it is now. | 2615 ;; Reset the edebug-window-data to whatever it is now. |
| 2655 (let ((window (if (eq (window-buffer) edebug-buffer) | 2616 (let ((window (if (eq (window-buffer) edebug-buffer) |
| 2656 (selected-window) | 2617 (selected-window) |
| 2692 (progn | 2653 (progn |
| 2693 (set-window-start window (cdr edebug-window-data) | 2654 (set-window-start window (cdr edebug-window-data) |
| 2694 'no-force) | 2655 'no-force) |
| 2695 ;; Unrestore edebug-buffer's window-point. | 2656 ;; Unrestore edebug-buffer's window-point. |
| 2696 ;; Needed in addition to setting the buffer point | 2657 ;; Needed in addition to setting the buffer point |
| 2697 ;; - otherwise quitting doesn't leave point as is. | 2658 ;; - otherwise quitting doesnt leave point as is. |
| 2698 ;; But this causes point to not be restored at times. | 2659 ;; But this causes point to not be restored at times. |
| 2699 ;; Also, it may not be a visible window. | 2660 ;; Also, it may not be a visible window. |
| 2700 ;; (set-window-point window edebug-point) | 2661 ;; (set-window-point window edebug-point) |
| 2701 ))) | 2662 ))) |
| 2702 | 2663 |
| 2712 | 2673 |
| 2713 ;; Restore current buffer always, in case application needs it. | 2674 ;; Restore current buffer always, in case application needs it. |
| 2714 (set-buffer edebug-outside-buffer) | 2675 (set-buffer edebug-outside-buffer) |
| 2715 ;; Restore point, and mark. | 2676 ;; Restore point, and mark. |
| 2716 ;; Needed even if restoring windows because | 2677 ;; Needed even if restoring windows because |
| 2717 ;; that doesn't restore point and mark in the current buffer. | 2678 ;; that doesnt restore point and mark in the current buffer. |
| 2718 ;; But don't restore point if edebug-buffer is current buffer. | 2679 ;; But dont restore point if edebug-buffer is current buffer. |
| 2719 (if (not (eq edebug-buffer edebug-outside-buffer)) | 2680 (if (not (eq edebug-buffer edebug-outside-buffer)) |
| 2720 (goto-char edebug-outside-point)) | 2681 (goto-char edebug-outside-point)) |
| 2721 (if (marker-buffer (edebug-mark-marker)) | 2682 (if (marker-buffer (edebug-mark-marker)) |
| 2722 ;; Does zmacs-regions need to be nil while doing set-marker? | 2683 ;; Does zmacs-regions need to be nil while doing set-marker? |
| 2723 (set-marker (edebug-mark-marker) edebug-outside-mark)) | 2684 (set-marker (edebug-mark-marker) edebug-outside-mark)) |
| 2937 )) | 2898 )) |
| 2938 )) | 2899 )) |
| 2939 | 2900 |
| 2940 | 2901 |
| 2941 ;;; Display related functions | 2902 ;;; Display related functions |
| 2903 ;;; =============================== | |
| 2942 | 2904 |
| 2943 (defun edebug-adjust-window (old-start) | 2905 (defun edebug-adjust-window (old-start) |
| 2944 ;; If pos is not visible, adjust current window to fit following context. | 2906 ;; If pos is not visible, adjust current window to fit following context. |
| 2945 ;;; (message "window: %s old-start: %s window-start: %s pos: %s" | 2907 ;;; (message "window: %s old-start: %s window-start: %s pos: %s" |
| 2946 ;;; (selected-window) old-start (window-start) (point)) (sit-for 5) | 2908 ;;; (selected-window) old-start (window-start) (point)) (sit-for 5) |
| 3109 (delq buffer edebug-display-buffer-list) | 3071 (delq buffer edebug-display-buffer-list) |
| 3110 (cons buffer edebug-display-buffer-list))) | 3072 (cons buffer edebug-display-buffer-list))) |
| 3111 (message "Displaying %s %s" buffer | 3073 (message "Displaying %s %s" buffer |
| 3112 (if already-displaying "off" "on")))) | 3074 (if already-displaying "off" "on")))) |
| 3113 | 3075 |
| 3076 | |
| 3114 ;;; Breakpoint related functions | 3077 ;;; Breakpoint related functions |
| 3078 ;;; =============================== | |
| 3115 | 3079 |
| 3116 (defun edebug-find-stop-point () | 3080 (defun edebug-find-stop-point () |
| 3117 ;; Return (function . index) of the nearest edebug stop point. | 3081 ;; Return (function . index) of the nearest edebug stop point. |
| 3118 (let* ((edebug-def-name (edebug-form-data-symbol)) | 3082 (let* ((edebug-def-name (edebug-form-data-symbol)) |
| 3119 (edebug-data | 3083 (edebug-data |
| 3173 ;; goto the first breakpoint | 3137 ;; goto the first breakpoint |
| 3174 (car edebug-breakpoints))) | 3138 (car edebug-breakpoints))) |
| 3175 (goto-char (+ edebug-def-mark | 3139 (goto-char (+ edebug-def-mark |
| 3176 (aref offset-vector (car breakpoint)))) | 3140 (aref offset-vector (car breakpoint)))) |
| 3177 | 3141 |
| 3178 (message "%s" | 3142 (message (concat (if (nth 2 breakpoint) |
| 3179 (concat (if (nth 2 breakpoint) | |
| 3180 "Temporary " "") | 3143 "Temporary " "") |
| 3181 (if (car (cdr breakpoint)) | 3144 (if (car (cdr breakpoint)) |
| 3182 (format "Condition: %s" | 3145 (format "Condition: %s" |
| 3183 (edebug-safe-prin1-to-string | 3146 (edebug-safe-prin1-to-string |
| 3184 (car (cdr breakpoint)))) | 3147 (car (cdr breakpoint)))) |
| 3269 (format "%s" edebug-global-break-condition)))) | 3232 (format "%s" edebug-global-break-condition)))) |
| 3270 (setq edebug-global-break-condition expression)) | 3233 (setq edebug-global-break-condition expression)) |
| 3271 | 3234 |
| 3272 | 3235 |
| 3273 ;;; Mode switching functions | 3236 ;;; Mode switching functions |
| 3237 ;;; =============================== | |
| 3274 | 3238 |
| 3275 (defun edebug-set-mode (mode shortmsg msg) | 3239 (defun edebug-set-mode (mode shortmsg msg) |
| 3276 ;; Set the edebug mode to MODE. | 3240 ;; Set the edebug mode to MODE. |
| 3277 ;; Display SHORTMSG, or MSG if not within edebug. | 3241 ;; Display SHORTMSG, or MSG if not within edebug. |
| 3278 (if (eq (1+ edebug-recursion-depth) (recursion-depth)) | 3242 (if (eq (1+ edebug-recursion-depth) (recursion-depth)) |
| 3493 ;; "Go until the current function exits." | 3457 ;; "Go until the current function exits." |
| 3494 ;; (interactive) | 3458 ;; (interactive) |
| 3495 ;; (edebug-set-mode 'exiting "Exit...")) | 3459 ;; (edebug-set-mode 'exiting "Exit...")) |
| 3496 | 3460 |
| 3497 | 3461 |
| 3462 ;;; ----------------------------------------------------------------- | |
| 3498 ;;; The following initial mode setting definitions are not used yet. | 3463 ;;; The following initial mode setting definitions are not used yet. |
| 3499 | 3464 |
| 3500 '(defconst edebug-initial-mode-alist | 3465 '(defconst edebug-initial-mode-alist |
| 3501 '((edebug-Continue-fast . Continue-fast) | 3466 '((edebug-Continue-fast . Continue-fast) |
| 3502 (edebug-Trace-fast . Trace-fast) | 3467 (edebug-Trace-fast . Trace-fast) |
| 3538 (message "Initial mode for %s is now: %s" | 3503 (message "Initial mode for %s is now: %s" |
| 3539 this-function mode)) | 3504 this-function mode)) |
| 3540 (error "Key must map to one of the mode changing commands") | 3505 (error "Key must map to one of the mode changing commands") |
| 3541 ))) | 3506 ))) |
| 3542 | 3507 |
| 3508 | |
| 3543 ;;; Evaluation of expressions | 3509 ;;; Evaluation of expressions |
| 3510 ;;; =============================== | |
| 3544 | 3511 |
| 3545 (def-edebug-spec edebug-outside-excursion t) | 3512 (def-edebug-spec edebug-outside-excursion t) |
| 3546 | 3513 |
| 3547 (defmacro edebug-outside-excursion (&rest body) | 3514 (defmacro edebug-outside-excursion (&rest body) |
| 3548 "Evaluate an expression list in the outside context. | 3515 "Evaluate an expression list in the outside context. |
| 3575 (last-nonmenu-event edebug-outside-last-nonmenu-event) | 3542 (last-nonmenu-event edebug-outside-last-nonmenu-event) |
| 3576 (track-mouse edebug-outside-track-mouse) | 3543 (track-mouse edebug-outside-track-mouse) |
| 3577 (standard-output edebug-outside-standard-output) | 3544 (standard-output edebug-outside-standard-output) |
| 3578 (standard-input edebug-outside-standard-input) | 3545 (standard-input edebug-outside-standard-input) |
| 3579 | 3546 |
| 3580 (executing-kbd-macro edebug-outside-executing-macro) | 3547 (executing-macro edebug-outside-executing-macro) |
| 3581 (defining-kbd-macro edebug-outside-defining-kbd-macro) | 3548 (defining-kbd-macro edebug-outside-defining-kbd-macro) |
| 3582 (pre-command-hook edebug-outside-pre-command-hook) | 3549 (pre-command-hook edebug-outside-pre-command-hook) |
| 3583 (post-command-hook edebug-outside-post-command-hook) | 3550 (post-command-hook edebug-outside-post-command-hook) |
| 3584 (post-command-idle-hook edebug-outside-post-command-idle-hook) | 3551 (post-command-idle-hook edebug-outside-post-command-idle-hook) |
| 3585 | 3552 |
| 3617 edebug-outside-last-nonmenu-event last-nonmenu-event | 3584 edebug-outside-last-nonmenu-event last-nonmenu-event |
| 3618 edebug-outside-track-mouse track-mouse | 3585 edebug-outside-track-mouse track-mouse |
| 3619 edebug-outside-standard-output standard-output | 3586 edebug-outside-standard-output standard-output |
| 3620 edebug-outside-standard-input standard-input | 3587 edebug-outside-standard-input standard-input |
| 3621 | 3588 |
| 3622 edebug-outside-executing-macro executing-kbd-macro | 3589 edebug-outside-executing-macro executing-macro |
| 3623 edebug-outside-defining-kbd-macro defining-kbd-macro | 3590 edebug-outside-defining-kbd-macro defining-kbd-macro |
| 3624 edebug-outside-pre-command-hook pre-command-hook | 3591 edebug-outside-pre-command-hook pre-command-hook |
| 3625 edebug-outside-post-command-hook post-command-hook | 3592 edebug-outside-post-command-hook post-command-hook |
| 3626 edebug-outside-post-command-idle-hook post-command-idle-hook | 3593 edebug-outside-post-command-idle-hook post-command-idle-hook |
| 3627 | 3594 |
| 3646 (edebug-eval edebug-expr) | 3613 (edebug-eval edebug-expr) |
| 3647 (error (edebug-format "%s: %s" ;; could | 3614 (error (edebug-format "%s: %s" ;; could |
| 3648 (get (car edebug-err) 'error-message) | 3615 (get (car edebug-err) 'error-message) |
| 3649 (car (cdr edebug-err)))))) | 3616 (car (cdr edebug-err)))))) |
| 3650 | 3617 |
| 3651 ;;; Printing | 3618 ;;;; Printing |
| 3652 | 3619 ;;; ========= |
| 3653 ;; Replace printing functions. | 3620 ;; Replace printing functions. |
| 3654 | 3621 |
| 3655 ;; obsolete names | 3622 ;; obsolete names |
| 3656 (defalias 'edebug-install-custom-print-funcs 'edebug-install-custom-print) | 3623 (defalias 'edebug-install-custom-print-funcs 'edebug-install-custom-print) |
| 3657 (defalias 'edebug-reset-print-funcs 'edebug-uninstall-custom-print) | 3624 (defalias 'edebug-reset-print-funcs 'edebug-uninstall-custom-print) |
| 3713 (print-readably nil)) ;; XEmacs uses this. | 3680 (print-readably nil)) ;; XEmacs uses this. |
| 3714 (edebug-prin1-to-string value))) | 3681 (edebug-prin1-to-string value))) |
| 3715 | 3682 |
| 3716 (defun edebug-compute-previous-result (edebug-previous-value) | 3683 (defun edebug-compute-previous-result (edebug-previous-value) |
| 3717 (setq edebug-previous-result | 3684 (setq edebug-previous-result |
| 3718 (if (numberp edebug-previous-value) | 3685 (if (and (numberp edebug-previous-value) |
| 3719 (format "Result: %s" edebug-previous-value) | 3686 (< edebug-previous-value 256) |
| 3687 (>= edebug-previous-value 0)) | |
| 3688 (format "Result: %s = %s" edebug-previous-value | |
| 3689 (single-key-description edebug-previous-value)) | |
| 3720 (if edebug-unwrap-results | 3690 (if edebug-unwrap-results |
| 3721 (setq edebug-previous-value | 3691 (setq edebug-previous-value |
| 3722 (edebug-unwrap* edebug-previous-value))) | 3692 (edebug-unwrap* edebug-previous-value))) |
| 3723 (concat "Result: " | 3693 (concat "Result: " |
| 3724 (edebug-safe-prin1-to-string edebug-previous-value))))) | 3694 (edebug-safe-prin1-to-string edebug-previous-value))))) |
| 3726 (defun edebug-previous-result () | 3696 (defun edebug-previous-result () |
| 3727 "Print the previous result." | 3697 "Print the previous result." |
| 3728 (interactive) | 3698 (interactive) |
| 3729 (message "%s" edebug-previous-result)) | 3699 (message "%s" edebug-previous-result)) |
| 3730 | 3700 |
| 3731 ;;; Read, Eval and Print | 3701 ;;;; Read, Eval and Print |
| 3702 ;;; ===================== | |
| 3732 | 3703 |
| 3733 (defun edebug-eval-expression (edebug-expr) | 3704 (defun edebug-eval-expression (edebug-expr) |
| 3734 "Evaluate an expression in the outside environment. | 3705 "Evaluate an expression in the outside environment. |
| 3735 If interactive, prompt for the expression. | 3706 If interactive, prompt for the expression. |
| 3736 Print result in minibuffer." | 3707 Print result in minibuffer." |
| 3759 ;; princ the string to get rid of quotes. | 3730 ;; princ the string to get rid of quotes. |
| 3760 (princ edebug-result-string) | 3731 (princ edebug-result-string) |
| 3761 (princ "\n") | 3732 (princ "\n") |
| 3762 )) | 3733 )) |
| 3763 | 3734 |
| 3764 ;;; Edebug Minor Mode | 3735 |
| 3736 ;;;; Edebug Minor Mode | |
| 3737 ;;; =============================== | |
| 3765 | 3738 |
| 3766 ;; Global GUD bindings for all emacs-lisp-mode buffers. | 3739 ;; Global GUD bindings for all emacs-lisp-mode buffers. |
| 3767 (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode) | 3740 (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode) |
| 3768 (define-key emacs-lisp-mode-map "\C-x\C-a\C-n" 'edebug-next-mode) | 3741 (define-key emacs-lisp-mode-map "\C-x\C-a\C-n" 'edebug-next-mode) |
| 3769 (define-key emacs-lisp-mode-map "\C-x\C-a\C-c" 'edebug-go-mode) | 3742 (define-key emacs-lisp-mode-map "\C-x\C-a\C-c" 'edebug-go-mode) |
| 3922 edebug-unwrap-results | 3895 edebug-unwrap-results |
| 3923 edebug-global-break-condition | 3896 edebug-global-break-condition |
| 3924 " | 3897 " |
| 3925 (use-local-map edebug-mode-map)) | 3898 (use-local-map edebug-mode-map)) |
| 3926 | 3899 |
| 3927 ;;; edebug eval list mode | 3900 |
| 3928 | 3901 ;;;; edebug eval list mode |
| 3902 ;;; =============================================== | |
| 3929 ;; A list of expressions and their evaluations is displayed in *edebug*. | 3903 ;; A list of expressions and their evaluations is displayed in *edebug*. |
| 3930 | 3904 |
| 3931 (defun edebug-eval-result-list () | 3905 (defun edebug-eval-result-list () |
| 3932 "Return a list of evaluations of edebug-eval-list" | 3906 "Return a list of evaluations of edebug-eval-list" |
| 3933 ;; Assumes in outside environment. | 3907 ;; Assumes in outside environment. |
| 4058 (lisp-interaction-mode) | 4032 (lisp-interaction-mode) |
| 4059 (setq major-mode 'edebug-eval-mode) | 4033 (setq major-mode 'edebug-eval-mode) |
| 4060 (setq mode-name "Edebug-Eval") | 4034 (setq mode-name "Edebug-Eval") |
| 4061 (use-local-map edebug-eval-mode-map)) | 4035 (use-local-map edebug-eval-mode-map)) |
| 4062 | 4036 |
| 4063 ;;; Interface with standard debugger. | 4037 |
| 4038 ;;;; Interface with standard debugger. | |
| 4039 ;;; ======================================== | |
| 4064 | 4040 |
| 4065 ;; (setq debugger 'edebug) ; to use the edebug debugger | 4041 ;; (setq debugger 'edebug) ; to use the edebug debugger |
| 4066 ;; (setq debugger 'debug) ; use the standard debugger | 4042 ;; (setq debugger 'debug) ; use the standard debugger |
| 4067 | 4043 |
| 4068 ;; Note that debug and its utilities must be byte-compiled to work, | 4044 ;; Note that debug and its utilities must be byte-compiled to work, |
| 4137 (delete-region last-ok-point (point)) | 4113 (delete-region last-ok-point (point)) |
| 4138 ))) | 4114 ))) |
| 4139 ))))) | 4115 ))))) |
| 4140 | 4116 |
| 4141 | 4117 |
| 4142 ;;; Trace display | 4118 ;;;; Trace display |
| 4119 ;; =============================== | |
| 4143 | 4120 |
| 4144 (defun edebug-trace-display (buf-name fmt &rest args) | 4121 (defun edebug-trace-display (buf-name fmt &rest args) |
| 4145 "In buffer BUF-NAME, display FMT and ARGS at the end and make it visible. | 4122 "In buffer BUF-NAME, display FMT and ARGS at the end and make it visible. |
| 4146 The buffer is created if it does not exist. | 4123 The buffer is created if it does not exist. |
| 4147 You must include newlines in FMT to break lines, but one newline is appended." | 4124 You must include newlines in FMT to break lines, but one newline is appended." |
| 4148 ;; e.g. | 4125 ;; e.g. |
| 4149 ;; (edebug-trace-display "*trace-point*" | 4126 ;; (edebug-trace-display "*trace-point*" |
| 4150 ;; "saving: point = %s window-start = %s" | 4127 ;; "saving: point = %s window-start = %s" |
| 4151 ;; (point) (window-start)) | 4128 ;; (point) (window-start)) |
| 4152 (let* ((oldbuf (current-buffer)) | 4129 (let* ((selected-window (selected-window)) |
| 4153 (selected-window (selected-window)) | |
| 4154 (buffer (get-buffer-create buf-name)) | 4130 (buffer (get-buffer-create buf-name)) |
| 4155 buf-window) | 4131 buf-window) |
| 4156 ;; (message "before pop-to-buffer") (sit-for 1) | 4132 ;; (message "before pop-to-buffer") (sit-for 1) |
| 4157 (edebug-pop-to-buffer buffer) | 4133 (edebug-pop-to-buffer buffer) |
| 4158 (setq truncate-lines t) | 4134 (setq truncate-lines t) |
| 4164 (set-window-start buf-window (point)) | 4140 (set-window-start buf-window (point)) |
| 4165 (goto-char (point-max)) | 4141 (goto-char (point-max)) |
| 4166 ;; (set-window-point buf-window (point)) | 4142 ;; (set-window-point buf-window (point)) |
| 4167 ;; (edebug-sit-for 0) | 4143 ;; (edebug-sit-for 0) |
| 4168 (bury-buffer buffer) | 4144 (bury-buffer buffer) |
| 4169 (select-window selected-window) | 4145 (select-window selected-window)) |
| 4170 (set-buffer oldbuf)) | |
| 4171 buf-name) | 4146 buf-name) |
| 4172 | 4147 |
| 4173 | 4148 |
| 4174 (defun edebug-trace (fmt &rest args) | 4149 (defun edebug-trace (fmt &rest args) |
| 4175 "Convenience call to edebug-trace-display using edebug-trace-buffer" | 4150 "Convenience call to edebug-trace-display using edebug-trace-buffer" |
| 4176 (apply 'edebug-trace-display edebug-trace-buffer fmt args)) | 4151 (apply 'edebug-trace-display edebug-trace-buffer fmt args)) |
| 4177 | 4152 |
| 4178 | 4153 |
| 4179 ;;; Frequency count and coverage | 4154 ;;;; Frequency count and coverage |
| 4155 ;;; ============================== | |
| 4180 | 4156 |
| 4181 (defun edebug-display-freq-count () | 4157 (defun edebug-display-freq-count () |
| 4182 "Display the frequency count data for each line of the current | 4158 "Display the frequency count data for each line of the current |
| 4183 definition. The frequency counts are inserted as comment lines after | 4159 definition. The frequency counts are inserted as comment lines after |
| 4184 each line, and you can undo all insertions with one `undo' command. | 4160 each line, and you can undo all insertions with one `undo' command. |
| 4257 (edebug-display-freq-count) | 4233 (edebug-display-freq-count) |
| 4258 (setq unread-command-char (read-char)) | 4234 (setq unread-command-char (read-char)) |
| 4259 (undo))) | 4235 (undo))) |
| 4260 | 4236 |
| 4261 | 4237 |
| 4262 ;;; Menus | 4238 ;;;; Menus |
| 4239 ;;;========= | |
| 4263 | 4240 |
| 4264 (defun edebug-toggle (variable) | 4241 (defun edebug-toggle (variable) |
| 4265 (set variable (not (eval variable))) | 4242 (set variable (not (eval variable))) |
| 4266 (message "%s: %s" variable (eval variable))) | 4243 (message "%s: %s" variable (eval variable))) |
| 4267 | 4244 |
| 4324 (edebug-toggle 'edebug-save-displayed-buffer-points) t] | 4301 (edebug-toggle 'edebug-save-displayed-buffer-points) t] |
| 4325 )) | 4302 )) |
| 4326 "XEmacs style menus for Edebug.") | 4303 "XEmacs style menus for Edebug.") |
| 4327 | 4304 |
| 4328 | 4305 |
| 4329 ;;; Emacs version specific code | 4306 ;;;; Emacs version specific code |
| 4330 | 4307 ;;;============================= |
| 4331 ;;; The default for all above is Emacs 18, because it is easier to compile | 4308 ;;; The default for all above is Emacs 18, because it is easier to compile |
| 4332 ;;; Emacs 18 code in Emacs 19 than vice versa. This default will | 4309 ;;; Emacs 18 code in Emacs 19 than vice versa. This default will |
| 4333 ;;; change once most people are using Emacs 19 or derivatives. | 4310 ;;; change once most people are using Emacs 19 or derivatives. |
| 4334 | 4311 |
| 4335 ;; Epoch specific code is in a separate file: edebug-epoch.el. | 4312 ;; Epoch specific code is in a separate file: edebug-epoch.el. |
| 4336 | 4313 |
| 4337 ;; The byte-compiler will complain about changes in number of arguments | 4314 ;; The byte-compiler will complain about changes in number of arguments |
| 4338 ;; to functions like mark and read-from-minibuffer. These warnings | 4315 ;; to functions like mark and read-from-minibuffer. These warnings |
| 4339 ;; may be ignored because the right call should always be made. | 4316 ;; may be ignored because the right call should always be made. |
| 4391 (edebug-outside-excursion | 4368 (edebug-outside-excursion |
| 4392 (setq values (cons (edebug-eval edebug-expr) values)) | 4369 (setq values (cons (edebug-eval edebug-expr) values)) |
| 4393 (edebug-safe-prin1-to-string (car values))))) | 4370 (edebug-safe-prin1-to-string (car values))))) |
| 4394 | 4371 |
| 4395 (easy-menu-define edebug-menu edebug-mode-map "Edebug menus" edebug-mode-menus) | 4372 (easy-menu-define edebug-menu edebug-mode-map "Edebug menus" edebug-mode-menus) |
| 4396 (if (eq (console-type) 'x) ; XEmacs | 4373 (if window-system |
| 4397 (x-popup-menu nil (lookup-key edebug-mode-map [menu-bar Edebug]))) | 4374 (x-popup-menu nil (lookup-key edebug-mode-map [menu-bar Edebug]))) |
| 4398 ) | 4375 ) |
| 4399 | 4376 |
| 4400 | 4377 |
| 4401 (defun edebug-xemacs-specific () | 4378 (defun edebug-xemacs-specific () |
| 4435 (edebug-emacs-19-specific)))) | 4412 (edebug-emacs-19-specific)))) |
| 4436 | 4413 |
| 4437 (edebug-emacs-version-specific) | 4414 (edebug-emacs-version-specific) |
| 4438 | 4415 |
| 4439 | 4416 |
| 4440 ;;; Byte-compiler | 4417 ;;;; Byte-compiler |
| 4441 | 4418 ;;; ==================== |
| 4442 ;; Extension for bytecomp to resolve undefined function references. | 4419 ;; Extension for bytecomp to resolve undefined function references. |
| 4443 ;; Requires new byte compiler. | 4420 ;; Requires new byte compiler. |
| 4444 | 4421 |
| 4445 ;; Reenable byte compiler warnings about unread-command-char and -event. | 4422 ;; Reenable byte compiler warnings about unread-command-char and -event. |
| 4446 ;; Disabled before edebug-recursive-edit. | 4423 ;; Disabled before edebug-recursive-edit. |
| 4506 ;; XEmacs | 4483 ;; XEmacs |
| 4507 zmacs-deactivate-region | 4484 zmacs-deactivate-region |
| 4508 popup-menu | 4485 popup-menu |
| 4509 ;; CL | 4486 ;; CL |
| 4510 cl-macroexpand-all | 4487 cl-macroexpand-all |
| 4511 ;; And believe it or not, the byte compiler doesn't know about: | 4488 ;; And believe it or not, the byte compiler doesnt know about: |
| 4512 byte-compile-resolve-functions | 4489 byte-compile-resolve-functions |
| 4513 )) | 4490 )) |
| 4514 | 4491 |
| 4515 '(byte-compile-resolve-free-references | 4492 '(byte-compile-resolve-free-references |
| 4516 '(read-expression-history | 4493 '(read-expression-history |
| 4520 '(read-expression-history)) | 4497 '(read-expression-history)) |
| 4521 | 4498 |
| 4522 ))) | 4499 ))) |
| 4523 | 4500 |
| 4524 | 4501 |
| 4525 ;;; Autoloading of Edebug accessories | 4502 ;;;; Autoloading of Edebug accessories |
| 4503 ;;;=================================== | |
| 4526 | 4504 |
| 4527 (if (featurep 'cl) | 4505 (if (featurep 'cl) |
| 4528 (add-hook 'edebug-setup-hook | 4506 (add-hook 'edebug-setup-hook |
| 4529 (function (lambda () (require 'cl-specs)))) | 4507 (function (lambda () (require 'cl-specs)))) |
| 4530 ;; The following causes cl-specs to be loaded if you load cl.el. | 4508 ;; The following causes cl-specs to be loaded if you load cl.el. |
| 4538 ;; The following causes edebug-cl-read to be loaded when you load cl-read.el. | 4516 ;; The following causes edebug-cl-read to be loaded when you load cl-read.el. |
| 4539 (add-hook 'cl-read-load-hooks | 4517 (add-hook 'cl-read-load-hooks |
| 4540 (function (lambda () (require 'edebug-cl-read))))) | 4518 (function (lambda () (require 'edebug-cl-read))))) |
| 4541 | 4519 |
| 4542 | 4520 |
| 4543 ;;; Finalize Loading | 4521 ;;;; Finalize Loading |
| 4522 ;;;=================== | |
| 4544 | 4523 |
| 4545 ;;; Finally, hook edebug into the rest of Emacs. | 4524 ;;; Finally, hook edebug into the rest of Emacs. |
| 4546 ;;; There are probably some other things that could go here. | 4525 ;;; There are probably some other things that could go here. |
| 4547 | 4526 |
| 4548 ;; Install edebug read and eval functions. | 4527 ;; Install edebug read and eval functions. |
| 4549 (edebug-install-read-eval-functions) | 4528 (edebug-install-read-eval-functions) |
| 4550 | 4529 |
| 4551 (provide 'edebug) | 4530 (provide 'edebug) |
| 4552 | 4531 |
| 4553 ;;; edebug.el ends here | 4532 ;;; edebug.el ends here |
| 4533 | |
| 4534 |
