1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-27 10:21:14 -08:00

Improve locked narrowing around low-level hooks.

* src/buffer.c (syms_of_buffer): Two new variables,
'long-line-locked-narrowing-region-size' and
'long-line-locked-narrowing-bol-search-limit', to make the locked
narrowing around low-level hooks configurable.

Increase the default value of 'long-line-threshold'.  After
carefully considering the (few) bug reports about long line
optimizations, I concluded that the previous default value was too
low.

* src/xdisp.c (get_locked_narrowing_begv)
(get_locked_narrowing_zv): Two new functions.
(handle_fontified_prop, reseat): Use them.

* src/keyboard.c (safe_run_hooks_maybe_narrowed): Use them.

* src/dispextern.h (struct it): Add two new fields to store the
values returned by these functions.
Make them externally visible.

* src/editfns.c: (Fsave_restriction): Update docstring.
This commit is contained in:
Gregory Heytings 2022-11-26 14:09:41 +00:00
parent 16b8b0d1e0
commit 558084c7f7
5 changed files with 92 additions and 12 deletions

View file

@ -5882,7 +5882,40 @@ this threshold.
If nil, these display shortcuts will always remain disabled.
There is no reason to change that value except for debugging purposes. */);
XSETFASTINT (Vlong_line_threshold, 10000);
XSETFASTINT (Vlong_line_threshold, 50000);
DEFVAR_INT ("long-line-locked-narrowing-region-size",
long_line_locked_narrowing_region_size,
doc: /* Region size for locked narrowing in buffers with long lines.
This variable has effect only in buffers which contain one or more
lines whose length is above `long-line-threshold', which see. For
performance reasons, in such buffers, low-level hooks such as
`fontification-functions' or `post-command-hook' are executed on a
narrowed buffer, with a narrowing locked with `narrowing-lock'. This
variable specifies the size of the narrowed region around point.
To disable that narrowing, set this variable to 0.
There is no reason to change that value except for debugging purposes. */);
long_line_locked_narrowing_region_size = 500000;
DEFVAR_INT ("long-line-locked-narrowing-bol-search-limit",
long_line_locked_narrowing_bol_search_limit,
doc: /* Limit for beginning of line search in buffers with long lines.
This variable has effect only in buffers which contain one or more
lines whose length is above `long-line-threshold', which see. For
performance reasons, in such buffers, low-level hooks such as
`fontification-functions' or `post-command-hook' are executed on a
narrowed buffer, with a narrowing locked with `narrowing-lock'. The
variable `long-line-locked-narrowing-region-size' specifies the size
of the narrowed region around point. This variable, which should be a
small integer, specifies the number of characters by which that region
can be extended backwards to start it at the beginning of a line.
There is no reason to change that value except for debugging purposes. */);
long_line_locked_narrowing_bol_search_limit = 128;
DEFVAR_INT ("large-hscroll-threshold", large_hscroll_threshold,
doc: /* Horizontal scroll of truncated lines above which to use redisplay shortcuts.