[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10275: speedbar highlights first selected item in speedbar-highlight
From: |
martin rudalics |
Subject: |
bug#10275: speedbar highlights first selected item in speedbar-highlight-face |
Date: |
Wed, 14 Dec 2011 18:23:34 +0100 |
User-agent: |
Thunderbird 2.0.0.21 (Windows/20090302) |
> emacs -Q -f speedbar
> ;; then select any source file in speedbar, click to unfold it, and
> click over any variable or function.
>
> What happens:
> - The file is highlighted in the Speedbar frame, with
`speedbar-highlight-face'.
> - The file is loaded into a buffer and displayed in a window.
> - The selected variable or function is shown, and also highlighted
> with `speedbar-highlight-face'.
>
> Clicking into another subitem (or even the same one) of the same file
> does not bring back the highlighting. But clicking it into another
> file's subitem does. It happens every time a new file is selected,
> even if previously selected.
>
> I'm not sure this is a bug, because the behavior already happens in
> 22.1, but certainly is unexpected, and the docstring of
> `speedbar-highlight-face' talks only about buttons, not the source
> file.
What happens is that after the mouse click speedbar does highlight the
line via `speedbar-highlight-one-tag-line' which installs in
`pre-command-hook' the function `speedbar-unhighlight-one-tag-line'.
Next comes a switch-frame event to select the frame of the buffer where
the highlight is and executing the corresponding `handle-switch-frame'
command triggers the `pre-command-hook' which swallows the highlight
immediately.
An easy work-around is
(defun speedbar-unhighlight-one-tag-line ()
"Unhighlight the currently highlighted line."
(when (and speedbar-highlight-one-tag-line
(not (eq this-command 'handle-switch-frame)))
(speedbar-delete-overlay speedbar-highlight-one-tag-line)
(setq speedbar-highlight-one-tag-line nil)
(remove-hook 'pre-command-hook 'speedbar-unhighlight-one-tag-line)))
but I have no idea what Eric intended to accomplish in the first place
and delving into the code of speedbar or dframe is no fun at all.
martin