Subject: Re: bug#62780: 30.0.50; Redisplay gets slow when using Org tables + show-trailing-whitespace

From: Ihor Radchenko <[email-masked]>
Date: Tue, 11 Apr 2023 19:41:01 +0000

Eli Zaretskii <[email-masked]> writes:

> show-trailing-whitespace disables quite a few redisplay optimizations,
> including even the cursor-motion optimization (when nothing has
> changed on display except the position of point).  And full thorough
> redisplay becomes slow when you have relatively long lines, because
> Emacs is forced to consider all of them.

Well. But it is not even that big of a file. And the lines are shorter
than window width.

I could understand Emacs lagging on some really large file or long
lines, but this does not look large at all!

> In addition, org-table seems to put a large number of 'display'
> properties (like, 2 per cell?), which also slows down redisplay.

These properties are for the purpose of bidirectional ordering:

(defconst org-table--separator-space-pre
  (propertize " " 'display '(space :relative-width 1))
  "Space used in front of fields when aligning the table.
This space serves as a segment separator for the purposes of the
bidirectional reordering.
Note that `org-table--separator-space-pre' is not `eq' to
`org-table--separator-space-post'.  This is done to prevent Emacs from
visually merging spaces in an empty table cell.  See bug#45915.")

Maybe there is a better way?

> Are you saying there's been a regression in Emacs 30 in this situation
> wrt Emacs 29 and Emacs 28?  I don't think I see a regression in my
> testing here.

No, I do not mean a regression. But the slowdown appears to be
unreasonable for such a small test case. What is the point having
`show-trailing-whitespace' if it is this much inefficient? Maybe a
simple font-lock rule can be better?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>