Subject: bug#16192: closed (Re: bug#16192: hl-line-mode: Current line highlighting takes precedence over region highlighting)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 19 Dec 2013 20:32:02 +0000

Your bug report

#16192: hl-line-mode: Current line highlighting takes precedence over region highlighting

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
16192: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16192
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#16192: hl-line-mode: Current line highlighting takes precedence over region highlighting
From: Stefan Monnier <[email-masked]>
To: Jarosław Rzeszótko <[email-masked]>
Cc: Eli Zaretskii <[email-masked]>, [email-masked]
Date: Thu, 19 Dec 2013 15:31:28 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

> Thanks, it's perfect now!

Thank you, closing,

        Stefan

Subject: hl-line-mode: Current line highlighting takes precedence over region highlighting
From: Jarosław Rzeszótko <[email-masked]>
To: [email-masked]
Date: Thu, 19 Dec 2013 12:38:28 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

I use a current emacs build from VCS. When you use hl-line-mode with the
default settings, the highlighting of the current line takes precedence
over the region highlighting. In my opinion this is bad usability, since
you no longer see where the region is, and in this particular situation
where the current line is would be obvious without the highlighting (the
user is in the middle of selecting the region so he knows where he is in
the file I guess). Would a hl-line-range function of this kind not be a
better default:

(setq hl-line-range-function
      (lambda ()
        (if (region-active-p)
            nil
          (cons (line-beginning-position) (line-beginning-position 2)))))

Or one that keeps the current line highlighting only where it does not
interfere with the region highlighting:

(setq hl-line-range-function
      (lambda ()
        (let ((line-beg-pos (line-beginning-position))
              (line-end-pos (line-beginning-position 2)))
          (if (region-active-p)
              (if (= (point) (region-end))
                  (cons (point) line-end-pos)
                (cons line-beg-pos (point)))
            (cons line-beg-pos line-end-pos)))))

The last function is better but since hl-line-range-function returns a
single range, it is impossible to highlight the line on both sides of a
region that is part of a single line. In general I appreciate that this is
customizable and one can overwrite it, but it takes quite some time to fix
it yourself, and I think most users want to see one of those two behaviours
(as evidenced by what most editors do in this respect).

Cheers,
Jarosław Rzeszótko