all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs pretest: highlight line number in display-line-numbers-mode?
@ 2017-10-19 15:19 Sivaram Neelakantan
  2017-10-19 15:37 ` Robert Pluim
  0 siblings, 1 reply; 12+ messages in thread
From: Sivaram Neelakantan @ 2017-10-19 15:19 UTC (permalink / raw)
  To: help-gnu-emacs


The new display-line-numbers-mode in the Emacs pretest works nicely
and seems faster than linum.  Thanks Eli.

Is there a way to highlight the current line number on the fringe in a
different face where the cursor is?  Like hl-line-mode except just the
line number is bold or in a different colour?

sivaram
-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs pretest: highlight line number in display-line-numbers-mode?
  2017-10-19 15:19 Emacs pretest: highlight line number in display-line-numbers-mode? Sivaram Neelakantan
@ 2017-10-19 15:37 ` Robert Pluim
  2017-10-19 17:18   ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Robert Pluim @ 2017-10-19 15:37 UTC (permalink / raw)
  To: Sivaram Neelakantan; +Cc: help-gnu-emacs

Sivaram Neelakantan <nsivaram.net@gmail.com> writes:

> The new display-line-numbers-mode in the Emacs pretest works nicely
> and seems faster than linum.  Thanks Eli.
>
> Is there a way to highlight the current line number on the fringe in a
> different face where the cursor is?  Like hl-line-mode except just the
> line number is bold or in a different colour?
>

        Face: line-number-current-line (sample) (customize this face)

        Documentation:
        Face for displaying the current line number.

Robert



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Emacs pretest: highlight line number in display-line-numbers-mode?
  2017-10-19 15:37 ` Robert Pluim
@ 2017-10-19 17:18   ` Drew Adams
  2017-10-19 20:09     ` Eli Zaretskii
       [not found]     ` <<834lquew6p.fsf@gnu.org>
  0 siblings, 2 replies; 12+ messages in thread
From: Drew Adams @ 2017-10-19 17:18 UTC (permalink / raw)
  To: Robert Pluim, Sivaram Neelakantan; +Cc: help-gnu-emacs

> > Is there a way to highlight the current line number on the fringe in a
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > different face where the cursor is?  Like hl-line-mode except just the
> > line number is bold or in a different colour?
> 
>         Face: line-number-current-line (sample) (customize this face)

(The line number is not actually in the fringe, BTW.)

Not that I really care, for myself, as I don't use line-number
display, but this is yet another case of the misguided (IMHO)
use of a face that does not appear differently from others by
default.

If the default value of face `line-number-current-line'
looked different from that of face `line-number' then
there would be little need to pose the question of whether
you can highlight the current line number differently.
The only question then might be how to do so.

(I have never understood why Emacs sometimes chooses to
provide a face and yet "hide" it from users by default.
That seems very wrong.)

An additional problem (is there a good answer here?) is that
this face is used in a place where you cannot put the cursor
and use `C-u C-x =' to find out what the face is.

To find the face used, I use `list-faces-display' and look
for either a face name that is a likely candidate
(`line-number' is pretty obvious, in this case) or a face
appearance that matches what I see.

Maybe we could have a mouse command (e.g. bound to some
prefix key plus a mouse click) that would let you get the
same info that `C-u C-x =' provides by clicking in (at
least some) places where there is no text?

But it doesn't seem like a click on a displayed line number
registers a particular event that is different from clicking
on nearby buffer text (unlike the case for clicking in the
fringe, for instance), so perhaps this is not feasible for
at least some click spots.  Still, it would presumably be
possible for some such non-text spots, such as the fringe.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs pretest: highlight line number in display-line-numbers-mode?
  2017-10-19 17:18   ` Drew Adams
@ 2017-10-19 20:09     ` Eli Zaretskii
       [not found]     ` <<834lquew6p.fsf@gnu.org>
  1 sibling, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2017-10-19 20:09 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Thu, 19 Oct 2017 10:18:25 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: help-gnu-emacs@gnu.org
> 
> If the default value of face `line-number-current-line'
> looked different from that of face `line-number' then
> there would be little need to pose the question of whether
> you can highlight the current line number differently.

This face is by default the same as line-number because of 2 reasons:

  . linum-mode did the same
  . using a different face makes redisplay slightly slower (because it
    disallows some redisplay optimizations)

> To find the face used, I use `list-faces-display' and look
> for either a face name that is a likely candidate
> (`line-number' is pretty obvious, in this case) or a face
> appearance that matches what I see.

There are other places where this doesn't work, e.g. on the mode line.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Emacs pretest: highlight line number in display-line-numbers-mode?
       [not found]     ` <<834lquew6p.fsf@gnu.org>
@ 2017-10-19 20:43       ` Drew Adams
  2017-10-20  6:34         ` Eli Zaretskii
       [not found]         ` <<83376ee39c.fsf@gnu.org>
  0 siblings, 2 replies; 12+ messages in thread
From: Drew Adams @ 2017-10-19 20:43 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs

> This face is by default the same as line-number because of 2 reasons:
> 
>   . linum-mode did the same

...chasing that rabbit: Why did `linum-mode' do that?

Two wrongs don't necessarily make a right.

>   . using a different face makes redisplay slightly slower
>     (because it disallows some redisplay optimizations)

Would those optimizations still be available if a
user chose the same face for both (but the faces
were different by default)?

If so, I'd suggest making the faces different by
default.  And if the performance difference is
important then perhaps mention it in the doc,
so users who want that optimization at the cost
of not highlighting the current line number can
get it.  IOW, opt-in for the loss of a difference.

> > To find the face used, I use `list-faces-display' and look
> > for either a face name that is a likely candidate
> > (`line-number' is pretty obvious, in this case) or a face
> > appearance that matches what I see.
> 
> There are other places where this doesn't work, e.g. on the
> mode line.

What do you mean by "this"?  Using `list-faces-display'
or the fact that you can't use `C-u C-x =' to learn
the face?

You gave that reply after my mention of the former. 
Aren't all of the faces used in the mode line shown in
`list-faces-display'?  At least all faces with "mode-line"
in their name are listed there.

There are certainly several places where you cannot use
`C-u C-x =' to see what the face is.  (In particular,
places where there is no cursor/buffer position.)



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs pretest: highlight line number in display-line-numbers-mode?
  2017-10-19 20:43       ` Drew Adams
@ 2017-10-20  6:34         ` Eli Zaretskii
  2017-10-20 13:49           ` Robert Pluim
       [not found]           ` <<87mv4mexpo.fsf@gmail.com>
       [not found]         ` <<83376ee39c.fsf@gnu.org>
  1 sibling, 2 replies; 12+ messages in thread
From: Eli Zaretskii @ 2017-10-20  6:34 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Thu, 19 Oct 2017 13:43:06 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> 
> > This face is by default the same as line-number because of 2 reasons:
> > 
> >   . linum-mode did the same
> 
> ...chasing that rabbit: Why did `linum-mode' do that?

I don't know, but too many differences from a previous feature tend to
annoy people IME.

> >   . using a different face makes redisplay slightly slower
> >     (because it disallows some redisplay optimizations)
> 
> Would those optimizations still be available if a
> user chose the same face for both (but the faces
> were different by default)?
> 
> If so, I'd suggest making the faces different by
> default.

They are already different by default.  They just have the same
attributes.

> IOW, opt-in for the loss of a difference.

That's already so.

> > > To find the face used, I use `list-faces-display' and look
> > > for either a face name that is a likely candidate
> > > (`line-number' is pretty obvious, in this case) or a face
> > > appearance that matches what I see.
> > 
> > There are other places where this doesn't work, e.g. on the
> > mode line.
> 
> What do you mean by "this"?  Using `list-faces-display'
> or the fact that you can't use `C-u C-x =' to learn
> the face?

The latter.

> You gave that reply after my mention of the former. 
> Aren't all of the faces used in the mode line shown in
> `list-faces-display'?

They are, but so are the line-number faces.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs pretest: highlight line number in display-line-numbers-mode?
  2017-10-20  6:34         ` Eli Zaretskii
@ 2017-10-20 13:49           ` Robert Pluim
  2017-10-20 14:49             ` Eli Zaretskii
       [not found]           ` <<87mv4mexpo.fsf@gmail.com>
  1 sibling, 1 reply; 12+ messages in thread
From: Robert Pluim @ 2017-10-20 13:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Thu, 19 Oct 2017 13:43:06 -0700 (PDT)
>> From: Drew Adams <drew.adams@oracle.com>
>> 
>> > This face is by default the same as line-number because of 2 reasons:
>> > 
>> >   . linum-mode did the same
>> 
>> ...chasing that rabbit: Why did `linum-mode' do that?
>
> I don't know, but too many differences from a previous feature tend to
> annoy people IME.

nlinum-mode has an option to highlight the current line, disabled by
default (I never turned it on because I didn't know it existed, but I
do have it turned on for the builtin support)

I'd vote for having the current line face have a background colour
set. Calculating line numbers is going to slow things down anyway, so
a little less speed doesn't matter to me. Something like:

diff --git i/lisp/faces.el w/lisp/faces.el
index a5f1d1dd32..a2bb2cd1b3 100644
--- i/lisp/faces.el
+++ w/lisp/faces.el
@@ -2487,7 +2487,12 @@ line-number
   :group 'display-line-numbers)
 
 (defface line-number-current-line
-  '((t :inherit line-number))
+  '((((class color) (background light))
+     :inherit line-number :background "grey95")
+    (((class color) (background dark))
+     :inherit line-number :background "grey10")
+    (t
+     :inherit line-number :background "gray"))
   "Face for displaying the current line number.
 This face is used when `display-line-numbers' is non-nil.
 
Robert



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: Emacs pretest: highlight line number in display-line-numbers-mode?
  2017-10-20 13:49           ` Robert Pluim
@ 2017-10-20 14:49             ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2017-10-20 14:49 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Robert Pluim <rpluim@gmail.com>
> Cc: help-gnu-emacs@gnu.org
> Date: Fri, 20 Oct 2017 15:49:07 +0200
> 
> nlinum-mode has an option to highlight the current line, disabled by
> default

So does display-line-numbers-mode, by way of the
line-number-current-line face.  Or am I missing something?

> I'd vote for having the current line face have a background colour
> set.

By default?  Why do you need it by default?  What's wrong with lettng
users customize that as they see fit?

> Calculating line numbers is going to slow things down anyway

It doesn't.  I measured it.  And there's no reason why it should slow
down, because the line numbers are computed on the fly, as the lines
are laid out for display.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Emacs pretest: highlight line number in display-line-numbers-mode?
       [not found]             ` <<83h8utdgcq.fsf@gnu.org>
@ 2017-10-20 15:18               ` Drew Adams
  2017-10-20 15:42                 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2017-10-20 15:18 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs

> > I'd vote for having the current line face have a background colour
> > set.
> 
> By default?  Why do you need it by default?  What's wrong
> with lettng users customize that as they see fit?

We've already answered that: It is not obvious that they
have that possibility.  They can't see that there are
two different faces involved, with the default behavior.

If you make a difference invisible, you are not exactly
helping users to be aware of it.

The second reason is that showing which line is current
is helpful.  Anyone who is annoyed by seeing that can
opt out, customizing the current-line face to look the
same as the other-line face.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Emacs pretest: highlight line number in display-line-numbers-mode?
       [not found]         ` <<83376ee39c.fsf@gnu.org>
@ 2017-10-20 15:18           ` Drew Adams
  2017-10-20 15:52             ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2017-10-20 15:18 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs

> > >   . using a different face makes redisplay slightly slower
> > >     (because it disallows some redisplay optimizations)
> >
> > Would those optimizations still be available if a
> > user chose the same face for both (but the faces
> > were different by default)?

?

I guess you are confirming that the optimizations you
spoke of are a red herring here: they would anyway be
available whenever someone customizes the current-line
face to have the same appearance as the other-lines face.
Or do you want to correct this guess?

> > If so, I'd suggest making the faces different by
> > default.
> 
> They are already different by default.  They just have
> the same attributes.

I think you understood perfectly well that I was
referring to a difference of _appearance_, not the fact
that there are two different face objects.  There are
two faces, but they have the same appearance by default.
That's the misdesign.

Please consider giving them a different appearance by
default.  That will help users see which is the current
line, and it will help users know that there are two
different faces, which they can customize.

   If you think it is important, add a doc mention that if
   the faces have the same attribute values then display
   performance can be better.

> > IOW, opt-in for the loss of a difference.
> 
> That's already so.

No.  If the appearance is the same by default then
you have to opt out of that default behavior to see
a difference.  Lack of a difference in appearance
is not opt-in currently; it is the default behavior.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs pretest: highlight line number in display-line-numbers-mode?
  2017-10-20 15:18               ` Drew Adams
@ 2017-10-20 15:42                 ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2017-10-20 15:42 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 20 Oct 2017 08:18:02 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> 
> > > I'd vote for having the current line face have a background colour
> > > set.
> > 
> > By default?  Why do you need it by default?  What's wrong
> > with lettng users customize that as they see fit?
> 
> We've already answered that:

Who are 'we"?  I was answering to Robert.

> It is not obvious that they have that possibility.  They can't see
> that there are two different faces involved, with the default
> behavior.

Yes, you already said that, it wasn't convincing the first time.  The
documentation exists for a reason.

> The second reason is that showing which line is current
> is helpful.  Anyone who is annoyed by seeing that can
> opt out, customizing the current-line face to look the
> same as the other-line face.

There are several features that show the current line, all of them
optional.  I see no reason to make that on by default now, and in any
case this is a separate issue.  IOW, if you are lobbying for making
the line-number-current face be distinct by default for this reason,
you will have first to convince that making the current line stand out
by default is a good idea.  (And the place to make that argument is
not here.)



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs pretest: highlight line number in display-line-numbers-mode?
  2017-10-20 15:18           ` Drew Adams
@ 2017-10-20 15:52             ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2017-10-20 15:52 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 20 Oct 2017 08:18:07 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> 
> > > >   . using a different face makes redisplay slightly slower
> > > >     (because it disallows some redisplay optimizations)
> > >
> > > Would those optimizations still be available if a
> > > user chose the same face for both (but the faces
> > > were different by default)?
> 
> ?
> 
> I guess you are confirming that the optimizations you
> spoke of are a red herring here:

It's not a red herring, you can see that in the code.

> they would anyway be available whenever someone customizes the
> current-line face to have the same appearance as the other-lines
> face.

The current-line face has the same appearance by default, making those
optimizations possible.  When the appearance is different, the
optimizations are disabled.  I hope what I say is now perfectly clear.

It is not clear to me what change you are lobbying for, except for
changing the defaults, which is something that was already asked and
answered.

> There are two faces, but they have the same appearance by default.
> That's the misdesign.

And as I already said, this "misdesign" has a good reason, so the
"mis" part is uncalled for.  You might disagree with my design, but
please don't use denigrating terms just because you do.

In any case, we already have several other faces that by default look
the same, so this is not an odd case.

> Please consider giving them a different appearance by
> default.

I already explained why I didn't think this was a good idea.  What is
the purpose of repeating the same request?



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-10-20 15:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-19 15:19 Emacs pretest: highlight line number in display-line-numbers-mode? Sivaram Neelakantan
2017-10-19 15:37 ` Robert Pluim
2017-10-19 17:18   ` Drew Adams
2017-10-19 20:09     ` Eli Zaretskii
     [not found]     ` <<834lquew6p.fsf@gnu.org>
2017-10-19 20:43       ` Drew Adams
2017-10-20  6:34         ` Eli Zaretskii
2017-10-20 13:49           ` Robert Pluim
2017-10-20 14:49             ` Eli Zaretskii
     [not found]           ` <<87mv4mexpo.fsf@gmail.com>
     [not found]             ` <<83h8utdgcq.fsf@gnu.org>
2017-10-20 15:18               ` Drew Adams
2017-10-20 15:42                 ` Eli Zaretskii
     [not found]         ` <<83376ee39c.fsf@gnu.org>
2017-10-20 15:18           ` Drew Adams
2017-10-20 15:52             ` Eli Zaretskii
     [not found] <<krpqx3tvyv413v.fsf@gmail.com>
     [not found] <<<krpqx3tvyv413v.fsf@gmail.com>

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.