I have a buffer foo.el
with some invalid code
(bar)
If i run M-x eval-buffer
, with debug on, it show this in backtrace buffer
Debugger entered--Lisp error: (void-function bar)
(bar)
eval-buffer() ; Reading at buffer position 49
call-interactively(eval-buffer nil nil)
command-execute(eval-buffer)
I am trying to hyperlink
(bar)
to origial location which is foo.el
at some position.
Here is what i have done so far.
(defun hyperlink-error-location ()
"Hyperlink errors in backtrace."
(interactive)
(when (search-forward-regexp "Reading at buffer position " nil 'noerror)
(goto-char (match-end 0))
(let ((num (symbol-at-point)))
(forward-line -1)
(make-button (line-beginning-position) (line-end-position)
'action (lambda (x)
(find-file "/path/to/file")
(goto-char num))))))
(add-hook 'debugger-mode-hook 'hyperlink-error-location)
However i need original buffer name foo.el
in backtrace buffer. How can i get it?
debugger-old-buffer
, but I am not sure your hook will work since themode-hook
is called before the debugger buffer is setup