+(defun hl-line-maybe-unhighlight ()
+ "Maybe deactivate the Hl-Line overlay on the current line.
+Specifically, when `hl-line-sticky-flag' is nil deactivate all
+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)
+ (not (eq curbuf hlob))
+ (not (minibufferp)))
+ (with-current-buffer hlob
+ (when (overlayp hl-line-overlay)
+ (delete-overlay hl-line-overlay))))
+ (when (and (overlayp hl-line-overlay)
+ (eq (overlay-buffer hl-line-overlay) curbuf))
+ (setq hl-line-overlay-buffer curbuf))))
+