Subject: Re: bug#25522: 26.0.50; (hl-line-maybe-unhighlight): (error "Selecting deleted buffer")

From: Stephen Berman <[email-masked]>
Date: Thu, 26 Jan 2017 20:45:11 +0100

On Thu, 26 Jan 2017 11:15:24 +0100 Michael Heerdegen <[email-masked]> wrote:

> Stephen Berman <[email-masked]> writes:
>
>> > I just got the same error message after hitting U x in M-x
>> > list-packages.
>>
>> Is this after removing the above sexp?
>
> No, still with hl-line-sticky-flag -> nil.
>
>
>> Did you have hl-line-mode enabled in package-menu-mode, and if so,
>> how?  I added this:
>>
>> (add-hook 'package-menu-mode-hook #'hl-line-mode)
>
> Yes, that's exactly what I use - sorry for my terseness.
>
>
>> -    (when (and (not hl-line-sticky-flag)
>> +    (when (and (buffer-live-p hlob)
>> +               (not hl-line-sticky-flag)
>
> Yeah, that seems to fix the problem (I had already tried that ;-)).  I
> still wonder why you don't see it...but I'm not sure if it's worth to
> investigate (because this will probably take hours).

I think I found out what triggers the error: when you kill a buffer in
whose mode hl-line-mode is enabled and the mode of the next (now
current) buffer does not have hl-line-mode enabled, and then you change
(or Emacs changes) to another buffer in whose mode hl-line-mode is
enabled -- that raises the error.  Can you confirm this?  Just out of
curiosity, because I think the above fix is good enough and it's simple,
so unless someone sees a problem with it, I'll commit it to master.

Steve Berman