From: Keith David Bershatsky <esq@lawlist.com>
To: 25393@debbugs.gnu.org
Subject: bug#25393: FEATURE REQUEST: *Backtrace* -- C source code def highlight + jump to def.
Date: Sun, 08 Jan 2017 00:29:13 -0800 [thread overview]
Message-ID: <m2wpe6ymxy.wl%esq@lawlist.com> (raw)
As a feature request, the Emacs team may wish to consider implementing the ability for users to highlight C source code definitions in the *Backtrace* buffer and jump to the function definitions. The highlighting of said functions makes the *Backtrace* buffer prettier, and it's handy to jump to the definitions with buttons. A check should probably be included to see whether the `find-function-C-source-directory' contains C source code files before creating highlighting/buttons for jumping:
Here is the link to the related thread: http://emacs.stackexchange.com/questions/29875/debugging-debugger-mode-how-to-highlight-the-culprit
In my use-case, it wasn't very obvious to me that `/` was the cause of my backtrace error message because it was not highlighted -- this is true even though I am aware that the problem is always near the top of the debugger buffer. It is just not a function I use a lot and it didn't really look like a function because it was just regular text coloration.
(require 'debug)
(defun debugger-make-xrefs (&optional buffer)
"Attach cross-references to function names in the `*Backtrace*' buffer."
(interactive "b")
(with-current-buffer (or buffer (current-buffer))
(save-excursion
(setq buffer (current-buffer))
(let ((inhibit-read-only t)
(old-end (point-min)) (new-end (point-min)))
(if debugger-previous-backtrace
(let (old-start new-start (all-match t))
(goto-char (point-max))
(with-temp-buffer
(insert debugger-previous-backtrace)
(while (and all-match (not (bobp)))
(setq old-end (point))
(forward-line -1)
(setq old-start (point))
(with-current-buffer buffer
(setq new-end (point))
(forward-line -1)
(setq new-start (point)))
(if (not (zerop
(let ((case-fold-search nil))
(compare-buffer-substrings
(current-buffer) old-start old-end
buffer new-start new-end))))
(setq all-match nil))))
(delete-region new-end (point-max))
(goto-char (point-max))
(insert (substring debugger-previous-backtrace
(- old-end (point-min))))
(narrow-to-region (point-min) new-end)))
(goto-char (point-min))
(while (progn
(goto-char (+ (point) 2))
(skip-syntax-forward "^w_")
(not (eobp)))
(let* ((beg (point))
(end (progn (skip-syntax-forward "w_") (point)))
(fn (function-called-at-point)) ;; MODIFICATION
(sym (intern-soft (buffer-substring-no-properties beg end)))
;; MODIFICATION
(file
(if fn
(let* (
(function fn)
(advised (and (symbolp function)
(featurep 'nadvice)
(advice--p (advice--symbol-function function))))
;; If the function is advised, use the symbol that has the
;; real definition, if that symbol is already set up.
(real-function
(or (and advised
(advice--cd*r (advice--symbol-function function)))
function))
;; Get the real definition.
(def (if (symbolp real-function)
(or (symbol-function real-function)
(signal 'void-function (list real-function)))
real-function))
(aliased (or (symbolp def)
;; Advised & aliased function.
(and advised (symbolp real-function)
(not (eq 'autoload (car-safe def))))))
(file-name (find-lisp-object-file-name function (if aliased 'defun
def))))
file-name)
(and sym (symbol-file sym 'defun)))))
(when (or fn file) ;; MODIFICATION
(goto-char beg)
(re-search-forward "\\(\\sw\\|\\s_\\)+")
(help-xref-button 0 'help-function-def sym file)))
(forward-line 1))
(widen))
(setq debugger-previous-backtrace (buffer-string)))))
next reply other threads:[~2017-01-08 8:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-08 8:29 Keith David Bershatsky [this message]
2018-08-09 0:11 ` bug#25393: FEATURE REQUEST: *Backtrace* -- C source code def highlight + jump to def Gemini Lasswell
2018-08-27 18:07 ` Gemini Lasswell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2wpe6ymxy.wl%esq@lawlist.com \
--to=esq@lawlist.com \
--cc=25393@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.