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/editfns.c | |
| 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/editfns.c')
| -rw-r--r-- | src/editfns.c | 28 |
1 files changed, 21 insertions, 7 deletions
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 | } |