From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: Native line numbers landed on master Date: Tue, 1 Oct 2019 07:44:47 +0200 Message-ID: References: <83k23jl5ra.fsf@gnu.org> <87bmolqryw.fsf@wavexx.thregr.org> <83blz5bh2m.fsf@gnu.org> <87h88x4fqw.fsf@wavexx.thregr.org> <834l4xbfmp.fsf@gnu.org> <87ef414dfn.fsf@wavexx.thregr.org> <83o9359w3l.fsf@gnu.org> <83eezycce5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000cd1fad0593d2dbf0" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="216755"; mail-complaints-to="usenet@blaine.gmane.org" Cc: wavexx@thregr.org, Emacs developers To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 01 07:46:37 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFAzc-000uHF-Oq for ged-emacs-devel@m.gmane.org; Tue, 01 Oct 2019 07:46:36 +0200 Original-Received: from localhost ([::1]:59152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFAzb-0004Fh-Cz for ged-emacs-devel@m.gmane.org; Tue, 01 Oct 2019 01:46:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41202) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFAyW-0004Cv-Nd for emacs-devel@gnu.org; Tue, 01 Oct 2019 01:45:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iFAyV-0003dN-5D for emacs-devel@gnu.org; Tue, 01 Oct 2019 01:45:28 -0400 Original-Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:43180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iFAyT-0003ce-4d; Tue, 01 Oct 2019 01:45:25 -0400 Original-Received: by mail-qt1-x829.google.com with SMTP id c3so20077611qtv.10; Mon, 30 Sep 2019 22:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=leCkwMSRT8oVXTUpVlZnc7VQxlMWUq5BV7ReMnEE8Jo=; b=jUBYIdf0ulY3MmHhNYN4R5qAREnCrJaAc/h4NW6urgO2YZhoB5l7zKCOBsbzjUVC0M W5+DFgU3n+moJqDHZiZ7q4Zbzq6k2KvxSA8bm+uA/5q0+CpvLu0FpN5gfuH5AiDutEqB h3npHbOatkUuUPduXNq7AMV0CSgCUD5V8ilf+pn4qXar66PxvE5AE7rEeK7Kb1WpkgvG 19ienzDlJHv+XnMq7HpNLgPNc5zFM7kiwEPaYHZJ2lAitSGkBfl0Mw65a8S/E0nKpX3/ AB+wcrQSr6Lw8b2gBQgmBPEt6jbOOt6PBV3mZfcgCQ5nJPyxXjOPq3cpUFYdCBOEhLfE 4QlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=leCkwMSRT8oVXTUpVlZnc7VQxlMWUq5BV7ReMnEE8Jo=; b=oV0y30xO2OLslV4SuAju7m0fwT+JHwwK3o8kUqRLTy8B/6nrmjYoJFvdKwuV8fcqJ3 iPEGtJYRluxexIpf6SlGcNcV6eKF/WOKwy2X5mgwB0ns2JOdBUUwrzub/Dpmo7ZxIedb pi8SENWLfMzqIrIM2GMLtHHS0/5ZbUkURuhMRS4ZB4vLPVb+hnFMfQrhGxTp6yV5g5Vk gafUpdABa1EXqWW6tooKZXDS/OoAvZcJiQJ2wdu/gwPuMkkMffZG+//WKEdx2i8ODSDc wGxJ6zOVTePwCqsHEsPL0AZRrg1uySSByESYV64ynt73Lk7piqHRyNHQjupiirvRFjRi VKgQ== X-Gm-Message-State: APjAAAWtmDfg3qB/Ij3WjT3/KyWMjRbIJMj4L3oeMo6CNwbRR9WPONNe mb1X2hUf0QIvaraLW/sgBRY3WWBjM1GIUCsjfx/egcl1 X-Google-Smtp-Source: APXvYqyVijieJ6iFvsjubKqRtUoICXgszCfZ4pCl9kRdZdp3AZKAKZ7NXgNotoFrWy0HNK3juQTH4VaAScBeW2Do404= X-Received: by 2002:aed:21d1:: with SMTP id m17mr1351860qtc.17.1569908723620; Mon, 30 Sep 2019 22:45:23 -0700 (PDT) In-Reply-To: <83eezycce5.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::829 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240417 Archived-At: --000000000000cd1fad0593d2dbf0 Content-Type: text/plain; charset="UTF-8" On Mon, Sep 30, 2019 at 12:21 PM Eli Zaretskii wrote: > Patches welcome. To quote Barney Stinson, "Challenge accepted!" > I don't think it should be too hard to write that. Didn't know you were an optimist. Ok. The following extremely simple patch (with no documentation, etc, and horrible, *horrible* face names because I couldn't think of anything better) seems to work in the various tests I've done in absolute, visual and relative modes. Now, I'm not sure about code (try_cursor_movement and try_window_id) that compare the line-number and line-number-current-line faces for optimization. Performance seems to be fine, and I haven't seen any obvious visual glitch. Also, this in maybe_produce_line_number: /* Compute point's line number if needed. */ if ((EQ (Vdisplay_line_numbers, Qrelative) || EQ (Vdisplay_line_numbers, Qvisual) || lnum_face_id != current_lnum_face_id) && !it->pt_lnum) should perhaps compare curremt_lnum_face_id also with the face_ids of the two new faces. ? diff --git i/lisp/faces.el w/lisp/faces.el index 9c5ffe1e59..0d9107a6a0 100644 --- i/lisp/faces.el +++ w/lisp/faces.el @@ -2391,4 +2391,35 @@ line-number-current-line :group 'display-line-numbers) +(defface line-number-ends-5 + '((t :inherit line-number)) + "Face for displaying line numbers that end in 5. +That is, multiple of 5 but not of 10. +This face is used when `display-line-numbers' is non-nil. + +If you customize the font of this face, make sure it is a +monospaced font, otherwise line numbers will not line up, +and text lines might move horizontally as you move through +the buffer. Similarly, making this face's font different +from that of the `line-number' face could produce such +unwanted effects." + :version "27.1" + :group 'basic-faces + :group 'display-line-numbers) + +(defface line-number-ends-0 + '((t :inherit line-number)) + "Face for displaying line numbers that are multiples of 10. +This face is used when `display-line-numbers' is non-nil. + +If you customize the font of this face, make sure it is a +monospaced font, otherwise line numbers will not line up, +and text lines might move horizontally as you move through +the buffer. Similarly, making this face's font different +from that of the `line-number' face could produce such +unwanted effects." + :version "27.1" + :group 'basic-faces + :group 'display-line-numbers) + ;; Definition stolen from display-line-numbers. (defface fill-column-indicator diff --git i/src/xdisp.c w/src/xdisp.c index 95895ec3ac..7d5c0b11f4 100644 --- i/src/xdisp.c +++ w/src/xdisp.c @@ -21483,4 +21483,8 @@ maybe_produce_line_number (struct it *it) int current_lnum_face_id = merge_faces (it->w, Qline_number_current_line, 0, DEFAULT_FACE_ID); + int mul5_lnum_face_id + = merge_faces (it->w, Qline_number_ends_5, 0, DEFAULT_FACE_ID); + int mul10_lnum_face_id + = merge_faces (it->w, Qline_number_ends_0, 0, DEFAULT_FACE_ID); /* Compute point's line number if needed. */ if ((EQ (Vdisplay_line_numbers, Qrelative) @@ -21576,4 +21580,8 @@ maybe_produce_line_number (struct it *it) && it->what != IT_EOB) tem_it.face_id = current_lnum_face_id; + else if (lnum_to_display % 10 == 0) + tem_it.face_id = mul10_lnum_face_id; + else if (lnum_to_display % 5 == 0) + tem_it.face_id = mul5_lnum_face_id; else tem_it.face_id = lnum_face_id; @@ -32971,4 +32979,6 @@ syms_of_xdisp (void) DEFSYM (Qline_number, "line-number"); DEFSYM (Qline_number_current_line, "line-number-current-line"); + DEFSYM (Qline_number_ends_5, "line-number-ends-5"); + DEFSYM (Qline_number_ends_0, "line-number-ends-0"); /* Name of a text property which disables line-number display. */ DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable"); --000000000000cd1fad0593d2dbf0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Mon, Sep 30, 2019 at 12:21 PM Eli Zaretskii <eliz@gnu.org> wrote:

> P= atches welcome.=C2=A0

To quote Barney Stinson, &qu= ot;Challenge accepted!"

> I don't thin= k it should be too hard to write that.

Didn= 9;t know you were an optimist.

Ok. The following e= xtremely simple patch (with no documentation, etc, and horrible, *horrible*= face names because I couldn't think of anything better) seems to work = in the various tests I've done in absolute, visual and relative modes.<= /div>

Now, I'm not sure about code (try_cursor_movem= ent and try_window_id) that compare the line-number and line-number-current= -line faces for optimization. Performance seems to be fine, and I haven'= ;t seen any obvious visual glitch.

Also, this in m= aybe_produce_line_number:

=C2=A0 /* Compute point&= #39;s line number if needed. =C2=A0*/
=C2=A0 if ((EQ (Vdisplay_line_numb= ers, Qrelative)
=C2=A0 =C2=A0 =C2=A0 =C2=A0|| EQ (Vdisplay_line_numbers,= Qvisual)
=C2=A0 =C2=A0 =C2=A0 =C2=A0|| lnum_face_id !=3D current_lnum_f= ace_id)
=C2=A0 =C2=A0 =C2=A0 && !it->pt_lnum)
<= br>
should perhaps compare=C2=A0curremt_lnum_face_id also with th= e face_ids of the two new faces. ?


diff --git = i/lisp/faces.el w/lisp/faces.el
index 9c5ffe1e59..0d9107a6a0 100644
-= -- i/lisp/faces.el
+++ w/lisp/faces.el
@@ -2391,4 +2391,35 @@ line-nu= mber-current-line
=C2=A0 =C2=A0:group 'display-line-numbers)
=C2= =A0
+(defface line-number-ends-5
+ =C2=A0'((t :inherit line-numbe= r))
+ =C2=A0"Face for displaying line numbers that end in 5.
+Th= at is, multiple of 5 but not of 10.
+This face is used when `display-lin= e-numbers' is non-nil.
+
+If you customize the font of this face,= make sure it is a
+monospaced font, otherwise line numbers will not lin= e up,
+and text lines might move horizontally as you move through
+th= e buffer.=C2=A0 Similarly, making this face's font different
+from t= hat of the `line-number' face could produce such
+unwanted effects.&= quot;
+ =C2=A0:version "27.1"
+ =C2=A0:group 'basic-fac= es
+ =C2=A0:group 'display-line-numbers)
+
+(defface line-numb= er-ends-0
+ =C2=A0'((t :inherit line-number))
+ =C2=A0"Face = for displaying line numbers that are multiples of 10.
+This face is used= when `display-line-numbers' is non-nil.
+
+If you customize the = font of this face, make sure it is a
+monospaced font, otherwise line nu= mbers will not line up,
+and text lines might move horizontally as you m= ove through
+the buffer.=C2=A0 Similarly, making this face's font di= fferent
+from that of the `line-number' face could produce such
+= unwanted effects."
+ =C2=A0:version "27.1"
+ =C2=A0:gr= oup 'basic-faces
+ =C2=A0:group 'display-line-numbers)
+
= =C2=A0;; Definition stolen from display-line-numbers.
=C2=A0(defface fil= l-column-indicator
diff --git i/src/xdisp.c w/src/xdisp.c
index 95895= ec3ac..7d5c0b11f4 100644
--- i/src/xdisp.c
+++ w/src/xdisp.c
@@ -2= 1483,4 +21483,8 @@ maybe_produce_line_number (struct it *it)
=C2=A0 =C2= =A0int current_lnum_face_id
=C2=A0 =C2=A0 =C2=A0=3D merge_faces (it->= w, Qline_number_current_line, 0, DEFAULT_FACE_ID);
+ =C2=A0int mul5_lnum= _face_id
+ =C2=A0 =C2=A0=3D merge_faces (it->w, Qline_number_ends_5, = 0, DEFAULT_FACE_ID);
+ =C2=A0int mul10_lnum_face_id
+ =C2=A0 =C2=A0= =3D merge_faces (it->w, Qline_number_ends_0, 0, DEFAULT_FACE_ID);
=C2= =A0 =C2=A0/* Compute point's line number if needed. =C2=A0*/
=C2=A0 = =C2=A0if ((EQ (Vdisplay_line_numbers, Qrelative)
@@ -21576,4 +21580,8 @@= maybe_produce_line_number (struct it *it)
=C2=A0 =C2=A0&& it-&= gt;what !=3D IT_EOB)
=C2=A0 tem_it.face_id =3D current_lnum_face_id;
= + =C2=A0 =C2=A0 =C2=A0else if (lnum_to_display % 10 =3D=3D 0)
+ tem_it.f= ace_id =3D mul10_lnum_face_id;
+ =C2=A0 =C2=A0 =C2=A0else if (lnum_to_di= splay % 5 =3D=3D 0)
+ tem_it.face_id =3D mul5_lnum_face_id;
=C2=A0 = =C2=A0 =C2=A0 =C2=A0else
=C2=A0 tem_it.face_id =3D lnum_face_id;
@@ -= 32971,4 +32979,6 @@ syms_of_xdisp (void)
=C2=A0 =C2=A0DEFSYM (Qline_numb= er, "line-number");
=C2=A0 =C2=A0DEFSYM (Qline_number_current_= line, "line-number-current-line");
+ =C2=A0DEFSYM (Qline_numbe= r_ends_5, "line-number-ends-5");
+ =C2=A0DEFSYM (Qline_number_= ends_0, "line-number-ends-0");
=C2=A0 =C2=A0/* Name of a text = property which disables line-number display. =C2=A0*/
=C2=A0 =C2=A0DEFSY= M (Qdisplay_line_numbers_disable, "display-line-numbers-disable")= ;

--000000000000cd1fad0593d2dbf0--