Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/lisp/edebug/edebug.el Mon Aug 13 09:00:04 2007 +0200 +++ b/lisp/edebug/edebug.el Mon Aug 13 09:02:59 2007 +0200 @@ -5,100 +5,97 @@ ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> ;; Keywords: lisp, tools, maint -;; This file is part of XEmacs. - -;; XEmacs is free software; you can redistribute it and/or modify it -;; under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; XEmacs is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with XEmacs; see the file COPYING. If not, write to the Free -;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -;; 02111-1307, USA. - -;;; Synched up with: FSF 19.34. - -;;; Commentary: - ;; LCD Archive Entry: ;; edebug|Daniel LaLiberte|liberte@cs.uiuc.edu ;; |A source level debugger for Emacs Lisp. -;; |$Date: 1997/08/21 06:23:41 $|$Revision: 1.3 $|~/modes/edebug.el| - -;; This minor mode allows programmers to step through Emacs Lisp -;; source code while executing functions. You can also set -;; breakpoints, trace (stopping at each expression), evaluate -;; expressions as if outside Edebug, reevaluate and display a list of -;; expressions, trap errors normally caught by debug, and display a -;; debug style backtrace. - -;;; Installation -;; ============= - -;; Put edebug.el in some directory in your load-path and -;; byte-compile it. Also read the beginning of edebug-epoch.el, -;; cl-specs.el, and edebug-cl-read.el if they apply to you. - -;; Unless you are using Emacs 19 which is already set up to use Edebug, -;; put the following forms in your .emacs file. -;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form) -;; (autoload 'edebug-eval-top-level-form "edebug") - -;; If you wish to change the default edebug global command prefix, change: -;; (setq edebug-global-prefix "\C-xX") - -;; Other options, are described in the manual. - -;; In previous versions of Edebug, users were directed to set -;; `debugger' to `edebug-debug'. This is no longer necessary -;; since Edebug automatically sets it whenever Edebug is active. - -;;; Minimal Instructions -;; ===================== - -;; First evaluate a defun with C-xx, then run the function. Step -;; through the code with SPC, mark breakpoints with b, go until a -;; breakpoint is reached with g, and quit execution with q. Use the -;; "?" command in edebug to describe other commands. See edebug.tex -;; or the Emacs 19 Lisp Reference Manual for more instructions. - -;; Send me your enhancements, ideas, bugs, or fixes. -;; For bugs, you can call edebug-submit-bug-report if you have reporter.el. -;; There is an edebug mailing list if you want to keep up -;; with the latest developments. Requests to: edebug-request@cs.uiuc.edu - -;; Daniel LaLiberte 217-398-4114 -;; University of Illinois, Urbana-Champaign -;; Department of Computer Science -;; 1304 W Springfield -;; Urbana, IL 61801 - -;; uiucdcs!liberte -;; liberte@cs.uiuc.edu - -;; For the early revision history, see edebug-history. - -;;; Code: +;; |$Date: 1996/12/18 22:43:07 $|$Revision: 1.1.1.1 $|~/modes/edebug.el| + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +;;;; Commentary: + +;;; This minor mode allows programmers to step through Emacs Lisp +;;; source code while executing functions. You can also set +;;; breakpoints, trace (stopping at each expression), evaluate +;;; expressions as if outside Edebug, reevaluate and display a list of +;;; expressions, trap errors normally caught by debug, and display a +;;; debug style backtrace. + +;;;; Installation +;;; ============= + +;;; Put edebug.el in some directory in your load-path and +;;; byte-compile it. Also read the beginning of edebug-epoch.el, +;;; cl-specs.el, and edebug-cl-read.el if they apply to you. + +;;; Unless you are using Emacs 19 which is already set up to use Edebug, +;;; put the following forms in your .emacs file. +;;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form) +;;; (autoload 'edebug-eval-top-level-form "edebug") + +;;; If you wish to change the default edebug global command prefix, change: +;;; (setq edebug-global-prefix "\C-xX") + +;;; Other options, are described in the manual. + +;;; In previous versions of Edebug, users were directed to set +;;; `debugger' to `edebug-debug'. This is no longer necessary +;;; since Edebug automatically sets it whenever Edebug is active. + +;;;; Minimal Instructions +;;; ===================== + +;;; First evaluate a defun with C-xx, then run the function. Step +;;; through the code with SPC, mark breakpoints with b, go until a +;;; breakpoint is reached with g, and quit execution with q. Use the +;;; "?" command in edebug to describe other commands. See edebug.tex +;;; or the Emacs 19 Lisp Reference Manual for more instructions. + +;;; Send me your enhancements, ideas, bugs, or fixes. +;;; For bugs, you can call edebug-submit-bug-report if you have reporter.el. +;;; There is an edebug mailing list if you want to keep up +;;; with the latest developments. Requests to: edebug-request@cs.uiuc.edu + +;;; Daniel LaLiberte 217-398-4114 +;;; University of Illinois, Urbana-Champaign +;;; Department of Computer Science +;;; 1304 W Springfield +;;; Urbana, IL 61801 + +;;; uiucdcs!liberte +;;; liberte@cs.uiuc.edu + +;;; =============================== +;;; For the early revision history, see edebug-history. (defconst edebug-version - (let ((raw-version "$Revision: 1.3 $")) + (let ((raw-version "$Revision: 1.1.1.1 $")) (substring raw-version (string-match "[0-9.]*" raw-version) (match-end 0)))) (require 'backquote) -;; Emacs 18 doesn't have defalias. +;; Emacs 18 doesnt have defalias. (eval-and-compile (or (fboundp 'defalias) (fset 'defalias 'fset))) -;;; Bug reporting +;;;; Bug reporting +;;; ============== (defconst edebug-maintainer-address "liberte@cs.uiuc.edu") @@ -126,7 +123,9 @@ 'edebug-print-circle )))) -;;; Options + +;;;; Options +;;; =============================== (defvar edebug-setup-hook nil "*Functions to call before edebug is used. @@ -248,7 +247,9 @@ "*If non-nil, an expression to test for at every stop point. If the result is non-nil, then break. Errors are ignored.") -;;; Form spec utilities. + +;;;; Form spec utilities. +;;; =============================== ;;;###autoload (defmacro def-edebug-spec (symbol spec) @@ -273,7 +274,9 @@ edebug-form-spec )) -;;; Utilities + +;;;; Utilities +;;; =============================== ;; Define edebug-gensym - from old cl.el (defvar edebug-gensym-index 0 @@ -322,7 +325,7 @@ (defun edebug-window-list () "Return a list of windows, in order of `next-window'." - ;; This doesn't work for epoch. + ;; This doesnt work for epoch. (let* ((first-window (selected-window)) (window-list (list first-window)) (next (next-window first-window))) @@ -364,7 +367,7 @@ "Returns the function named by OBJECT, or nil if it is not a function." (setq object (edebug-lookup-function object)) (if (or (subrp object) - (compiled-function-p object) ; XEmacs + (byte-code-function-p object) (and (listp object) (eq (car object) 'lambda) (listp (car (cdr object))))) @@ -395,7 +398,8 @@ (set-buffer (marker-buffer edebug:s-r-beg)) (narrow-to-region edebug:s-r-beg edebug:s-r-end)))))) -;;; Display +;;;; Display +;;; ============ (defconst edebug-trace-buffer "*edebug-trace*" "Name of the buffer to put trace info in.") @@ -417,7 +421,7 @@ (split-window)) ;; (message "next window: %s" (next-window)) (sit-for 1) (if (eq (get-buffer-window edebug-trace-buffer) (next-window)) - ;; Don't select trace window + ;; Dont select trace window nil (select-window (next-window)))) (set-window-buffer (selected-window) buffer) @@ -489,11 +493,12 @@ (defalias 'edebug-input-pending-p 'input-pending-p) -;;; Redefine read and eval functions -;; read is redefined to maybe instrument forms. -;; eval-defun is redefined to check edebug-all-forms and edebug-all-defs. - -;; Use the Lisp version of eval-region. +;;;; Redefine read and eval functions +;;; ================================= +;;; read is redefined to maybe instrument forms. +;;; eval-defun is redefined to check edebug-all-forms and edebug-all-defs. + +;;; Use the Lisp version of eval-region. (require 'eval-reg "eval-reg") ;; Save the original read function @@ -512,7 +517,7 @@ t (read text line using minibuffer and use it). This version, from Edebug, maybe instruments the expression. But the -STREAM must be the current buffer to do so. Whether it instruments is +STREAM must be the current buffer to do so. Whether it instuments is also dependent on the values of `edebug-all-defs' and `edebug-all-forms'." (or stream (setq stream standard-input)) @@ -523,8 +528,6 @@ (or (fboundp 'edebug-original-eval-defun) (defalias 'edebug-original-eval-defun (symbol-function 'eval-defun))) -;; We should somehow arrange to be able to do this -;; without actually replacing the eval-defun command. (defun edebug-eval-defun (edebug-it) "Evaluate the top-level form containing point, or after point. @@ -534,16 +537,13 @@ argument. If instrumenting, it prints: `Edebug: FUNCTIONNAME'. Otherwise, it prints in the minibuffer." (interactive "P") - (let* ((edebugging (not (eq (not edebug-it) (not edebug-all-defs)))) - (edebug-result) - (form - (let ((edebug-all-forms edebugging) - (edebug-all-defs (eq edebug-all-defs (not edebug-it)))) - (edebug-read-top-level-form)))) - (if (and (eq (car form) 'defvar) - (cdr-safe (cdr-safe form))) - (setq form (cons 'defconst (cdr form)))) - (setq edebug-result (eval form)) + (let ((edebugging (not (eq (not edebug-it) (not edebug-all-defs)))) + (edebug-result)) + (setq edebug-result + (eval + (let ((edebug-all-forms edebugging) + (edebug-all-defs (eq edebug-all-defs (not edebug-it)))) + (edebug-read-top-level-form)))) (if (not edebugging) (princ edebug-result) edebug-result))) @@ -560,7 +560,7 @@ or if an error occurs, leave point after it with mark at the original point." (interactive) (eval - ;; Bind edebug-all-forms only while reading, not while evalling + ;; Bind edebug-all-forms only while reading, not while evaling ;; but this causes problems while edebugging edebug. (let ((edebug-all-forms t) (edebug-all-defs t)) @@ -611,10 +611,11 @@ (defalias 'eval-defun (symbol-function 'edebug-original-eval-defun))) -;;; Edebug internal data - -;; The internal data that is needed for edebugging is kept in the -;; buffer-local variable `edebug-form-data'. +;;;; Edebug internal data +;;; =============================== + +;;; The internal data that is needed for edebugging is kept in the +;;; buffer-local variable `edebug-form-data'. ;; XEmacs change? (defconst edebug-form-data nil) @@ -696,7 +697,10 @@ ;; (set-marker (nth 2 entry) nil) (setq edebug-form-data (delq entry edebug-form-data))))) -;;; Parser utilities + +;;;; Parser utilities +;;; =============================== + (defun edebug-syntax-error (&rest args) ;; Signal an invalid-read-syntax with ARGS. @@ -714,8 +718,6 @@ (aset table ?\( 'lparen) (aset table ?\) 'rparen) (aset table ?\' 'quote) - (aset table ?\` 'backquote) - (aset table ?\, 'comma) (aset table ?\" 'string) (aset table ?\? 'char) (aset table ?\[ 'lbracket) @@ -723,13 +725,12 @@ (aset table ?\. 'dot) (aset table ?\# 'hash) ;; We treat numbers as symbols, because of confusion with -, -1, and 1-. - ;; We don't care about any other chars since they won't be seen. + ;; We dont care about any other chars since they wont be seen. table)) (defun edebug-next-token-class () ;; Move to the next token and return its class. We only care about - ;; lparen, rparen, dot, quote, backquote, comma, string, char, vector, - ;; or symbol. + ;; lparen, rparen, dot, quote, string, char, vector, or symbol. (edebug-skip-whitespace) (aref edebug-read-syntax-table (following-char))) @@ -766,14 +767,12 @@ (forward-char -1)))) ((eq class 'quote) (forward-char 1) (list 'quote (edebug-read-sexp))) - ((eq class 'backquote) - (list '\` (edebug-read-sexp))) - ((eq class 'comma) - (list '\, (edebug-read-sexp))) (t ; anything else, just read it. (edebug-original-read (current-buffer)))))) -;;; Offsets for reader + +;;;; Offsets for reader +;;; ============================== ;; Define a structure to represent offset positions of expressions. ;; Each offset structure looks like: (before . after) for constituents, @@ -848,8 +847,8 @@ (edebug-store-after-offset (point))))) -;;; Reader for Emacs Lisp. - +;;;; Reader for Emacs Lisp. +;;; ========================================== ;; Uses edebug-next-token-class (and edebug-skip-whitespace) above. (defconst edebug-read-alist @@ -857,8 +856,6 @@ (lparen . edebug-read-list) (string . edebug-read-string) (quote . edebug-read-quote) - (backquote . edebug-read-backquote) - (comma . edebug-read-comma) (lbracket . edebug-read-vector) (hash . edebug-read-function) )) @@ -895,42 +892,6 @@ (edebug-storing-offsets (point) 'quote) (edebug-read-storing-offsets stream))) -(defun edebug-read-backquote (stream) - ;; Turn `thing into (\` thing) - (let ((opoint (point))) - (forward-char 1) - ;; Generate the same structure of offsets we would have - ;; if the resulting list appeared verbatim in the input text. - (edebug-storing-offsets opoint - (list - (edebug-storing-offsets opoint '\`) - (edebug-read-storing-offsets stream))))) - -(defvar edebug-read-backquote-new nil - "Non-nil if reading the inside of a new-style backquote with no parens around it. -Value of nil means reading the inside of an old-style backquote construct -which is surrounded by an extra set of parentheses. -This controls how we read comma constructs.") - -(defun edebug-read-comma (stream) - ;; Turn ,thing into (\, thing). Handle ,@ and ,. also. - (let ((opoint (point))) - (forward-char 1) - (let ((symbol '\,)) - (cond ((eq (following-char) ?\.) - (setq symbol '\,\.) - (forward-char 1)) - ((eq (following-char) ?\@) - (setq symbol '\,@) - (forward-char 1))) - ;; Generate the same structure of offsets we would have - ;; if the resulting list appeared verbatim in the input text. - (if edebug-read-backquote-new - (list - (edebug-storing-offsets opoint symbol) - (edebug-read-storing-offsets stream)) - (edebug-storing-offsets opoint symbol))))) - (defun edebug-read-function (stream) ;; Turn #'thing into (function thing) (forward-char 1) @@ -946,18 +907,7 @@ (prog1 (let ((elements)) (while (not (memq (edebug-next-token-class) '(rparen dot))) - (if (eq (edebug-next-token-class) 'backquote) - (let ((edebug-read-backquote-new (not (null elements))) - (opoint (point))) - (if edebug-read-backquote-new - (setq elements (cons (edebug-read-backquote stream) elements)) - (forward-char 1) ; Skip backquote. - ;; Call edebug-storing-offsets here so that we - ;; produce the same offsets we would have had - ;; if the backquote were an ordinary symbol. - (setq elements (cons (edebug-storing-offsets opoint '\`) - elements)))) - (setq elements (cons (edebug-read-storing-offsets stream) elements)))) + (setq elements (cons (edebug-read-storing-offsets stream) elements))) (setq elements (nreverse elements)) (if (eq 'dot (edebug-next-token-class)) (let (dotted-form) @@ -982,7 +932,10 @@ (forward-char 1) ; skip \] )) -;;; Cursors for traversal of list and vector elements with offsets. + + +;;;; Cursors for traversal of list and vector elements with offsets. +;;;==================================================================== (defvar edebug-dotted-spec nil) @@ -1059,28 +1012,29 @@ (setq offset (cdr offset))) offset)) -;;; The Parser - -;; The top level function for parsing forms is -;; edebug-read-and-maybe-wrap-form; it calls all the rest. It checks the -;; syntax a bit and leaves point at any error it finds, but otherwise -;; should appear to work like eval-defun. - -;; The basic plan is to surround each expression with a call to -;; the edebug debugger together with indexes into a table of positions of -;; all expressions. Thus an expression "exp" becomes: - -;; (edebug-after (edebug-before 1) 2 exp) - -;; When this is evaluated, first point is moved to the beginning of -;; exp at offset 1 of the current function. The expression is -;; evaluated, which may cause more edebug calls, and then point is -;; moved to offset 2 after the end of exp. - -;; The highest level expressions of the function are wrapped in a call to -;; edebug-enter, which supplies the function name and the actual -;; arguments to the function. See functions edebug-enter, edebug-before, -;; and edebug-after for more details. +;;;; The Parser +;;; =============================== + +;;; The top level function for parsing forms is +;;; edebug-read-and-maybe-wrap-form; it calls all the rest. It checks the +;;; syntax a bit and leaves point at any error it finds, but otherwise +;;; should appear to work like eval-defun. + +;;; The basic plan is to surround each expression with a call to +;;; the edebug debugger together with indexes into a table of positions of +;;; all expressions. Thus an expression "exp" becomes: + +;;; (edebug-after (edebug-before 1) 2 exp) + +;;; When this is evaluated, first point is moved to the beginning of +;;; exp at offset 1 of the current function. The expression is +;;; evaluated, which may cause more edebug calls, and then point is +;;; moved to offset 2 after the end of exp. + +;;; The highest level expressions of the function are wrapped in a call to +;;; edebug-enter, which supplies the function name and the actual +;;; arguments to the function. See functions edebug-enter, edebug-before, +;;; and edebug-after for more details. ;; Dynamically bound vars, left unbound, but globally declared. ;; This is to quiet the byte compiler. @@ -1111,7 +1065,7 @@ (let (result edebug-top-window-data edebug-def-name;; make sure it is locally nil - ;; I don't like these here!! + ;; I dont like these here!! edebug-&optional edebug-&rest edebug-gate @@ -1135,7 +1089,7 @@ def-kind defining-form-p def-name - ;; These offset things don't belong here, but to support recursive + ;; These offset things dont belong here, but to support recursive ;; calls to edebug-read, they need to be here. edebug-offsets edebug-offsets-stack @@ -1229,7 +1183,7 @@ (quote (, edebug-def-name)) (, (if edebug-inside-func (` (list (,@ - ;; Doesn't work with more than one def-body!! + ;; Doesnt work with more than one def-body!! ;; But the list will just be reversed. (nreverse edebug-def-args)))) 'nil)) @@ -1258,7 +1212,7 @@ ;; (edebug-after (edebug-before BEFORE-INDEX) AFTER-INDEX FORM) ;; Also increment the offset index for subsequent use. ;; if (not edebug-stop-before-symbols) and form is a symbol, - ;; then don't call edebug-before. + ;; then dont call edebug-before. (list 'edebug-after (list 'edebug-before before-index) after-index form)) @@ -1447,7 +1401,7 @@ ((symbolp form) (cond - ;; Check for constant symbols that don't get wrapped. + ;; Check for constant symbols that dont get wrapped. ((or (memq form '(t nil)) (and (fboundp 'edebug-keywordp) (edebug-keywordp form))) form) @@ -1536,7 +1490,9 @@ "Head of list form must be a symbol or lambda expression."))) )) -;;; Matching of specs. + +;;;; Matching of specs. +;;; =================== (defvar edebug-after-dotted-spec nil) @@ -1544,8 +1500,8 @@ (defconst edebug-max-depth 150) ;; maximum number of matching recursions. -;;; Failure to match - +;;;; Failure to match +;;; ================== ;; This throws to no-match, if there are higher alternatives. ;; Otherwise it signals an error. The place of the error is found ;; with the two before- and after-offset functions. @@ -1633,7 +1589,7 @@ ;; Define specs for all the symbol specs with functions used to process them. -;; Perhaps we shouldn't be doing this with edebug-form-specs since the +;; Perhaps we shouldnt be doing this with edebug-form-specs since the ;; user may want to define macros or functions with the same names. ;; We could use an internal obarray for these primitive specs. @@ -1751,7 +1707,7 @@ (let (edebug-gate ;; only while matching each spec edebug-best-error edebug-error-point) - ;; Doesn't support e.g. &or symbolp &rest form + ;; Doesnt support e.g. &or symbolp &rest form (edebug-match-one-spec cursor (car specs))))) ;; Match failed, so reset and try again. (setq specs (cdr specs)) @@ -1780,7 +1736,7 @@ (defun edebug-match-&key (cursor specs) ;; Following specs must look like (<name> <spec>) ... ;; where <name> is the name of a keyword, and spec is its spec. - ;; This really doesn't save much over the expanded form and takes time. + ;; This really doesnt save much over the expanded form and takes time. (edebug-match-&rest cursor (cons '&or @@ -1884,7 +1840,7 @@ (defun edebug-match-&define (cursor specs) ;; Match a defining form. - ;; Normally, &define is interpreted specially other places. + ;; Normally, &define is interpretted specially other places. ;; This should only be called inside of a spec list to match the remainder ;; of the current list. e.g. ("lambda" &define args def-body) (edebug-make-form-wrapper @@ -2006,7 +1962,7 @@ )) -;;;* Emacs special forms and some functions. +;;;;* Emacs special forms and some functions. ;; quote expects only one argument, although it allows any number. (def-edebug-spec quote sexp) @@ -2023,7 +1979,7 @@ (def-edebug-spec defmacro (&define name lambda-list def-body)) -(def-edebug-spec arglist lambda-list) ;; deprecated - use lambda-list. +(def-edebug-spec arglist lambda-list) ;; denegrated - use lambda-list. (def-edebug-spec lambda-list (([&rest arg] @@ -2124,6 +2080,7 @@ ;; Anything else? +;;==================== ;; Some miscellaneous specs for macros in public packages. ;; Send me yours. @@ -2141,7 +2098,9 @@ [&optional ("interactive" interactive)] def-body)) -;;; The debugger itself + +;;;; The debugger itself +;;; =============================== (defvar edebug-active nil) ;; Non-nil when edebug is active @@ -2208,6 +2167,7 @@ (defvar cl-lexical-debug) ;; Defined in cl.el ;;; Handling signals +;;; ================= (if (not (fboundp 'edebug-original-signal)) (defalias 'edebug-original-signal (symbol-function 'signal))) @@ -2236,6 +2196,7 @@ ;;; Entering Edebug +;;; ================== (defun edebug-enter (edebug-function edebug-args edebug-body) ;; Entering FUNC. The arguments are ARGS, and the body is BODY. @@ -2266,7 +2227,7 @@ (cl-lexical-debug t) ;; Save the outside value of executing macro. (here??) - (edebug-outside-executing-macro executing-kbd-macro) + (edebug-outside-executing-macro executing-macro) (edebug-outside-pre-command-hook pre-command-hook) (edebug-outside-post-command-hook post-command-hook) (edebug-outside-post-command-idle-hook post-command-idle-hook)) @@ -2274,8 +2235,8 @@ (let (;; Don't keep reading from an executing kbd macro ;; within edebug unless edebug-continue-kbd-macro is ;; non-nil. Again, local binding may not be best. - (executing-kbd-macro - (if edebug-continue-kbd-macro executing-kbd-macro)) + (executing-macro + (if edebug-continue-kbd-macro executing-macro)) ;; Disable command hooks. This is essential when ;; a hook function is instrumented - to avoid infinite loop. @@ -2293,7 +2254,7 @@ (edebug-enter edebug-function edebug-args edebug-body) (fset 'signal (symbol-function 'edebug-original-signal)))) ;; Reset global variables in case outside value was changed. - (setq executing-kbd-macro edebug-outside-executing-macro + (setq executing-macro edebug-outside-executing-macro pre-command-hook edebug-outside-pre-command-hook post-command-hook edebug-outside-post-command-hook post-command-idle-hook edebug-outside-post-command-idle-hook @@ -2552,8 +2513,8 @@ (setq edebug-buffer-points (edebug-get-displayed-buffer-points))) ;; First move the edebug buffer point to edebug-point - ;; so that window start doesn't get changed when we display it. - ;; I don't know if this is going to help. + ;; so that window start doesnt get changed when we display it. + ;; I dont know if this is going to help. ;;(set-buffer edebug-buffer) ;;(goto-char edebug-point) @@ -2648,7 +2609,7 @@ (eq edebug-arg-mode 'error)) (progn ;; (setq edebug-execution-mode 'step) - ;; (edebug-overlay-arrow) ; this doesn't always show up. + ;; (edebug-overlay-arrow) ; this doesnt always show up. (edebug-recursive-edit))) ; <---------- Recursive edit ;; Reset the edebug-window-data to whatever it is now. @@ -2694,7 +2655,7 @@ 'no-force) ;; Unrestore edebug-buffer's window-point. ;; Needed in addition to setting the buffer point - ;; - otherwise quitting doesn't leave point as is. + ;; - otherwise quitting doesnt leave point as is. ;; But this causes point to not be restored at times. ;; Also, it may not be a visible window. ;; (set-window-point window edebug-point) @@ -2714,8 +2675,8 @@ (set-buffer edebug-outside-buffer) ;; Restore point, and mark. ;; Needed even if restoring windows because - ;; that doesn't restore point and mark in the current buffer. - ;; But don't restore point if edebug-buffer is current buffer. + ;; that doesnt restore point and mark in the current buffer. + ;; But dont restore point if edebug-buffer is current buffer. (if (not (eq edebug-buffer edebug-outside-buffer)) (goto-char edebug-outside-point)) (if (marker-buffer (edebug-mark-marker)) @@ -2939,6 +2900,7 @@ ;;; Display related functions +;;; =============================== (defun edebug-adjust-window (old-start) ;; If pos is not visible, adjust current window to fit following context. @@ -3111,7 +3073,9 @@ (message "Displaying %s %s" buffer (if already-displaying "off" "on")))) + ;;; Breakpoint related functions +;;; =============================== (defun edebug-find-stop-point () ;; Return (function . index) of the nearest edebug stop point. @@ -3175,8 +3139,7 @@ (goto-char (+ edebug-def-mark (aref offset-vector (car breakpoint)))) - (message "%s" - (concat (if (nth 2 breakpoint) + (message (concat (if (nth 2 breakpoint) "Temporary " "") (if (car (cdr breakpoint)) (format "Condition: %s" @@ -3271,6 +3234,7 @@ ;;; Mode switching functions +;;; =============================== (defun edebug-set-mode (mode shortmsg msg) ;; Set the edebug mode to MODE. @@ -3495,6 +3459,7 @@ ;; (edebug-set-mode 'exiting "Exit...")) +;;; ----------------------------------------------------------------- ;;; The following initial mode setting definitions are not used yet. '(defconst edebug-initial-mode-alist @@ -3540,7 +3505,9 @@ (error "Key must map to one of the mode changing commands") ))) + ;;; Evaluation of expressions +;;; =============================== (def-edebug-spec edebug-outside-excursion t) @@ -3577,7 +3544,7 @@ (standard-output edebug-outside-standard-output) (standard-input edebug-outside-standard-input) - (executing-kbd-macro edebug-outside-executing-macro) + (executing-macro edebug-outside-executing-macro) (defining-kbd-macro edebug-outside-defining-kbd-macro) (pre-command-hook edebug-outside-pre-command-hook) (post-command-hook edebug-outside-post-command-hook) @@ -3619,7 +3586,7 @@ edebug-outside-standard-output standard-output edebug-outside-standard-input standard-input - edebug-outside-executing-macro executing-kbd-macro + edebug-outside-executing-macro executing-macro edebug-outside-defining-kbd-macro defining-kbd-macro edebug-outside-pre-command-hook pre-command-hook edebug-outside-post-command-hook post-command-hook @@ -3648,8 +3615,8 @@ (get (car edebug-err) 'error-message) (car (cdr edebug-err)))))) -;;; Printing - +;;;; Printing +;;; ========= ;; Replace printing functions. ;; obsolete names @@ -3715,8 +3682,11 @@ (defun edebug-compute-previous-result (edebug-previous-value) (setq edebug-previous-result - (if (numberp edebug-previous-value) - (format "Result: %s" edebug-previous-value) + (if (and (numberp edebug-previous-value) + (< edebug-previous-value 256) + (>= edebug-previous-value 0)) + (format "Result: %s = %s" edebug-previous-value + (single-key-description edebug-previous-value)) (if edebug-unwrap-results (setq edebug-previous-value (edebug-unwrap* edebug-previous-value))) @@ -3728,7 +3698,8 @@ (interactive) (message "%s" edebug-previous-result)) -;;; Read, Eval and Print +;;;; Read, Eval and Print +;;; ===================== (defun edebug-eval-expression (edebug-expr) "Evaluate an expression in the outside environment. @@ -3761,7 +3732,9 @@ (princ "\n") )) -;;; Edebug Minor Mode + +;;;; Edebug Minor Mode +;;; =============================== ;; Global GUD bindings for all emacs-lisp-mode buffers. (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode) @@ -3924,8 +3897,9 @@ " (use-local-map edebug-mode-map)) -;;; edebug eval list mode - + +;;;; edebug eval list mode +;;; =============================================== ;; A list of expressions and their evaluations is displayed in *edebug*. (defun edebug-eval-result-list () @@ -4060,7 +4034,9 @@ (setq mode-name "Edebug-Eval") (use-local-map edebug-eval-mode-map)) -;;; Interface with standard debugger. + +;;;; Interface with standard debugger. +;;; ======================================== ;; (setq debugger 'edebug) ; to use the edebug debugger ;; (setq debugger 'debug) ; use the standard debugger @@ -4139,7 +4115,8 @@ ))))) -;;; Trace display +;;;; Trace display +;; =============================== (defun edebug-trace-display (buf-name fmt &rest args) "In buffer BUF-NAME, display FMT and ARGS at the end and make it visible. @@ -4149,8 +4126,7 @@ ;; (edebug-trace-display "*trace-point*" ;; "saving: point = %s window-start = %s" ;; (point) (window-start)) - (let* ((oldbuf (current-buffer)) - (selected-window (selected-window)) + (let* ((selected-window (selected-window)) (buffer (get-buffer-create buf-name)) buf-window) ;; (message "before pop-to-buffer") (sit-for 1) @@ -4166,8 +4142,7 @@ ;; (set-window-point buf-window (point)) ;; (edebug-sit-for 0) (bury-buffer buffer) - (select-window selected-window) - (set-buffer oldbuf)) + (select-window selected-window)) buf-name) @@ -4176,7 +4151,8 @@ (apply 'edebug-trace-display edebug-trace-buffer fmt args)) -;;; Frequency count and coverage +;;;; Frequency count and coverage +;;; ============================== (defun edebug-display-freq-count () "Display the frequency count data for each line of the current @@ -4259,7 +4235,8 @@ (undo))) -;;; Menus +;;;; Menus +;;;========= (defun edebug-toggle (variable) (set variable (not (eval variable))) @@ -4326,12 +4303,12 @@ "XEmacs style menus for Edebug.") -;;; Emacs version specific code - +;;;; Emacs version specific code +;;;============================= ;;; The default for all above is Emacs 18, because it is easier to compile ;;; Emacs 18 code in Emacs 19 than vice versa. This default will ;;; change once most people are using Emacs 19 or derivatives. - + ;; Epoch specific code is in a separate file: edebug-epoch.el. ;; The byte-compiler will complain about changes in number of arguments @@ -4393,7 +4370,7 @@ (edebug-safe-prin1-to-string (car values))))) (easy-menu-define edebug-menu edebug-mode-map "Edebug menus" edebug-mode-menus) - (if (eq (console-type) 'x) ; XEmacs + (if window-system (x-popup-menu nil (lookup-key edebug-mode-map [menu-bar Edebug]))) ) @@ -4437,8 +4414,8 @@ (edebug-emacs-version-specific) -;;; Byte-compiler - +;;;; Byte-compiler +;;; ==================== ;; Extension for bytecomp to resolve undefined function references. ;; Requires new byte compiler. @@ -4508,7 +4485,7 @@ popup-menu ;; CL cl-macroexpand-all - ;; And believe it or not, the byte compiler doesn't know about: + ;; And believe it or not, the byte compiler doesnt know about: byte-compile-resolve-functions )) @@ -4522,7 +4499,8 @@ ))) -;;; Autoloading of Edebug accessories +;;;; Autoloading of Edebug accessories +;;;=================================== (if (featurep 'cl) (add-hook 'edebug-setup-hook @@ -4540,7 +4518,8 @@ (function (lambda () (require 'edebug-cl-read))))) -;;; Finalize Loading +;;;; Finalize Loading +;;;=================== ;;; Finally, hook edebug into the rest of Emacs. ;;; There are probably some other things that could go here. @@ -4551,3 +4530,5 @@ (provide 'edebug) ;;; edebug.el ends here + +