[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Colorful line numbers

From: João Távora
Subject: Re: Colorful line numbers
Date: Fri, 22 Jul 2022 14:53:12 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

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. 
> I don't understand what that means.  Querying the properties how?

With the C equivalent of get-text-property.  textget() or
Ftext_properties_at(), or some callee of those.  The lightest possible

> And doing what with the results of those queries? Eventually, you need a face.

If the query (or "lookup" if you prefer) produces something non-nil, the
value it returns is a LispObject which is a face.

>> > 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. 
> Well, good luck with that!  Because I don't think this can be
> reasonably implemented from Lisp: there are too many aspects involved
> that are hidden from Lisp.

I don't foresee any great difficulties in selecting a region of a buffer
and propertizing the text with some arbitrary 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
> I guess this gets back to the question about "queries" and their
> processing?

To try to clear up any doubts, I meant nothing fancy with the word
"query": by it I mean inspecting and retrieving the value of a text
property at a certain buffer position.

> The answer depends on the condition(s) which that "valid buffer
> position" should satisfy.

That buffer position should satisfy just one condition: it should exist
in the same line to which the line number about to be produced
(maybe...)  by 'maybe_produce_line_number()' refers to.

>In general, IT_CHARPOS(*it) gives you the next buffer position to be

If I'm reading the code correctly, the particular 'it' argument to
maybe_produce_line_number _does not_ refer to a buffer position, rather
to a thing that may be displayed.  In that case, I have to advance (a
copy) of this iterator until I find such a buffer position. Otherwise
(if it _does_ refer to some buffer text) I think my question is closer
to being answered.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]