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

From: Stephen Berman <[email-masked]>
Date: Thu, 26 Jan 2017 10:54:47 +0100

On Thu, 26 Jan 2017 03:07:51 +0100 Michael Heerdegen <[email-masked]> wrote:

> Michael Heerdegen <[email-masked]> writes:
>
>> Michael Heerdegen <[email-masked]> writes:
>>
>> >   (setq-default hl-line-sticky-flag nil)
>>
>> Removing that from my init file seems to fix the issue.  Maybe we are
>> lucky and this was already the missing piece.
>
> I just got the same error message after hitting U x in M-x
> list-packages.  Here is an excerpt from `interaction-log':

Is this after removing the above sexp?  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)

to ~/.emacs and did `I x' in package-menu-mode (I didn't have any
package to update so I just installed a new one), but didn't get the
error (even with the above setq-default).  Anyway, your suggestion to
check hl-line-overlay-buffer appears to eliminate the error when exiting
Gnus, so does the following patch also fix the other error you saw?

Steve Berman

diff --git a/lisp/hl-line.el b/lisp/hl-line.el
index 4cf0573..38fe683 100644
--- a/lisp/hl-line.el
+++ b/lisp/hl-line.el
@@ -189,7 +189,8 @@ hl-line-maybe-unhighlight
 such overlays in all buffers except the current one."
   (let ((hlob hl-line-overlay-buffer)
         (curbuf (current-buffer)))
-    (when (and (not hl-line-sticky-flag)
+    (when (and (buffer-live-p hlob)
+               (not hl-line-sticky-flag)
                (not (eq curbuf hlob))
                (not (minibufferp)))
       (with-current-buffer hlob