From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: eliz@gnu.org, 72830@debbugs.gnu.org, juri@linkov.net
Subject: bug#72830: Big rectangular selections are slow
Date: Thu, 29 Aug 2024 10:09:06 +0200 [thread overview]
Message-ID: <3F6C6CAB-8CD1-4336-B1D1-949E716139FE@gmail.com> (raw)
In-Reply-To: <jwv7cc14v8f.fsf-monnier+emacs@gnu.org>
27 aug. 2024 kl. 21.16 skrev Eli Zaretskii <eliz@gnu.org>:
>> It has to be done with the display code, but does not have to be as
>> part of redisplay. We can use functions like vertical-motion,
>> window-text-pixel-size, posn-at-point, and other similar APIs, which
>> all employ display code that performs layout-related calculations
>> without actually displaying anything.
>
> Btw, the horizontal dimensions of the window are known in advance even
> without calling the display code, and we could use posn-at-x-y to find
> the buffer position that corresponds to the right edge of the window.
> Isn't that what's needed to avoid highlighting the portions of text
> that are outside of the viewport?
Unfortunately I don't think that helps. The way it works now is that a pre-redisplay function puts a highlight overlay on every line in the rectangular selection. All this work and memory completely tanks performance.
Only putting overlays on lines where they can be seen would solve the problem, but we have to know the first and last line that will be displayed. I tried using `posn-at-x-y` but it doesn't seem to recompute `window-start` so it has the same problem.
27 aug. 2024 kl. 21.44 skrev Stefan Monnier <monnier@iro.umontreal.ca>:
> I rely on it on a regular basis, and I'm probably not the only one, so
> even if we disable it by default, we should make it work well enough for
> large rectangular regions.
Yes, that's probably true. Let's deal with that concern later; it's orthogonal to the redisplay problem.
> There might be some remaining issues with (re)running the
> `pre-redisplay-function(s)` when redisplay forces a change in
> `window-start` (or in the unlikely case where the highlighting moves the
> `window-end` further), but these are things we need to fix anyway.
That's what I wondered how to deal with. I agree we can probably assume that highlighting won't affect the viewport in any substantial way.
To be clear, just using the (inaccurate) window-start and window-end to clip the setting of highlight overlays works very well and with excellent speed until the viewport moves, in which case it no longer does.
> There are further issues when several windows display the buffer.
Are there? The highlight overlay is set with a `window` parameter that keeps it visible in one window only.
> We could also move some of the work to jit-lock, which would have the
> advantage that it would additionally be able to skip over (large) chunks
> that are marked as `invisible`.
Not sure how this would work. Isn't it guided by (comparatively persistent) `fontified` properties?
next prev parent reply other threads:[~2024-08-29 8:09 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 12:39 bug#72830: Big rectangular selections are slow Mattias Engdegård
2024-08-27 13:48 ` Eli Zaretskii
2024-08-27 14:04 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-27 16:42 ` Mattias Engdegård
2024-08-27 17:47 ` Eli Zaretskii
2024-08-27 19:16 ` Eli Zaretskii
2024-08-27 18:23 ` Juri Linkov
2024-08-27 18:55 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-27 19:03 ` Eli Zaretskii
2024-08-27 19:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 3:56 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 10:22 ` Mattias Engdegård
2024-08-29 11:18 ` Mattias Engdegård
2024-08-29 8:09 ` Mattias Engdegård [this message]
2024-08-29 20:04 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-30 15:20 ` Mattias Engdegård
2024-09-20 12:53 ` Mattias Engdegård
2024-09-21 2:07 ` Stefan Kangas
2024-09-21 8:26 ` Eli Zaretskii
2024-09-21 3:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-22 13:27 ` Mattias Engdegård
2024-09-22 14:12 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-22 15:16 ` Mattias Engdegård
2024-09-22 15:32 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-22 16:22 ` Mattias Engdegård
2024-09-22 17:37 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-23 10:42 ` Mattias Engdegård
2024-08-29 0:45 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 3:39 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 4:44 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 0:40 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=3F6C6CAB-8CD1-4336-B1D1-949E716139FE@gmail.com \
--to=mattias.engdegard@gmail.com \
--cc=72830@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=juri@linkov.net \
--cc=monnier@iro.umontreal.ca \
/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).