aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2023-02-17 11:14:38 +0100
committerAndrea Corallo2023-02-17 11:14:38 +0100
commitd6e4f2437202f13bec85d68c003700d06aa343e6 (patch)
treec8cffc88721cc9a82b5565189d42c91effa296ec /src
parentce4a066ed1ea07f651f439132017db8ceb32779c (diff)
parenta555abc56d5270cebe94f904189526d7ac433a94 (diff)
downloademacs-d6e4f2437202f13bec85d68c003700d06aa343e6.tar.gz
emacs-d6e4f2437202f13bec85d68c003700d06aa343e6.zip
Merge 'emacs-29' into 'feature/inhibit-native-comp-cleanup'
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c47
-rw-r--r--src/editfns.c118
-rw-r--r--src/keyboard.c31
-rw-r--r--src/xdisp.c38
4 files changed, 121 insertions, 113 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 38648519ba0..df1f5206668 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5916,40 +5916,41 @@ If nil, these display shortcuts will always remain disabled.
5916There is no reason to change that value except for debugging purposes. */); 5916There is no reason to change that value except for debugging purposes. */);
5917 XSETFASTINT (Vlong_line_threshold, 50000); 5917 XSETFASTINT (Vlong_line_threshold, 50000);
5918 5918
5919 DEFVAR_INT ("long-line-locked-narrowing-region-size", 5919 DEFVAR_INT ("long-line-optimizations-region-size",
5920 long_line_locked_narrowing_region_size, 5920 long_line_optimizations_region_size,
5921 doc: /* Region size for locked narrowing in buffers with long lines. 5921 doc: /* Region size for narrowing in buffers with long lines.
5922 5922
5923This variable has effect only in buffers which contain one or more 5923This variable has effect only in buffers in which
5924lines whose length is above `long-line-threshold', which see. For 5924`long-line-optimizations-p' is non-nil. For performance reasons, in
5925performance reasons, in such buffers, low-level hooks such as 5925such buffers, the `fontification-functions', `pre-command-hook' and
5926`fontification-functions' or `post-command-hook' are executed on a 5926`post-command-hook' hooks are executed on a narrowed buffer around
5927narrowed buffer, with a narrowing locked with `narrowing-lock'. This 5927point, as if they were called in a `with-restriction' form with a label.
5928variable specifies the size of the narrowed region around point. 5928This variable specifies the size of the narrowed region around point.
5929 5929
5930To disable that narrowing, set this variable to 0. 5930To disable that narrowing, set this variable to 0.
5931 5931
5932See also `long-line-locked-narrowing-bol-search-limit'. 5932See also `long-line-optimizations-bol-search-limit'.
5933 5933
5934There is no reason to change that value except for debugging purposes. */); 5934There is no reason to change that value except for debugging purposes. */);
5935 long_line_locked_narrowing_region_size = 500000; 5935 long_line_optimizations_region_size = 500000;
5936 5936
5937 DEFVAR_INT ("long-line-locked-narrowing-bol-search-limit", 5937 DEFVAR_INT ("long-line-optimizations-bol-search-limit",
5938 long_line_locked_narrowing_bol_search_limit, 5938 long_line_optimizations_bol_search_limit,
5939 doc: /* Limit for beginning of line search in buffers with long lines. 5939 doc: /* Limit for beginning of line search in buffers with long lines.
5940 5940
5941This variable has effect only in buffers which contain one or more 5941This variable has effect only in buffers in which
5942lines whose length is above `long-line-threshold', which see. For 5942`long-line-optimizations-p' is non-nil. For performance reasons, in
5943performance reasons, in such buffers, low-level hooks such as 5943such buffers, the `fontification-functions', `pre-command-hook' and
5944`fontification-functions' or `post-command-hook' are executed on a 5944`post-command-hook' hooks are executed on a narrowed buffer around
5945narrowed buffer, with a narrowing locked with `narrowing-lock'. The 5945point, as if they were called in a `with-restriction' form with a label.
5946variable `long-line-locked-narrowing-region-size' specifies the size 5946The variable `long-line-optimizations-region-size' specifies the
5947of the narrowed region around point. This variable, which should be a 5947size of the narrowed region around point. This variable, which should
5948small integer, specifies the number of characters by which that region 5948be a small integer, specifies the number of characters by which that
5949can be extended backwards to make it start at the beginning of a line. 5949region can be extended backwards to make it start at the beginning of
5950a line.
5950 5951
5951There is no reason to change that value except for debugging purposes. */); 5952There is no reason to change that value except for debugging purposes. */);
5952 long_line_locked_narrowing_bol_search_limit = 128; 5953 long_line_optimizations_bol_search_limit = 128;
5953 5954
5954 DEFVAR_INT ("large-hscroll-threshold", large_hscroll_threshold, 5955 DEFVAR_INT ("large-hscroll-threshold", large_hscroll_threshold,
5955 doc: /* Horizontal scroll of truncated lines above which to use redisplay shortcuts. 5956 doc: /* Horizontal scroll of truncated lines above which to use redisplay shortcuts.
diff --git a/src/editfns.c b/src/editfns.c
index 78d2c73ecbf..f83c5c7259b 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2659,7 +2659,11 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region,
2659 the (uninterned) Qoutermost_narrowing tag and records the narrowing 2659 the (uninterned) Qoutermost_narrowing tag and records the narrowing
2660 bounds that were set by the user and that are visible on display. 2660 bounds that were set by the user and that are visible on display.
2661 This alist is used internally by narrow-to-region, widen, 2661 This alist is used internally by narrow-to-region, widen,
2662 narrowing-lock, narrowing-unlock and save-restriction. */ 2662 internal--lock-narrowing, internal--unlock-narrowing and
2663 save-restriction. For efficiency reasons, an alist is used instead
2664 of a buffer-local variable: otherwise reset_outermost_narrowings,
2665 which is called during each redisplay cycle, would have to loop
2666 through all live buffers. */
2663static Lisp_Object narrowing_locks; 2667static Lisp_Object narrowing_locks;
2664 2668
2665/* Add BUF with its LOCKS in the narrowing_locks alist. */ 2669/* Add BUF with its LOCKS in the narrowing_locks alist. */
@@ -2763,7 +2767,10 @@ unwind_reset_outermost_narrowing (Lisp_Object buf)
2763 In particular, this function is called when redisplay starts, so 2767 In particular, this function is called when redisplay starts, so
2764 that if a Lisp function executed during redisplay calls (redisplay) 2768 that if a Lisp function executed during redisplay calls (redisplay)
2765 while a locked narrowing is in effect, the locked narrowing will 2769 while a locked narrowing is in effect, the locked narrowing will
2766 not be visible on display. */ 2770 not be visible on display.
2771 See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57207#140 and
2772 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57207#254 for example
2773 recipes that demonstrate why this is necessary. */
2767void 2774void
2768reset_outermost_narrowings (void) 2775reset_outermost_narrowings (void)
2769{ 2776{
@@ -2792,27 +2799,25 @@ narrowing_locks_save (void)
2792{ 2799{
2793 Lisp_Object buf = Fcurrent_buffer (); 2800 Lisp_Object buf = Fcurrent_buffer ();
2794 Lisp_Object locks = assq_no_quit (buf, narrowing_locks); 2801 Lisp_Object locks = assq_no_quit (buf, narrowing_locks);
2795 if (NILP (locks)) 2802 if (!NILP (locks))
2796 return Qnil; 2803 locks = XCAR (XCDR (locks));
2797 locks = XCAR (XCDR (locks));
2798 return Fcons (buf, Fcopy_sequence (locks)); 2804 return Fcons (buf, Fcopy_sequence (locks));
2799} 2805}
2800 2806
2801static void 2807static void
2802narrowing_locks_restore (Lisp_Object buf_and_saved_locks) 2808narrowing_locks_restore (Lisp_Object buf_and_saved_locks)
2803{ 2809{
2804 if (NILP (buf_and_saved_locks))
2805 return;
2806 Lisp_Object buf = XCAR (buf_and_saved_locks); 2810 Lisp_Object buf = XCAR (buf_and_saved_locks);
2807 Lisp_Object saved_locks = XCDR (buf_and_saved_locks); 2811 Lisp_Object saved_locks = XCDR (buf_and_saved_locks);
2808 narrowing_locks_remove (buf); 2812 narrowing_locks_remove (buf);
2809 narrowing_locks_add (buf, saved_locks); 2813 if (!NILP (saved_locks))
2814 narrowing_locks_add (buf, saved_locks);
2810} 2815}
2811 2816
2812static void 2817static void
2813unwind_narrow_to_region_locked (Lisp_Object tag) 2818unwind_narrow_to_region_locked (Lisp_Object tag)
2814{ 2819{
2815 Fnarrowing_unlock (tag); 2820 Finternal__unlock_narrowing (tag);
2816 Fwiden (); 2821 Fwiden ();
2817} 2822}
2818 2823
@@ -2821,7 +2826,7 @@ void
2821narrow_to_region_locked (Lisp_Object begv, Lisp_Object zv, Lisp_Object tag) 2826narrow_to_region_locked (Lisp_Object begv, Lisp_Object zv, Lisp_Object tag)
2822{ 2827{
2823 Fnarrow_to_region (begv, zv); 2828 Fnarrow_to_region (begv, zv);
2824 Fnarrowing_lock (tag); 2829 Finternal__lock_narrowing (tag);
2825 record_unwind_protect (restore_point_unwind, Fpoint_marker ()); 2830 record_unwind_protect (restore_point_unwind, Fpoint_marker ());
2826 record_unwind_protect (unwind_narrow_to_region_locked, tag); 2831 record_unwind_protect (unwind_narrow_to_region_locked, tag);
2827} 2832}
@@ -2829,10 +2834,12 @@ narrow_to_region_locked (Lisp_Object begv, Lisp_Object zv, Lisp_Object tag)
2829DEFUN ("widen", Fwiden, Swiden, 0, 0, "", 2834DEFUN ("widen", Fwiden, Swiden, 0, 0, "",
2830 doc: /* Remove restrictions (narrowing) from current buffer. 2835 doc: /* Remove restrictions (narrowing) from current buffer.
2831 2836
2832This allows the buffer's full text to be seen and edited, unless 2837This allows the buffer's full text to be seen and edited.
2833restrictions have been locked with `narrowing-lock', which see, in 2838
2834which case the narrowing that was current when `narrowing-lock' was 2839However, when restrictions have been set by `with-restriction' with a
2835called is restored. */) 2840label, `widen' restores the narrowing limits set by `with-restriction'.
2841To gain access to other portions of the buffer, use
2842`without-restriction' with the same label. */)
2836 (void) 2843 (void)
2837{ 2844{
2838 Fset (Qoutermost_narrowing, Qnil); 2845 Fset (Qoutermost_narrowing, Qnil);
@@ -2879,11 +2886,12 @@ When calling from Lisp, pass two arguments START and END:
2879positions (integers or markers) bounding the text that should 2886positions (integers or markers) bounding the text that should
2880remain visible. 2887remain visible.
2881 2888
2882When restrictions have been locked with `narrowing-lock', which see, 2889However, when restrictions have been set by `with-restriction' with a
2883`narrow-to-region' can be used only within the limits of the 2890label, `narrow-to-region' can be used only within the limits of these
2884restrictions that were current when `narrowing-lock' was called. If 2891restrictions. If the START or END arguments are outside these limits,
2885the START or END arguments are outside these limits, the corresponding 2892the corresponding limit set by `with-restriction' is used instead of the
2886limit of the locked restriction is used instead of the argument. */) 2893argument. To gain access to other portions of the buffer, use
2894`without-restriction' with the same label. */)
2887 (Lisp_Object start, Lisp_Object end) 2895 (Lisp_Object start, Lisp_Object end)
2888{ 2896{
2889 EMACS_INT s = fix_position (start), e = fix_position (end); 2897 EMACS_INT s = fix_position (start), e = fix_position (end);
@@ -2912,7 +2920,7 @@ limit of the locked restriction is used instead of the argument. */)
2912 2920
2913 /* Record the accessible range of the buffer when narrow-to-region 2921 /* Record the accessible range of the buffer when narrow-to-region
2914 is called, that is, before applying the narrowing. It is used 2922 is called, that is, before applying the narrowing. It is used
2915 only by narrowing-lock. */ 2923 only by internal--lock-narrowing. */
2916 Fset (Qoutermost_narrowing, list3 (Qoutermost_narrowing, 2924 Fset (Qoutermost_narrowing, list3 (Qoutermost_narrowing,
2917 Fpoint_min_marker (), 2925 Fpoint_min_marker (),
2918 Fpoint_max_marker ())); 2926 Fpoint_max_marker ()));
@@ -2932,31 +2940,18 @@ limit of the locked restriction is used instead of the argument. */)
2932 return Qnil; 2940 return Qnil;
2933} 2941}
2934 2942
2935DEFUN ("narrowing-lock", Fnarrowing_lock, Snarrowing_lock, 1, 1, 0, 2943DEFUN ("internal--lock-narrowing", Finternal__lock_narrowing,
2936 doc: /* Lock the current narrowing with TAG. 2944 Sinternal__lock_narrowing, 1, 1, 0,
2945 doc: /* Lock the current narrowing with LABEL.
2937 2946
2938When restrictions are locked, `narrow-to-region' and `widen' can be 2947This is an internal function used by `with-restriction'. */)
2939used only within the limits of the restrictions that were current when
2940`narrowing-lock' was called, unless the lock is removed by calling
2941`narrowing-unlock' with TAG.
2942
2943Locking restrictions should be used sparingly, after carefully
2944considering the potential adverse effects on the code that will be
2945executed within locked restrictions. It is typically meant to be used
2946around portions of code that would become too slow, and make Emacs
2947unresponsive, if they were executed in a large buffer. For example,
2948restrictions are locked by Emacs around low-level hooks such as
2949`fontification-functions' or `post-command-hook'.
2950
2951Locked restrictions are never visible on display, and can therefore
2952not be used as a stronger variant of normal restrictions. */)
2953 (Lisp_Object tag) 2948 (Lisp_Object tag)
2954{ 2949{
2955 Lisp_Object buf = Fcurrent_buffer (); 2950 Lisp_Object buf = Fcurrent_buffer ();
2956 Lisp_Object outermost_narrowing 2951 Lisp_Object outermost_narrowing
2957 = buffer_local_value (Qoutermost_narrowing, buf); 2952 = buffer_local_value (Qoutermost_narrowing, buf);
2958 /* If narrowing-lock is called without being preceded by 2953 /* If internal--lock-narrowing is ever called without being preceded
2959 narrow-to-region, do nothing. */ 2954 by narrow-to-region, do nothing. */
2960 if (NILP (outermost_narrowing)) 2955 if (NILP (outermost_narrowing))
2961 return Qnil; 2956 return Qnil;
2962 if (NILP (narrowing_lock_peek_tag (buf))) 2957 if (NILP (narrowing_lock_peek_tag (buf)))
@@ -2967,16 +2962,11 @@ not be used as a stronger variant of normal restrictions. */)
2967 return Qnil; 2962 return Qnil;
2968} 2963}
2969 2964
2970DEFUN ("narrowing-unlock", Fnarrowing_unlock, Snarrowing_unlock, 1, 1, 0, 2965DEFUN ("internal--unlock-narrowing", Finternal__unlock_narrowing,
2971 doc: /* Unlock a narrowing locked with (narrowing-lock TAG). 2966 Sinternal__unlock_narrowing, 1, 1, 0,
2967 doc: /* Unlock a narrowing locked with LABEL.
2972 2968
2973Unlocking restrictions locked with `narrowing-lock' should be used 2969This is an internal function used by `without-restriction'. */)
2974sparingly, after carefully considering the reasons why restrictions
2975were locked. Restrictions are typically locked around portions of
2976code that would become too slow, and make Emacs unresponsive, if they
2977were executed in a large buffer. For example, restrictions are locked
2978by Emacs around low-level hooks such as `fontification-functions' or
2979`post-command-hook'. */)
2980 (Lisp_Object tag) 2970 (Lisp_Object tag)
2981{ 2971{
2982 Lisp_Object buf = Fcurrent_buffer (); 2972 Lisp_Object buf = Fcurrent_buffer ();
@@ -2985,8 +2975,8 @@ by Emacs around low-level hooks such as `fontification-functions' or
2985 return Qnil; 2975 return Qnil;
2986} 2976}
2987 2977
2988Lisp_Object 2978static Lisp_Object
2989save_restriction_save (void) 2979save_restriction_save_1 (void)
2990{ 2980{
2991 if (BEGV == BEG && ZV == Z) 2981 if (BEGV == BEG && ZV == Z)
2992 /* The common case that the buffer isn't narrowed. 2982 /* The common case that the buffer isn't narrowed.
@@ -3009,8 +2999,8 @@ save_restriction_save (void)
3009 } 2999 }
3010} 3000}
3011 3001
3012void 3002static void
3013save_restriction_restore (Lisp_Object data) 3003save_restriction_restore_1 (Lisp_Object data)
3014{ 3004{
3015 struct buffer *cur = NULL; 3005 struct buffer *cur = NULL;
3016 struct buffer *buf = (CONSP (data) 3006 struct buffer *buf = (CONSP (data)
@@ -3078,13 +3068,28 @@ save_restriction_restore (Lisp_Object data)
3078 set_buffer_internal (cur); 3068 set_buffer_internal (cur);
3079} 3069}
3080 3070
3071Lisp_Object
3072save_restriction_save (void)
3073{
3074 Lisp_Object restr = save_restriction_save_1 ();
3075 Lisp_Object locks = narrowing_locks_save ();
3076 return Fcons (restr, locks);
3077}
3078
3079void
3080save_restriction_restore (Lisp_Object data)
3081{
3082 narrowing_locks_restore (XCDR (data));
3083 save_restriction_restore_1 (XCAR (data));
3084}
3085
3081DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0, 3086DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0,
3082 doc: /* Execute BODY, saving and restoring current buffer's restrictions. 3087 doc: /* Execute BODY, saving and restoring current buffer's restrictions.
3083The buffer's restrictions make parts of the beginning and end invisible. 3088The buffer's restrictions make parts of the beginning and end invisible.
3084\(They are set up with `narrow-to-region' and eliminated with `widen'.) 3089\(They are set up with `narrow-to-region' and eliminated with `widen'.)
3085This special form, `save-restriction', saves the current buffer's 3090This special form, `save-restriction', saves the current buffer's
3086restrictions, as well as their locks if they have been locked with 3091restrictions, including those that were set by `with-restriction' with a
3087`narrowing-lock', when it is entered, and restores them when it is exited. 3092label argument, when it is entered, and restores them when it is exited.
3088So any `narrow-to-region' within BODY lasts only until the end of the form. 3093So any `narrow-to-region' within BODY lasts only until the end of the form.
3089The old restrictions settings are restored even in case of abnormal exit 3094The old restrictions settings are restored even in case of abnormal exit
3090\(throw or error). 3095\(throw or error).
@@ -3102,7 +3107,6 @@ usage: (save-restriction &rest BODY) */)
3102 specpdl_ref count = SPECPDL_INDEX (); 3107 specpdl_ref count = SPECPDL_INDEX ();
3103 3108
3104 record_unwind_protect (save_restriction_restore, save_restriction_save ()); 3109 record_unwind_protect (save_restriction_restore, save_restriction_save ());
3105 record_unwind_protect (narrowing_locks_restore, narrowing_locks_save ());
3106 val = Fprogn (body); 3110 val = Fprogn (body);
3107 return unbind_to (count, val); 3111 return unbind_to (count, val);
3108} 3112}
@@ -4903,8 +4907,8 @@ it to be non-nil. */);
4903 defsubr (&Sdelete_and_extract_region); 4907 defsubr (&Sdelete_and_extract_region);
4904 defsubr (&Swiden); 4908 defsubr (&Swiden);
4905 defsubr (&Snarrow_to_region); 4909 defsubr (&Snarrow_to_region);
4906 defsubr (&Snarrowing_lock); 4910 defsubr (&Sinternal__lock_narrowing);
4907 defsubr (&Snarrowing_unlock); 4911 defsubr (&Sinternal__unlock_narrowing);
4908 defsubr (&Ssave_restriction); 4912 defsubr (&Ssave_restriction);
4909 defsubr (&Stranspose_regions); 4913 defsubr (&Stranspose_regions);
4910} 4914}
diff --git a/src/keyboard.c b/src/keyboard.c
index 6f0f075e54e..b2816f8270b 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1910,12 +1910,13 @@ safe_run_hooks_maybe_narrowed (Lisp_Object hook, struct window *w)
1910 specbind (Qinhibit_quit, Qt); 1910 specbind (Qinhibit_quit, Qt);
1911 1911
1912 if (current_buffer->long_line_optimizations_p 1912 if (current_buffer->long_line_optimizations_p
1913 && long_line_locked_narrowing_region_size > 0) 1913 && long_line_optimizations_region_size > 0)
1914 { 1914 {
1915 ptrdiff_t begv = get_locked_narrowing_begv (PT); 1915 ptrdiff_t begv = get_locked_narrowing_begv (PT);
1916 ptrdiff_t zv = get_locked_narrowing_zv (PT); 1916 ptrdiff_t zv = get_locked_narrowing_zv (PT);
1917 if (begv != BEG || zv != Z) 1917 if (begv != BEG || zv != Z)
1918 narrow_to_region_locked (make_fixnum (begv), make_fixnum (zv), hook); 1918 narrow_to_region_locked (make_fixnum (begv), make_fixnum (zv),
1919 Qlong_line_optimizations_in_command_hooks);
1919 } 1920 }
1920 1921
1921 run_hook_with_args (2, ((Lisp_Object []) {hook, hook}), 1922 run_hook_with_args (2, ((Lisp_Object []) {hook, hook}),
@@ -12168,6 +12169,8 @@ syms_of_keyboard (void)
12168 /* Hooks to run before and after each command. */ 12169 /* Hooks to run before and after each command. */
12169 DEFSYM (Qpre_command_hook, "pre-command-hook"); 12170 DEFSYM (Qpre_command_hook, "pre-command-hook");
12170 DEFSYM (Qpost_command_hook, "post-command-hook"); 12171 DEFSYM (Qpost_command_hook, "post-command-hook");
12172 DEFSYM (Qlong_line_optimizations_in_command_hooks,
12173 "long-line-optimizations-in-command-hooks");
12171 12174
12172 /* Hook run after the region is selected. */ 12175 /* Hook run after the region is selected. */
12173 DEFSYM (Qpost_select_region_hook, "post-select-region-hook"); 12176 DEFSYM (Qpost_select_region_hook, "post-select-region-hook");
@@ -12728,13 +12731,11 @@ If an unhandled error happens in running this hook, the function in
12728which the error occurred is unconditionally removed, since otherwise 12731which the error occurred is unconditionally removed, since otherwise
12729the error might happen repeatedly and make Emacs nonfunctional. 12732the error might happen repeatedly and make Emacs nonfunctional.
12730 12733
12731Note that, when the current buffer contains one or more lines whose 12734Note that, when `long-line-optimizations-p' is non-nil in the buffer,
12732length is above `long-line-threshold', these hook functions are called 12735these functions are called as if they were in a `with-restriction' form,
12733with the buffer narrowed to a small portion around point (whose size 12736with a `long-line-optimizations-in-command-hooks' label and with the
12734is specified by `long-line-locked-narrowing-region-size'), and the 12737buffer narrowed to a portion around point whose size is specified by
12735narrowing is locked (see `narrowing-lock'), so that these hook 12738`long-line-optimizations-region-size'.
12736functions cannot use `widen' to gain access to other portions of
12737buffer text.
12738 12739
12739See also `post-command-hook'. */); 12740See also `post-command-hook'. */);
12740 Vpre_command_hook = Qnil; 12741 Vpre_command_hook = Qnil;
@@ -12750,13 +12751,11 @@ It is a bad idea to use this hook for expensive processing. If
12750unavoidable, wrap your code in `(while-no-input (redisplay) CODE)' to 12751unavoidable, wrap your code in `(while-no-input (redisplay) CODE)' to
12751avoid making Emacs unresponsive while the user types. 12752avoid making Emacs unresponsive while the user types.
12752 12753
12753Note that, when the current buffer contains one or more lines whose 12754Note that, when `long-line-optimizations-p' is non-nil in the buffer,
12754length is above `long-line-threshold', these hook functions are called 12755these functions are called as if they were in a `with-restriction' form,
12755with the buffer narrowed to a small portion around point (whose size 12756with a `long-line-optimizations-in-command-hooks' label and with the
12756is specified by `long-line-locked-narrowing-region-size'), and the 12757buffer narrowed to a portion around point whose size is specified by
12757narrowing is locked (see `narrowing-lock'), so that these hook 12758`long-line-optimizations-region-size'.
12758functions cannot use `widen' to gain access to other portions of
12759buffer text.
12760 12759
12761See also `pre-command-hook'. */); 12760See also `pre-command-hook'. */);
12762 Vpost_command_hook = Qnil; 12761 Vpost_command_hook = Qnil;
diff --git a/src/xdisp.c b/src/xdisp.c
index a19c9908616..1f630de7586 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3536,11 +3536,11 @@ get_closer_narrowed_begv (struct window *w, ptrdiff_t pos)
3536ptrdiff_t 3536ptrdiff_t
3537get_locked_narrowing_begv (ptrdiff_t pos) 3537get_locked_narrowing_begv (ptrdiff_t pos)
3538{ 3538{
3539 if (long_line_locked_narrowing_region_size <= 0) 3539 if (long_line_optimizations_region_size <= 0)
3540 return BEGV; 3540 return BEGV;
3541 int len = long_line_locked_narrowing_region_size / 2; 3541 int len = long_line_optimizations_region_size / 2;
3542 int begv = max (pos - len, BEGV); 3542 int begv = max (pos - len, BEGV);
3543 int limit = long_line_locked_narrowing_bol_search_limit; 3543 int limit = long_line_optimizations_bol_search_limit;
3544 while (limit > 0) 3544 while (limit > 0)
3545 { 3545 {
3546 if (begv == BEGV || FETCH_BYTE (CHAR_TO_BYTE (begv) - 1) == '\n') 3546 if (begv == BEGV || FETCH_BYTE (CHAR_TO_BYTE (begv) - 1) == '\n')
@@ -3554,9 +3554,9 @@ get_locked_narrowing_begv (ptrdiff_t pos)
3554ptrdiff_t 3554ptrdiff_t
3555get_locked_narrowing_zv (ptrdiff_t pos) 3555get_locked_narrowing_zv (ptrdiff_t pos)
3556{ 3556{
3557 if (long_line_locked_narrowing_region_size <= 0) 3557 if (long_line_optimizations_region_size <= 0)
3558 return ZV; 3558 return ZV;
3559 int len = long_line_locked_narrowing_region_size / 2; 3559 int len = long_line_optimizations_region_size / 2;
3560 return min (pos + len, ZV); 3560 return min (pos + len, ZV);
3561} 3561}
3562 3562
@@ -4394,7 +4394,7 @@ handle_fontified_prop (struct it *it)
4394 eassert (it->end_charpos == ZV); 4394 eassert (it->end_charpos == ZV);
4395 4395
4396 if (current_buffer->long_line_optimizations_p 4396 if (current_buffer->long_line_optimizations_p
4397 && long_line_locked_narrowing_region_size > 0) 4397 && long_line_optimizations_region_size > 0)
4398 { 4398 {
4399 ptrdiff_t begv = it->locked_narrowing_begv; 4399 ptrdiff_t begv = it->locked_narrowing_begv;
4400 ptrdiff_t zv = it->locked_narrowing_zv; 4400 ptrdiff_t zv = it->locked_narrowing_zv;
@@ -4406,7 +4406,7 @@ handle_fontified_prop (struct it *it)
4406 } 4406 }
4407 if (begv != BEG || zv != Z) 4407 if (begv != BEG || zv != Z)
4408 narrow_to_region_locked (make_fixnum (begv), make_fixnum (zv), 4408 narrow_to_region_locked (make_fixnum (begv), make_fixnum (zv),
4409 Qfontification_functions); 4409 Qlong_line_optimizations_in_fontification_functions);
4410 } 4410 }
4411 4411
4412 /* Don't allow Lisp that runs from 'fontification-functions' 4412 /* Don't allow Lisp that runs from 'fontification-functions'
@@ -13424,7 +13424,8 @@ gui_consider_frame_title (Lisp_Object frame)
13424 13424
13425 Fselect_window (f->selected_window, Qt); 13425 Fselect_window (f->selected_window, Qt);
13426 set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->contents)); 13426 set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->contents));
13427 fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; 13427 fmt = (FRAME_ICONIFIED_P (f) && !EQ (Vicon_title_format, Qt)
13428 ? Vicon_title_format : Vframe_title_format);
13428 13429
13429 mode_line_target = MODE_LINE_TITLE; 13430 mode_line_target = MODE_LINE_TITLE;
13430 title_start = MODE_LINE_NOPROP_LEN (0); 13431 title_start = MODE_LINE_NOPROP_LEN (0);
@@ -36266,6 +36267,8 @@ be let-bound around code that needs to disable messages temporarily. */);
36266 DEFSYM (QCfile, ":file"); 36267 DEFSYM (QCfile, ":file");
36267 DEFSYM (Qfontified, "fontified"); 36268 DEFSYM (Qfontified, "fontified");
36268 DEFSYM (Qfontification_functions, "fontification-functions"); 36269 DEFSYM (Qfontification_functions, "fontification-functions");
36270 DEFSYM (Qlong_line_optimizations_in_fontification_functions,
36271 "long-line-optimizations-in-fontification-functions");
36269 36272
36270 /* Name of the symbol which disables Lisp evaluation in 'display' 36273 /* Name of the symbol which disables Lisp evaluation in 'display'
36271 properties. This is used by enriched.el. */ 36274 properties. This is used by enriched.el. */
@@ -36606,9 +36609,11 @@ which no explicit name has been set (see `modify-frame-parameters'). */);
36606 DEFVAR_LISP ("icon-title-format", Vicon_title_format, 36609 DEFVAR_LISP ("icon-title-format", Vicon_title_format,
36607 doc: /* Template for displaying the title bar of an iconified frame. 36610 doc: /* Template for displaying the title bar of an iconified frame.
36608\(Assuming the window manager supports this feature.) 36611\(Assuming the window manager supports this feature.)
36609This variable has the same structure as `mode-line-format' (which see), 36612If the value is a string, it should have the same structure
36610and is used only on frames for which no explicit name has been set 36613as `mode-line-format' (which see), and is used only on frames
36611\(see `modify-frame-parameters'). */); 36614for which no explicit name has been set \(see `modify-frame-parameters').
36615If the value is t, that means use `frame-title-format' for
36616iconified frames. */);
36612 /* Do not nest calls to pure_list. This works around a bug in 36617 /* Do not nest calls to pure_list. This works around a bug in
36613 Oracle Developer Studio 12.6. */ 36618 Oracle Developer Studio 12.6. */
36614 Lisp_Object icon_title_name_format 36619 Lisp_Object icon_title_name_format
@@ -36775,12 +36780,11 @@ Each function is called with one argument POS. Functions must
36775fontify a region starting at POS in the current buffer, and give 36780fontify a region starting at POS in the current buffer, and give
36776fontified regions the property `fontified' with a non-nil value. 36781fontified regions the property `fontified' with a non-nil value.
36777 36782
36778Note that, when the buffer contains one or more lines whose length is 36783Note that, when `long-line-optimizations-p' is non-nil in the buffer,
36779above `long-line-threshold', these functions are called with the 36784these functions are called as if they were in a `with-restriction' form,
36780buffer narrowed to a small portion around POS (whose size is specified 36785with a `long-line-optimizations-in-fontification-functions' label and
36781by `long-line-locked-narrowing-region-size'), and the narrowing is 36786with the buffer narrowed to a portion around POS whose size is
36782locked (see `narrowing-lock'), so that these functions cannot use 36787specified by `long-line-optimizations-region-size'. */);
36783`widen' to gain access to other portions of buffer text. */);
36784 Vfontification_functions = Qnil; 36788 Vfontification_functions = Qnil;
36785 Fmake_variable_buffer_local (Qfontification_functions); 36789 Fmake_variable_buffer_local (Qfontification_functions);
36786 36790