;; After any frame that uses eval-buffer,
;; insert a line that states the buffer position it's reading at.
(save-excursion
- (while (re-search-forward "^ eval-buffer(" nil t)
- (end-of-line)
- (insert (format " ; Reading at buffer position %d"
- (with-current-buffer
- (or (nth 2 (backtrace-frame (debugger-frame-number)))
- debugger-old-buffer)
- (point)))))
- (while (re-search-forward "^ eval-region(" nil t)
- (end-of-line)
- (insert (format " ; Reading at buffer position %d"
- (with-current-buffer debugger-old-buffer
- (point))))))
+ (let ((tem eval-buffer-list))
+ (while (and tem
+ (re-search-forward "^ eval-\\(buffer\\|region\\)(" nil t))
+ (end-of-line)
+ (insert (format " ; Reading at buffer position %d"
+ ;; This will get the wrong result
+ ;; if there are two nested eval-region calls
+ ;; for the same buffer. That's not a very useful case.
+ (with-current-buffer (car tem)
+ (point))))
+ (pop tem))))
(debugger-make-xrefs))
(defun debugger-make-xrefs (&optional buffer)
(define-key map "e" 'debugger-eval-expression)
(define-key map " " 'next-line)
(define-key map "R" 'debugger-record-expression)
- (define-key map "\C-m" 'help-follow)
+ (define-key map "\C-m" 'debug-help-follow)
(define-key map [mouse-2] 'push-button)
map))
-
+\f
(defcustom debugger-record-buffer "*Debugger-record*"
"*Buffer name for expression values, for \\[debugger-record-expression]."
:type 'string
(buffer-substring (line-beginning-position 0)
(line-end-position 0)))))
+(defun debug-help-follow (&optional pos)
+ "Follow cross-reference at POS, defaulting to point.
+
+For the cross-reference format, see `help-make-xrefs'."
+ (interactive "d")
+ (require 'help-mode)
+ (unless pos
+ (setq pos (point)))
+ (unless (push-button pos)
+ ;; check if the symbol under point is a function or variable
+ (let ((sym
+ (intern
+ (save-excursion
+ (goto-char pos) (skip-syntax-backward "w_")
+ (buffer-substring (point)
+ (progn (skip-syntax-forward "w_")
+ (point)))))))
+ (when (or (boundp sym) (fboundp sym) (facep sym))
+ (switch-to-buffer-other-window (generate-new-buffer "*Help*"))
+ (help-do-xref pos #'help-xref-interned (list sym))))))
+
(put 'debugger-mode 'mode-class 'special)
(defun debugger-mode ()