diff options
| author | Gregory Heytings | 2023-02-14 20:22:50 +0000 |
|---|---|---|
| committer | Gregory Heytings | 2023-02-14 21:41:35 +0100 |
| commit | 5206a551c166fc1908edff4fdf1695f7cef3600a (patch) | |
| tree | 6865a1e4131030a6c32c7551c8441a63ea349bd2 /src | |
| parent | accd88d55455b8c585b162242e6e4ede742afa99 (diff) | |
| download | emacs-5206a551c166fc1908edff4fdf1695f7cef3600a.tar.gz emacs-5206a551c166fc1908edff4fdf1695f7cef3600a.zip | |
Improve backward compatibility of save-restriction
* src/editfns.c (save_restriction_save_1): Renamed from
'save_restrictions_save'. Make it static.
(save_restriction_restore_1): Renamed from
'save_restriction_restore'. Make it static.
(save_restriction_restore): New function, combining
'save_restriction_save_1' and 'narrowing_locks_save'.
(save_restriction_save): New function, combining
'save_restriction_restore_1' and 'narrowing_locks_restore'.
(Fsave_restriction): Restore the previous code.
(narrowing_locks_save, narrowing_locks_restore): Make them static.
* src/lisp.h: Remove two functions that are not externally visible
anymore.
* src/comp.c (helper_save_restriction): Restore the previous code.
* src/bytecode.c (exec_byte_code): Restore the previous code.
* lisp/emacs-lisp/bytecomp.el (byte-compile-save-restriction):
Decrement unbinding count.
Diffstat (limited to 'src')
| -rw-r--r-- | src/bytecode.c | 2 | ||||
| -rw-r--r-- | src/comp.c | 2 | ||||
| -rw-r--r-- | src/editfns.c | 28 | ||||
| -rw-r--r-- | src/lisp.h | 2 |
4 files changed, 21 insertions, 13 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 8e214560f30..124348e5b35 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -942,8 +942,6 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template, | |||
| 942 | CASE (Bsave_restriction): | 942 | CASE (Bsave_restriction): |
| 943 | record_unwind_protect (save_restriction_restore, | 943 | record_unwind_protect (save_restriction_restore, |
| 944 | save_restriction_save ()); | 944 | save_restriction_save ()); |
| 945 | record_unwind_protect (narrowing_locks_restore, | ||
| 946 | narrowing_locks_save ()); | ||
| 947 | NEXT; | 945 | NEXT; |
| 948 | 946 | ||
| 949 | CASE (Bcatch): /* Obsolete since 25. */ | 947 | CASE (Bcatch): /* Obsolete since 25. */ |
diff --git a/src/comp.c b/src/comp.c index 0e2dfd3913b..10cf7962ba1 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -5063,8 +5063,6 @@ helper_save_restriction (void) | |||
| 5063 | { | 5063 | { |
| 5064 | record_unwind_protect (save_restriction_restore, | 5064 | record_unwind_protect (save_restriction_restore, |
| 5065 | save_restriction_save ()); | 5065 | save_restriction_save ()); |
| 5066 | record_unwind_protect (narrowing_locks_restore, | ||
| 5067 | narrowing_locks_save ()); | ||
| 5068 | } | 5066 | } |
| 5069 | 5067 | ||
| 5070 | static bool | 5068 | static bool |
diff --git a/src/editfns.c b/src/editfns.c index ce133785e0b..f83c5c7259b 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2794,7 +2794,7 @@ reset_outermost_narrowings (void) | |||
| 2794 | 2794 | ||
| 2795 | /* Helper functions to save and restore the narrowing locks of the | 2795 | /* Helper functions to save and restore the narrowing locks of the |
| 2796 | current buffer in Fsave_restriction. */ | 2796 | current buffer in Fsave_restriction. */ |
| 2797 | Lisp_Object | 2797 | static Lisp_Object |
| 2798 | narrowing_locks_save (void) | 2798 | narrowing_locks_save (void) |
| 2799 | { | 2799 | { |
| 2800 | Lisp_Object buf = Fcurrent_buffer (); | 2800 | Lisp_Object buf = Fcurrent_buffer (); |
| @@ -2804,7 +2804,7 @@ narrowing_locks_save (void) | |||
| 2804 | return Fcons (buf, Fcopy_sequence (locks)); | 2804 | return Fcons (buf, Fcopy_sequence (locks)); |
| 2805 | } | 2805 | } |
| 2806 | 2806 | ||
| 2807 | void | 2807 | static void |
| 2808 | narrowing_locks_restore (Lisp_Object buf_and_saved_locks) | 2808 | narrowing_locks_restore (Lisp_Object buf_and_saved_locks) |
| 2809 | { | 2809 | { |
| 2810 | Lisp_Object buf = XCAR (buf_and_saved_locks); | 2810 | Lisp_Object buf = XCAR (buf_and_saved_locks); |
| @@ -2975,8 +2975,8 @@ This is an internal function used by `without-restriction'. */) | |||
| 2975 | return Qnil; | 2975 | return Qnil; |
| 2976 | } | 2976 | } |
| 2977 | 2977 | ||
| 2978 | Lisp_Object | 2978 | static Lisp_Object |
| 2979 | save_restriction_save (void) | 2979 | save_restriction_save_1 (void) |
| 2980 | { | 2980 | { |
| 2981 | if (BEGV == BEG && ZV == Z) | 2981 | if (BEGV == BEG && ZV == Z) |
| 2982 | /* The common case that the buffer isn't narrowed. | 2982 | /* The common case that the buffer isn't narrowed. |
| @@ -2999,8 +2999,8 @@ save_restriction_save (void) | |||
| 2999 | } | 2999 | } |
| 3000 | } | 3000 | } |
| 3001 | 3001 | ||
| 3002 | void | 3002 | static void |
| 3003 | save_restriction_restore (Lisp_Object data) | 3003 | save_restriction_restore_1 (Lisp_Object data) |
| 3004 | { | 3004 | { |
| 3005 | struct buffer *cur = NULL; | 3005 | struct buffer *cur = NULL; |
| 3006 | struct buffer *buf = (CONSP (data) | 3006 | struct buffer *buf = (CONSP (data) |
| @@ -3068,6 +3068,21 @@ save_restriction_restore (Lisp_Object data) | |||
| 3068 | set_buffer_internal (cur); | 3068 | set_buffer_internal (cur); |
| 3069 | } | 3069 | } |
| 3070 | 3070 | ||
| 3071 | Lisp_Object | ||
| 3072 | save_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 | |||
| 3079 | void | ||
| 3080 | save_restriction_restore (Lisp_Object data) | ||
| 3081 | { | ||
| 3082 | narrowing_locks_restore (XCDR (data)); | ||
| 3083 | save_restriction_restore_1 (XCAR (data)); | ||
| 3084 | } | ||
| 3085 | |||
| 3071 | DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0, | 3086 | DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0, |
| 3072 | doc: /* Execute BODY, saving and restoring current buffer's restrictions. | 3087 | doc: /* Execute BODY, saving and restoring current buffer's restrictions. |
| 3073 | The buffer's restrictions make parts of the beginning and end invisible. | 3088 | The buffer's restrictions make parts of the beginning and end invisible. |
| @@ -3092,7 +3107,6 @@ usage: (save-restriction &rest BODY) */) | |||
| 3092 | specpdl_ref count = SPECPDL_INDEX (); | 3107 | specpdl_ref count = SPECPDL_INDEX (); |
| 3093 | 3108 | ||
| 3094 | record_unwind_protect (save_restriction_restore, save_restriction_save ()); | 3109 | record_unwind_protect (save_restriction_restore, save_restriction_save ()); |
| 3095 | record_unwind_protect (narrowing_locks_restore, narrowing_locks_save ()); | ||
| 3096 | val = Fprogn (body); | 3110 | val = Fprogn (body); |
| 3097 | return unbind_to (count, val); | 3111 | return unbind_to (count, val); |
| 3098 | } | 3112 | } |
diff --git a/src/lisp.h b/src/lisp.h index 93197d38176..1276285e2f2 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4684,8 +4684,6 @@ extern void save_excursion_save (union specbinding *); | |||
| 4684 | extern void save_excursion_restore (Lisp_Object, Lisp_Object); | 4684 | extern void save_excursion_restore (Lisp_Object, Lisp_Object); |
| 4685 | extern Lisp_Object save_restriction_save (void); | 4685 | extern Lisp_Object save_restriction_save (void); |
| 4686 | extern void save_restriction_restore (Lisp_Object); | 4686 | extern void save_restriction_restore (Lisp_Object); |
| 4687 | extern Lisp_Object narrowing_locks_save (void); | ||
| 4688 | extern void narrowing_locks_restore (Lisp_Object); | ||
| 4689 | extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); | 4687 | extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); |
| 4690 | extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, | 4688 | extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, |
| 4691 | ptrdiff_t, bool); | 4689 | ptrdiff_t, bool); |