GNU bug report logs - #16192
hl-line-mode: Current line highlighting takes precedence over region highlighting

Previous Next

Package: emacs;

Reported by: Jarosław Rzeszótko <sztywny <at> gmail.com>

Date: Thu, 19 Dec 2013 11:39:02 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 16192 in the body.
You can then email your comments to 16192 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Thu, 19 Dec 2013 11:39:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jarosław Rzeszótko <sztywny <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 19 Dec 2013 11:39:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jarosław Rzeszótko <sztywny <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: hl-line-mode: Current line highlighting takes precedence over region
 highlighting
Date: Thu, 19 Dec 2013 12:38:28 +0100
[Message part 1 (text/plain, inline)]
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
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Thu, 19 Dec 2013 14:03:02 GMT) Full text and rfc822 format available.

Message #8 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Jarosław Rzeszótko <sztywny <at> gmail.com>
Cc: 16192 <at> debbugs.gnu.org
Subject: Re: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Thu, 19 Dec 2013 09:02:29 -0500
> 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.

Actually, that depends on the relative position/size of the two.
I've just installed a patch which lowers the priority of the hl-line
highlighting, which seems like a good thing to do in general and which
should resolve this problem (unless you use the same attributes for the
region and the hl-line faces).


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Thu, 19 Dec 2013 14:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Jarosław Rzeszótko <sztywny <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 16192 <at> debbugs.gnu.org
Subject: Re: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Thu, 19 Dec 2013 15:19:45 +0100
[Message part 1 (text/plain, inline)]
Hi,

There is now a little quirk if the window has a margin, see here:

http://imgur.com/pkxRmhf

The first column on the left is the margin (as in left-margin-width), and
the bright yellow rectangle is the cursor block. When the margin is
disabled, it does fix the issue for me.

Cheers,
Jarosław Rzeszótko


2013/12/19 Stefan Monnier <monnier <at> iro.umontreal.ca>

> > 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.
>
> Actually, that depends on the relative position/size of the two.
> I've just installed a patch which lowers the priority of the hl-line
> highlighting, which seems like a good thing to do in general and which
> should resolve this problem (unless you use the same attributes for the
> region and the hl-line faces).
>
>
>         Stefan
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Thu, 19 Dec 2013 16:39:02 GMT) Full text and rfc822 format available.

Message #14 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Jaros?aw Rzeszótko <sztywny <at> gmail.com>,
 16192 <at> debbugs.gnu.org
Subject: RE: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Thu, 19 Dec 2013 08:38:47 -0800 (PST)
[Message part 1 (text/plain, inline)]
IMO, this is a duplicate of bug (regression) #15899.

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15899

 

Now, region highlighting can take a back seat to other highlighting. Not good.

 

As I said in that thread, "Selection highlighting should, at the very least by default, visibly cover the entire selection."

 

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). 
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Thu, 19 Dec 2013 16:45:01 GMT) Full text and rfc822 format available.

Message #17 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>,
 Jaros?aw Rzeszótko <sztywny <at> gmail.com>
Cc: 16192 <at> debbugs.gnu.org
Subject: RE: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Thu, 19 Dec 2013 08:43:56 -0800 (PST)
> I've just installed a patch which lowers the priority of the hl-line
> highlighting, which seems like a good thing to do in general and which
> should resolve this problem (unless you use the same attributes for the
> region and the hl-line faces).

It's not about the priority of the hl-line highlighting. (And other code
might well expect the priority that was there before.)

It's about the priority of the region highlighting.  Raise that,
instead of lowering other priorities case by case (and possibly breaking
other code).  It is the region overlay that is new.  It is its priority
that needs fixing.

But didn't you say that you didn't want to be fiddling with priorities,
to deal with the problems introduced by this change?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Thu, 19 Dec 2013 17:42:02 GMT) Full text and rfc822 format available.

Message #20 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Jarosław Rzeszótko <sztywny <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 16192 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Thu, 19 Dec 2013 18:41:51 +0100
[Message part 1 (text/plain, inline)]
Correction from my side, the last problem seems to actually be independent
of the fix, I reproduced it with vanilla emacs from vcs, no hl-line-mode,
emacs ran with --no-init, without any .Xresources etc., just:

(setq-default left-margin-width 1)

open a new buffer, select a few lines, and you get this:

http://imgur.com/M1LFjeF


2013/12/19 Drew Adams <drew.adams <at> oracle.com>

> > I've just installed a patch which lowers the priority of the hl-line
> > highlighting, which seems like a good thing to do in general and which
> > should resolve this problem (unless you use the same attributes for the
> > region and the hl-line faces).
>
> It's not about the priority of the hl-line highlighting. (And other code
> might well expect the priority that was there before.)
>
> It's about the priority of the region highlighting.  Raise that,
> instead of lowering other priorities case by case (and possibly breaking
> other code).  It is the region overlay that is new.  It is its priority
> that needs fixing.
>
> But didn't you say that you didn't want to be fiddling with priorities,
> to deal with the problems introduced by this change?
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Thu, 19 Dec 2013 18:03:01 GMT) Full text and rfc822 format available.

Message #23 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Jaros?aw Rzeszótko <sztywny <at> gmail.com>,
 16192 <at> debbugs.gnu.org
Subject: Re: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Thu, 19 Dec 2013 13:02:41 -0500
> It is the region overlay that is new.  It is its priority that
> needs fixing.

This narrow-minded "if a bug appear it must be in the new code" point of
view leads to unmaintainable messes of hacks upon hacks.

hl-line's overlay is a "background" highlight (not in the "background
color" sense, but in a "background noise" sense), so it makes a lot of
sense to give it a low priority.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Thu, 19 Dec 2013 19:29:02 GMT) Full text and rfc822 format available.

Message #26 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jarosław Rzeszótko <sztywny <at> gmail.com>
Cc: 16192 <at> debbugs.gnu.org, drew.adams <at> oracle.com
Subject: Re: bug#16192: hl-line-mode: Current line highlighting takes
 precedence	over region highlighting
Date: Thu, 19 Dec 2013 21:27:59 +0200
> Date: Thu, 19 Dec 2013 18:41:51 +0100
> From: Jarosław Rzeszótko <sztywny <at> gmail.com>
> Cc: 16192 <at> debbugs.gnu.org
> 
> Correction from my side, the last problem seems to actually be independent
> of the fix, I reproduced it with vanilla emacs from vcs, no hl-line-mode,
> emacs ran with --no-init, without any .Xresources etc., just:
> 
> (setq-default left-margin-width 1)
> 
> open a new buffer, select a few lines, and you get this:
> 
> http://imgur.com/M1LFjeF

My bad, now fixed in trunk revision 115615.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Thu, 19 Dec 2013 19:49:02 GMT) Full text and rfc822 format available.

Message #29 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Jarosław Rzeszótko <sztywny <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 16192 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Thu, 19 Dec 2013 20:47:58 +0100
[Message part 1 (text/plain, inline)]
Thanks, it's perfect now!

Cheers,
Jarosław Rzeszótko


2013/12/19 Eli Zaretskii <eliz <at> gnu.org>

> > Date: Thu, 19 Dec 2013 18:41:51 +0100
> > From: Jarosław Rzeszótko <sztywny <at> gmail.com>
> > Cc: 16192 <at> debbugs.gnu.org
> >
> > Correction from my side, the last problem seems to actually be
> independent
> > of the fix, I reproduced it with vanilla emacs from vcs, no hl-line-mode,
> > emacs ran with --no-init, without any .Xresources etc., just:
> >
> > (setq-default left-margin-width 1)
> >
> > open a new buffer, select a few lines, and you get this:
> >
> > http://imgur.com/M1LFjeF
>
> My bad, now fixed in trunk revision 115615.
>
[Message part 2 (text/html, inline)]

Reply sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
You have taken responsibility. (Thu, 19 Dec 2013 20:32:01 GMT) Full text and rfc822 format available.

Notification sent to Jarosław Rzeszótko <sztywny <at> gmail.com>:
bug acknowledged by developer. (Thu, 19 Dec 2013 20:32:02 GMT) Full text and rfc822 format available.

Message #34 received at 16192-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Jarosław Rzeszótko <sztywny <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 16192-done <at> debbugs.gnu.org
Subject: Re: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Thu, 19 Dec 2013 15:31:28 -0500
> Thanks, it's perfect now!

Thank you, closing,


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 17 Jan 2014 12:24:04 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Drew Adams <drew.adams <at> oracle.com> to control <at> debbugs.gnu.org. (Tue, 17 Jun 2014 14:18:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Tue, 17 Jun 2014 14:31:01 GMT) Full text and rfc822 format available.

Message #41 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Jaros?aw Rzeszótko <sztywny <at> gmail.com>,
 16192 <at> debbugs.gnu.org
Subject: RE: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Tue, 17 Jun 2014 07:30:25 -0700 (PDT)
Assigning the priority of the hl-line overlay as -50 breaks Emacs
convention and flies in the face of overlay behavior as documented.
(elisp) `Overlay Properties' says:

 If you want to specify a priority value, use either `nil' (or zero),
 or a positive integer.  Any other value has undefined behavior.
      ^^^^^^^^           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Maybe that policy and guideline needs to be modified in light of the
chosen fix for bug #16192?  Maybe it should now say what negative
values mean (what the behavior is).

Note that not only has Emacs Dev violated this past guideline, but
3rd-party code will now do the same.  To fix precisely this bug in
hl-line+.el, for example, I had to follow suit.

[Again, instead of reducing the priorities of multiple overlays case
by case as bugs are noticed, a better fix would be to raise the
region priority.  If the other, pre-existing overlays already have
priorities that make sense relative to each other, then it is only
the priority of the new, region overlay that needs to be established.]




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16192; Package emacs. (Tue, 17 Jun 2014 15:09:02 GMT) Full text and rfc822 format available.

Message #44 received at 16192 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Jaros?aw Rzeszótko <sztywny <at> gmail.com>,
 16192 <at> debbugs.gnu.org
Subject: Re: bug#16192: hl-line-mode: Current line highlighting takes
 precedence over region highlighting
Date: Tue, 17 Jun 2014 11:07:53 -0400
> Assigning the priority of the hl-line overlay as -50 breaks Emacs
> convention and flies in the face of overlay behavior as documented.

Not it just uses undefined behavior.


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 16 Jul 2014 11:24:04 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Drew Adams <drew.adams <at> oracle.com> to control <at> debbugs.gnu.org. (Sun, 05 Apr 2015 18:07:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 04 May 2015 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 16 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.