• Gemini Lasswell's avatar
    Add backtrace-mode and use it in the debugger, ERT and Edebug · e09120d6
    Gemini Lasswell authored
    * doc/lispref/debugging.texi (Using Debugger): Remove explanation of
    backtrace buffer.  Refer to new node.
    (Backtraces): New node.
    (Debugger Commands): Refer to new node.  Remove 'v'.
    * doc/lispref/edebug.texi (Edebug Misc): Refer to new node.
    * doc/misc/ert.texi (Running Tests Interactively): Refer to new node.
    
    * lisp/emacs-lisp-backtrace.el: New file.
    * test/lisp/emacs-lisp/backtrace-tests.el: New file.
    
    * lisp/emacs-lisp/debug.el: (debugger-buffer-state): New cl-defstruct.
    (debugger--restore-buffer-state): New function.
    (debug): Use a debugger-buffer-state object to save and restore buffer
    state.  Fix bug#15749 by leaving an unused buffer in debugger-mode,
    empty, instead of in fundamental-mode, and then when reusing a buffer,
    not calling debugger-mode if the buffer is already in debugger-mode.
    (debugger-insert-backtrace): Remove.
    (debugger-setup-buffer): Use backtrace-mode.
    (debugger--insert-header): New function.
    (debugger-continue, debugger-return-value): Change check for flags to
    use backtrace-frames.
    (debugger-frame-number): Determine backtrace frame number from
    backtrace-frames.
    (debugger--locals-visible-p, debugger--insert-locals)
    (debugger--show-locals, debugger--hide-locals)
    (debugger-toggle-locals): Remove.
    (debugger-mode-map): Make a child of backtrace-mode-map.  Move
    navigation commands to backtrace-mode-map.  Bind 'q' to debugger-quit
    instead of top-level.  Make Help Follow menu item call
    backtrace-help-follow-symbol.
    (debugger-mode): Derive from backtrace-mode.
    (debug-help-follow): Remove.  Move body of this function to
    'backtrace-help-follow-symbol' in backtrace.el.
    (debugger-quit): New function.
    
    * lisp/emacs-lisp/edebug.el (edebug-unwrap-results): Remove warning
    in docstring about circular results.
    (edebug-unwrap): Use pcase.
    (edebug-unwrap1): New function to unwrap circular objects.
    (edebug-unwrap*): Use it.
    (edebug--frame): New cl-defstruct.
    (edebug-backtrace): Call the buffer *Edebug Backtrace* and use
    backtrace-mode.  Get the frames from edebug--backtrace-frames.
    (edebug--backtrace-frames, edebug--unwrap-and-add-info)
    (edebug--symbol-not-prefixed-p): New functions.
    
    * lisp/emacs-lisp/lisp-mode.el
    (lisp-el-font-lock-keywords-for-backtraces)
    (lisp-el-font-lock-keywords-for-backtraces-1)
    (lisp-el-font-lock-keywords-for-backtraces-2): New constants.
    
    * lisp/emacs-lisp/ert.el (ert--print-backtrace): Remove.
    (ert--run-test-debugger): Use backtrace-get-frames.
    (ert-run-tests-batch): Use backtrace-to-string.
    (ert-results-pop-to-backtrace-for-test-at-point): Use backtrace-mode.
    (ert--insert-backtrace-header): New function.
    
    * tests/lisp/emacs-lisp/ert-tests.el (ert-test--which-file):
    Use backtrace-frame slot accessor.
    e09120d6
debugging.texi 42.1 KB