From: Eli Zaretskii <eliz@gnu.org>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 36472@debbugs.gnu.org
Subject: bug#36472: 27.0.50; Convey information by showing line numbers using different colors?
Date: Mon, 08 Jul 2019 15:23:09 +0300 [thread overview]
Message-ID: <83d0ik7m1e.fsf@gnu.org> (raw)
In-Reply-To: <b2985e09-62ce-6bca-5830-78eb4457cba6@yandex.ru> (message from Dmitry Gutov on Mon, 8 Jul 2019 02:46:50 +0300)
> Cc: 36472@debbugs.gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 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.
Right.
> > 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
problems.
> > 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.
next prev parent reply other threads:[~2019-07-08 12:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-02 11:14 bug#36472: 27.0.50; Convey information by showing line numbers using different colors? Dmitry Gutov
2019-07-02 14:30 ` Eli Zaretskii
2019-07-02 15:09 ` Dmitry Gutov
2019-07-02 15:38 ` Eli Zaretskii
2019-07-02 15:49 ` Dmitry Gutov
2019-07-02 16:27 ` Eli Zaretskii
2019-07-03 14:19 ` Dmitry Gutov
2019-07-03 16:14 ` Eli Zaretskii
2019-07-07 23:46 ` Dmitry Gutov
2019-07-08 12:23 ` Eli Zaretskii [this message]
2019-07-15 15:16 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83d0ik7m1e.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=36472@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
/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 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.