summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorGregory Heytings <gregory@heytings.org>2022-07-16 19:06:38 +0000
committerGregory Heytings <gregory@heytings.org>2022-07-16 21:13:33 +0200
commite7b5912b235936b304701ba6b1e808d9b197fd4f (patch)
tree78cfbd3ab9c032e45a6ba0f1e763807a01a9a3ec /src/buffer.c
parent9de00e5fda2e04316357bd8cf0d8094c63ff171b (diff)
downloademacs-e7b5912b235936b304701ba6b1e808d9b197fd4f.tar.gz
emacs-e7b5912b235936b304701ba6b1e808d9b197fd4f.tar.bz2
emacs-e7b5912b235936b304701ba6b1e808d9b197fd4f.zip
Improvements to long lines handling.
* src/buffer.h (struct buffer): New field 'long_line_optimizations_p'. * src/buffer.c (syms_of_buffer): New variable 'long-line-threshold'. (reset_buffer): Initialize the 'long_line_optimizations_p' field. (Fbuffer_swap_text): Handle it. * src/xdisp.c (redisplay_window): Set 'long_line_optimizations_p' when a buffer contains long lines. (init_iterator): Use 'long_line_optimizations_p'. (get_narrowed_begv): Update. (SET_WITH_NARROWED_BEGV): New macro. (unwind_narrowed_begv): New internal function used by the new macro. (back_to_previous_line_start, get_visually_first_element, move_it_vertically_backward): Use the new macro. * src/search.c (find_newline1): Make it externally visible. * src/lisp.h: Make 'find_newline1' externally visible. * src/dispextern.h (struct it): Update comment. Remove the 'WITH_NARROWED_BEGV' macro. * etc/NEWS: Mention the 'long-line-threshold' variable.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 509ce51b55e..a777668e44b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -984,6 +984,7 @@ reset_buffer (register struct buffer *b)
/* It is more conservative to start out "changed" than "unchanged". */
b->clip_changed = 0;
b->prevent_redisplay_optimizations_p = 1;
+ b->long_line_optimizations_p = 0;
bset_backed_up (b, Qnil);
bset_local_minor_modes (b, Qnil);
BUF_AUTOSAVE_MODIFF (b) = 0;
@@ -2445,6 +2446,7 @@ results, see Info node `(elisp)Swapping Text'. */)
swapfield (bidi_paragraph_cache, struct region_cache *);
current_buffer->prevent_redisplay_optimizations_p = 1;
other_buffer->prevent_redisplay_optimizations_p = 1;
+ swapfield (long_line_optimizations_p, bool_bf);
swapfield (overlays_before, struct Lisp_Overlay *);
swapfield (overlays_after, struct Lisp_Overlay *);
swapfield (overlay_center, ptrdiff_t);
@@ -6423,6 +6425,14 @@ Since `clone-indirect-buffer' calls `make-indirect-buffer', this hook
will run for `clone-indirect-buffer' calls as well. */);
Vclone_indirect_buffer_hook = Qnil;
+ DEFVAR_LISP ("long-line-threshold", Vlong_line_threshold,
+ doc: /* Line length above which specific display optimizations are used.
+Display optimizations for long lines will automatically be enabled in
+buffers which contain one or more lines whose length is above that
+threshold.
+When nil, these display optimizations are disabled. */);
+ XSETFASTINT (Vlong_line_threshold, 10000);
+
defsubr (&Sbuffer_live_p);
defsubr (&Sbuffer_list);
defsubr (&Sget_buffer);