[Top][All Lists]

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

bug#36472: 27.0.50; Convey information by showing line numbers using dif

From: Eli Zaretskii
Subject: bug#36472: 27.0.50; Convey information by showing line numbers using different colors?
Date: Mon, 08 Jul 2019 15:23:09 +0300

> Cc: address@hidden
> From: Dmitry Gutov <address@hidden>
> Date: Mon, 8 Jul 2019 02:46:50 +0300
> > IOW, a line number is not a good API design in this case, because the
> > display engine doesn't always know the absolute line number of each
> > line, whereas your function must have an unambiguous descriptor of the
> > line's location.
> The display engine doesn't, but the display-line-numbers feature clearly 
> does. Knowing line numbers is in its job description.
> Or are you hinting at some optimization where, when the style is 
> `relative', it doesn't bother to compute the absolute numbers?

Yes.  In particular, in the 'visual' style.

> Anyway, it doesn't matter for this particular use case: I only need 
> line-beginning-position, not its absolute number.


> > I assume the face attributes can only specify colors?
> Sure. Although some other users of this hook could also want to specify 
> other properties. Maybe we'll want to combine the return values?

If the face attributes make characters wider or narrower than the
faces of other numbers, you will have unpleasant horizontal movement
of the line's text.  Colors can never cause this.

> >> Normally they are changed in after-save-hook. But there is an option
> >> that makes that happen on a timer.
> > 
> > Ouch!  Another performance killer.
> That feature already exists, you know. And it updates fringe or margin 
> indicators. People seem to like it. In my limited testing, I haven't 
> observed any major slowdowns.

I meant it will be a slow-down for redisplay.

> > Redisplay should and does happen, but it tries very hard to determine
> > which portions of the window actually need to be redrawn.  For some
> > features, the answer is "the entire window", and that makes redisplay
> > slower.
> So is there an optimization that looks at new overlays, checks that it 
> only has a before-string with a fringe spec, and then only updates the 
> fringe?

Some of that.  We know whether the overlays changed, and we have tests
for whether the fringe needs to be updated on a per-line basis.

> > My question was how local are the changes caused by this
> > feature, i.e. could it happen that changes in some place in a buffer
> > cause changes on display in remote places?
> In my case, the hook function would just look up a property on overlays 
> at bol. Thus no far-reaching changes.

What events trigger changes in that property?

> But it's hard to guarantee, API-wise.

Yes, this is always a concern with such hooks.

> > I don't know about "allowed".  Would it be reasonable to say don't
> > switch buffers and/or don't select another window?
> Sure, I guess. Though I would like to know why a temporary changes in 
> the current buffer or the selected window would be so bad.

Because when the display engine works on a window, it always makes
that window's buffer the current buffer.  If some Lisp we call changes
that, redisplay will be confused.  So we need to save and restore the
current buffer (and sometimes also the selected frame), to avoid such

> > There are also
> > things you cannot really disallow, because the caller doesn't know
> > enough about what happens under the hood and doesn't control that.
> > For example, if the Lisp function calls vertical-motion or
> > posn-at-point, that invokes display routines, so the code in question
> > could be re-entered; but how can we tell Lisp programmers "don't call
> > anything that could call vertical-motion"?  And where to put such
> > limitations for them to be visible and discoverable enough in the
> > first place?
> I suppose the display code could check for re-entrance (e.g. by setting 
> a variable at the beginning of the redisplay routine) and abort any such 
> attempts with a Lisp-level error. Thus the limitation would be enforced 
> at runtime, which is not perfect, but if the error is intelligible, it 
> shouldn't be hard for a programmer to understand the reasons and change 
> their code.

Errors signaled during redisplay are caught and only logged in
*Messages*, because displaying them would re-enter redisplay and cause
the same error again.  So such errors are not very visible, and could
go undetected for a long time.  IOW, it is better to (tediously)
protect ourselves than signal errors in such situations.

reply via email to

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