unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Colorful line numbers
Date: Fri, 22 Jul 2022 13:02:01 +0100	[thread overview]
Message-ID: <87zgh1nyo6.fsf@gmail.com> (raw)
In-Reply-To: <837d45l6ge.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 22 Jul 2022 14:42:09 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> Does checking for a given text property on some buffer text call into
>> Lisp?  If it isn't, and it's cheap, then this hypothetical feature could
>> have very low overhead when not used.
> You want the line number to have the same face as the character
> displayed immediately after it?

Not the "same face", rather some face which is the result of querying
text properties on that text. 

> That can be done from C without calling Lisp, but how would that work
> reliably?  Any change in the buffer text will risk breaking the
> feature.

It's up to the Lisp package that is interested in this functionality to
set or unset the correct text property. 

> And even this is already a complication I'd like to avoid: line number
> of a line is rendered before we examine the buffer text of the line
> (and even know whether there is any text there).  Now we would need to
> look forward in the buffer and get text properties of that text.
> Which might not work correctly, btw, if jit-lock was not yet invoked
> to produce the faces there.

See above. This wouldn't be a problem because I'm not interesting in
choosing the same face that jit-lock selected.  The indirection would be
some text property, say line-number-face

> Likewise if the line is hscrolled, so
> that the first character displayed to the right of the line number is
> not the first character of the physical line.

It would be up to the Lisp package to propertize the whole line with
'line-number-face'.

>> Even if you're opposed the idea, could you perhaps some pointers on how
>> to implement it, so that I try my hand at it and benchmark the
>> before/after?
>
> The implementation is in maybe_produce_line_number in xdisp.c.

Yes, I've seen it (this is would I discovered the closed set of faces).
But I'm not familiar with xdisp.c code and how to get to the buffer text
about to be displayed besides the line number (if it indeed exists) and
the associated text properties of that text.  The only argument passed
to maybe_produce_line_number is a 'struct it'.  How to go from there to
any valid buffer position of the same line that the 'struct it' refers
to?

> You can change the colors of the text without affecting the line
> numbers.  Line numbers have a distinct face for a good reason.

See above.  I'm not interested in having line number have exactly the
same face/color as any one of the characters in the buffer text.

>> I've recently discovered Jay Kamat's most excellent rmsbolt.el.  It is
>> is even better than godbolt.org in many aspects but is missing this last
>> feature, which I would like to add.  But instead of highlighting the
>> whole line, I thought it would be nicer and less distracting if I just
>> highlighted the line number's background.
>
> Why not put some indication on the fringe instead?

I'm experimenting with that, too.  Not the fringe, since it only works
on graphical displays, but the margin.

>> > And if they aren't enough, why cannot you use line-number-mode?
>> I do use line-number-mode, but I don't understand how it can help me
>> here.  AFAIK it shows me one line number at a time in the modeline, not
>> besides the text.
> Sorry, I meant linum-mode.

Ah.  I could indeed, but I would still like to experiment with the
display-line-numbers-mode.

João



  reply	other threads:[~2022-07-22 12:02 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-22  7:50 Colorful line numbers João Távora
2022-07-22 11:00 ` Eli Zaretskii
2022-07-22 11:29   ` João Távora
2022-07-22 11:42     ` Eli Zaretskii
2022-07-22 12:02       ` João Távora [this message]
2022-07-22 13:27         ` Eli Zaretskii
2022-07-22 13:53           ` João Távora
2022-07-22 14:33             ` Eli Zaretskii
2022-07-22 15:10               ` João Távora
2022-07-22 15:38                 ` Eli Zaretskii
2022-07-22 16:30                   ` rmsbolt.el [Was: Colorful line numbers] João Távora
2022-07-22 19:53                     ` Stefan Monnier
2022-07-23  6:13                     ` Eli Zaretskii
2022-07-23  9:35                       ` João Távora
2022-07-23 10:25                         ` Eli Zaretskii
2022-07-23 14:43                           ` Stefan Monnier
2022-07-23 15:52                             ` Eli Zaretskii
2022-07-23 16:31                               ` Stefan Monnier
2022-07-23 17:07                                 ` Colorful line numbers Eli Zaretskii
2022-07-23 18:18                                 ` rmsbolt.el [Was: Colorful line numbers] João Távora
2022-07-23 18:11                           ` João Távora
2022-07-23 14:53                     ` Jay Kamat
2022-07-23 17:25                       ` Stefan Monnier
2022-07-23 17:34                         ` Eglot to core [Was: rmsbolt.el [Was: Colorful line numbers]] João Távora
2022-07-23 17:52                           ` Stefan Monnier
2022-07-24 18:58                             ` João Távora
2022-07-24 19:04                               ` Stefan Monnier
2022-07-25  1:05                               ` Po Lu
2022-07-25  2:45                                 ` Stefan Monnier
2022-07-25  5:55                                   ` Philip Kaludercic
2022-07-25 15:31                                     ` Stefan Monnier
2022-07-25  6:23                                   ` Po Lu
2022-07-25 10:49                                     ` Bozhidar Batsov
2022-07-25 11:01                                     ` João Távora
2022-07-25 11:50                                       ` Felician Nemeth
2022-07-25 12:27                                         ` João Távora
2022-07-25 12:29                                           ` João Távora
2022-07-25 15:00                                           ` Felician Nemeth
2022-07-25 15:41                                             ` João Távora
2022-07-26  8:12                                               ` Felician Nemeth
2022-07-26  8:21                                                 ` João Távora
2022-07-26  8:55                                                   ` Felician Nemeth
2022-07-25 16:07                                       ` Max Brieiev
2022-07-25 17:05                                         ` João Távora
2022-07-25 15:33                                     ` Stefan Monnier
2022-07-22 12:18 ` Colorful line numbers Dmitry Gutov
2022-07-22 12:38 ` Stefan Monnier
2022-07-22 13:41   ` Dmitry Gutov
2022-07-22 14:01     ` João Távora
2022-07-22 23:32     ` Stefan Monnier
2022-07-23 18:50       ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zgh1nyo6.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).