diff options
| author | Eli Zaretskii | 2023-07-15 05:28:16 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2023-07-15 05:28:16 -0400 |
| commit | b5bbb29634eca42582c01e2fd30c867d22f53298 (patch) | |
| tree | c9780576214669db6c889d512bc83660df5f25e7 /src/editfns.c | |
| parent | a047fb8494c203bd8f416e7ee9f77ad8dcb03631 (diff) | |
| parent | 01fb898420fe8260a1adc267993549a93b901cd8 (diff) | |
| download | emacs-b5bbb29634eca42582c01e2fd30c867d22f53298.tar.gz emacs-b5bbb29634eca42582c01e2fd30c867d22f53298.zip | |
Merge from origin/emacs-29
01fb898420f Simplify after adding internal function to enter a labele...
b741dc7fcde Add internal function to enter a labeled restriction
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/src/editfns.c b/src/editfns.c index b920857b664..cb093be75d6 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2682,11 +2682,12 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region, | |||
| 2682 | records the restriction bounds that were current when the first | 2682 | records the restriction bounds that were current when the first |
| 2683 | labeled restriction was entered (which may be a narrowing that was | 2683 | labeled restriction was entered (which may be a narrowing that was |
| 2684 | set by the user and is visible on display). This alist is used | 2684 | set by the user and is visible on display). This alist is used |
| 2685 | internally by narrow-to-region, widen, internal--label-restriction, | 2685 | internally by narrow-to-region, internal--labeled-narrow-to-region, |
| 2686 | internal--unlabel-restriction and save-restriction. For efficiency | 2686 | widen, internal--unlabel-restriction and save-restriction. For |
| 2687 | reasons, an alist is used instead of a buffer-local variable: | 2687 | efficiency reasons, an alist is used instead of a buffer-local |
| 2688 | otherwise reset_outermost_restrictions, which is called during each | 2688 | variable: otherwise reset_outermost_restrictions, which is called |
| 2689 | redisplay cycle, would have to loop through all live buffers. */ | 2689 | during each redisplay cycle, would have to loop through all live |
| 2690 | buffers. */ | ||
| 2690 | static Lisp_Object labeled_restrictions; | 2691 | static Lisp_Object labeled_restrictions; |
| 2691 | 2692 | ||
| 2692 | /* Add BUF with its list of labeled RESTRICTIONS in the | 2693 | /* Add BUF with its list of labeled RESTRICTIONS in the |
| @@ -2868,8 +2869,7 @@ void | |||
| 2868 | labeled_narrow_to_region (Lisp_Object begv, Lisp_Object zv, | 2869 | labeled_narrow_to_region (Lisp_Object begv, Lisp_Object zv, |
| 2869 | Lisp_Object label) | 2870 | Lisp_Object label) |
| 2870 | { | 2871 | { |
| 2871 | Fnarrow_to_region (begv, zv); | 2872 | Finternal__labeled_narrow_to_region (begv, zv, label); |
| 2872 | Finternal__label_restriction (label); | ||
| 2873 | record_unwind_protect (restore_point_unwind, Fpoint_marker ()); | 2873 | record_unwind_protect (restore_point_unwind, Fpoint_marker ()); |
| 2874 | record_unwind_protect (unwind_labeled_narrow_to_region, label); | 2874 | record_unwind_protect (unwind_labeled_narrow_to_region, label); |
| 2875 | } | 2875 | } |
| @@ -2885,7 +2885,6 @@ To gain access to other portions of the buffer, use | |||
| 2885 | `without-restriction' with the same label. */) | 2885 | `without-restriction' with the same label. */) |
| 2886 | (void) | 2886 | (void) |
| 2887 | { | 2887 | { |
| 2888 | Fset (Qoutermost_restriction, Qnil); | ||
| 2889 | Lisp_Object buf = Fcurrent_buffer (); | 2888 | Lisp_Object buf = Fcurrent_buffer (); |
| 2890 | Lisp_Object label = labeled_restrictions_peek_label (buf); | 2889 | Lisp_Object label = labeled_restrictions_peek_label (buf); |
| 2891 | 2890 | ||
| @@ -2967,13 +2966,6 @@ argument. To gain access to other portions of the buffer, use | |||
| 2967 | if (e > zv_charpos) e = zv_charpos; | 2966 | if (e > zv_charpos) e = zv_charpos; |
| 2968 | } | 2967 | } |
| 2969 | 2968 | ||
| 2970 | /* Record the accessible range of the buffer when narrow-to-region | ||
| 2971 | is called, that is, before applying the narrowing. That | ||
| 2972 | information is used only by internal--label-restriction. */ | ||
| 2973 | Fset (Qoutermost_restriction, list3 (Qoutermost_restriction, | ||
| 2974 | Fpoint_min_marker (), | ||
| 2975 | Fpoint_max_marker ())); | ||
| 2976 | |||
| 2977 | if (BEGV != s || ZV != e) | 2969 | if (BEGV != s || ZV != e) |
| 2978 | current_buffer->clip_changed = 1; | 2970 | current_buffer->clip_changed = 1; |
| 2979 | 2971 | ||
| @@ -2989,20 +2981,18 @@ argument. To gain access to other portions of the buffer, use | |||
| 2989 | return Qnil; | 2981 | return Qnil; |
| 2990 | } | 2982 | } |
| 2991 | 2983 | ||
| 2992 | DEFUN ("internal--label-restriction", Finternal__label_restriction, | 2984 | DEFUN ("internal--labeled-narrow-to-region", Finternal__labeled_narrow_to_region, |
| 2993 | Sinternal__label_restriction, 1, 1, 0, | 2985 | Sinternal__labeled_narrow_to_region, 3, 3, 0, |
| 2994 | doc: /* Label the current restriction with LABEL. | 2986 | doc: /* Restrict editing in this buffer to START-END, and label the restriction with LABEL. |
| 2995 | 2987 | ||
| 2996 | This is an internal function used by `with-restriction'. */) | 2988 | This is an internal function used by `with-restriction'. */) |
| 2997 | (Lisp_Object label) | 2989 | (Lisp_Object start, Lisp_Object end, Lisp_Object label) |
| 2998 | { | 2990 | { |
| 2999 | Lisp_Object buf = Fcurrent_buffer (); | 2991 | Lisp_Object buf = Fcurrent_buffer (); |
| 3000 | Lisp_Object outermost_restriction | 2992 | Lisp_Object outermost_restriction = list3 (Qoutermost_restriction, |
| 3001 | = buffer_local_value (Qoutermost_restriction, buf); | 2993 | Fpoint_min_marker (), |
| 3002 | /* If internal--label-restriction is ever called without being | 2994 | Fpoint_max_marker ()); |
| 3003 | preceded by narrow-to-region, do nothing. */ | 2995 | Fnarrow_to_region (start, end); |
| 3004 | if (NILP (outermost_restriction)) | ||
| 3005 | return Qnil; | ||
| 3006 | if (NILP (labeled_restrictions_peek_label (buf))) | 2996 | if (NILP (labeled_restrictions_peek_label (buf))) |
| 3007 | labeled_restrictions_push (buf, outermost_restriction); | 2997 | labeled_restrictions_push (buf, outermost_restriction); |
| 3008 | labeled_restrictions_push (buf, list3 (label, | 2998 | labeled_restrictions_push (buf, list3 (label, |
| @@ -4865,10 +4855,6 @@ This variable is experimental; email 32252@debbugs.gnu.org if you need | |||
| 4865 | it to be non-nil. */); | 4855 | it to be non-nil. */); |
| 4866 | binary_as_unsigned = false; | 4856 | binary_as_unsigned = false; |
| 4867 | 4857 | ||
| 4868 | DEFVAR_LISP ("outermost-restriction", Voutermost_restriction, | ||
| 4869 | doc: /* Outermost narrowing bounds, if any. Internal use only. */); | ||
| 4870 | Voutermost_restriction = Qnil; | ||
| 4871 | Fmake_variable_buffer_local (Qoutermost_restriction); | ||
| 4872 | DEFSYM (Qoutermost_restriction, "outermost-restriction"); | 4858 | DEFSYM (Qoutermost_restriction, "outermost-restriction"); |
| 4873 | Funintern (Qoutermost_restriction, Qnil); | 4859 | Funintern (Qoutermost_restriction, Qnil); |
| 4874 | 4860 | ||
| @@ -4963,7 +4949,7 @@ it to be non-nil. */); | |||
| 4963 | defsubr (&Sdelete_and_extract_region); | 4949 | defsubr (&Sdelete_and_extract_region); |
| 4964 | defsubr (&Swiden); | 4950 | defsubr (&Swiden); |
| 4965 | defsubr (&Snarrow_to_region); | 4951 | defsubr (&Snarrow_to_region); |
| 4966 | defsubr (&Sinternal__label_restriction); | 4952 | defsubr (&Sinternal__labeled_narrow_to_region); |
| 4967 | defsubr (&Sinternal__unlabel_restriction); | 4953 | defsubr (&Sinternal__unlabel_restriction); |
| 4968 | defsubr (&Ssave_restriction); | 4954 | defsubr (&Ssave_restriction); |
| 4969 | defsubr (&Stranspose_regions); | 4955 | defsubr (&Stranspose_regions); |