From: Dmitry Gutov <dgutov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 36472@debbugs.gnu.org
Subject: bug#36472: 27.0.50; Convey information by showing line numbers using different colors?
Date: Mon, 8 Jul 2019 02:46:50 +0300 [thread overview]
Message-ID: <b2985e09-62ce-6bca-5830-78eb4457cba6@yandex.ru> (raw)
In-Reply-To: <83pnmrayei.fsf@gnu.org>
On 03.07.2019 19:14, Eli Zaretskii wrote:
> There's some misunderstanding here, perhaps mine. What I wanted to
> say is that you may get a relative line-number string such as "-2",
> which will probably tell you nothing about the position of that line.
Like I wrote in the example docstring, the hook functions would be
called with point temporary changed to the corresponding line's
beginning. You didn't like that, so I suggested the position would be
passed as a second parameter to the functions. Or it can be a dynamic
variable. Whichever option looks best to you.
> 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?
Anyway, it doesn't matter for this particular use case: I only need
line-beginning-position, not its absolute number.
>> Although if we just make a hook that would return a face to use, that
>> would work just as well for me.
>
> A face would be much easier to use from the display engine, I think.
> 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?
>> Either the calling code would temporarily change point
>
> That's an absolute no-no for the display engine, because such changes
> sooner or later leak to userland and cause adverse effects.
OK.
>> 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.
> 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?
> 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. But it's hard to guarantee, API-wise.
>> But on that subject, maybe it'd be fine to just document what the
>> functions on the new hook are allowed and not allowed to do. And then
>> see if we really have to add actual restrictions to force third-party
>> code to behave.
>
> 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.
> 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.
next prev parent reply other threads:[~2019-07-07 23:46 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 [this message]
2019-07-08 12:23 ` Eli Zaretskii
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=b2985e09-62ce-6bca-5830-78eb4457cba6@yandex.ru \
--to=dgutov@yandex.ru \
--cc=36472@debbugs.gnu.org \
--cc=eliz@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 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.