help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: highlight current source line during debugging


From: Stephen Berman
Subject: Re: highlight current source line during debugging
Date: Tue, 05 Feb 2013 23:36:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

On Tue, 5 Feb 2013 08:56:38 -0600 John Yates <john@yates-sheets.org> wrote:

> Thanks for this suggestion.  To implement it seems to require that one
> know the name of the elisp function which places the overlay arrow.  I
> have been having a hard time figuring this out for gdb disassembly
> buffers.

I'm not familiar with these, nor with the code for them, but glancing at
gdb-mi.el it looks like the overlay arrow is set in
gdb-disassembly-handler-custom, though I can't tell whether you can
advise this to get line highlighting.  I also notice that gud.el appears
to provide support for hl-line (see gud-display-line), so maybe that can
be adapted to gdb disassembly buffers.

> Performing cleanup based on an event in the buffer seems fragile.

Do you mean the way I remapped top-level?  This is just what is bound to
`q' in edebug-mode-map.  When I'm debugging elisp code, I often quit
when I've found the bug, so this is a natural point to remove
highlighting.  The code I posted doesn't remove highlighting when the
instrumented function returns, but the following does (this is rather
heavy-handed, but I can't think of a better way at the moment):

(defun my-edebug-finish ()
  "Finish edebugging and remove highlighting."
  (interactive)
  (unless edebug-active
    (hl-line-mode -1)))

(add-hook 'post-command-hook 'my-edebug-finish)

> Would it not be better to hook buffer destruction?

Well, if you kill the buffer you're debugging, that will automatically
end hl-line-mode, which is buffer-local, so in that case there's nothing
more to clean up.  My approach provides highlighting only while
debugging, so when you're finished (or quit in the middle), you still
have the code buffer but no more highlighting.

> Finally, does this technique keep the line high lighted even when the
> buffer is not selected?  In a normal debugging session it is the
> buffer with the gdb prompt that is selected most of the time.

The highlighting remains until removed by (hl-line-mode -1), even when
the buffer is not current.

Steve Berman



reply via email to

[Prev in Thread] Current Thread [Next in Thread]