[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 5206a551c1: Improve backward compatibility of save-restriction
From: |
Gregory Heytings |
Subject: |
emacs-29 5206a551c1: Improve backward compatibility of save-restriction |
Date: |
Tue, 14 Feb 2023 15:42:47 -0500 (EST) |
branch: emacs-29
commit 5206a551c166fc1908edff4fdf1695f7cef3600a
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>
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.
---
lisp/emacs-lisp/bytecomp.el | 2 +-
src/bytecode.c | 2 --
src/comp.c | 2 --
src/editfns.c | 28 +++++++++++++++++++++-------
src/lisp.h | 2 --
5 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index c6cda6b588..5df1205869 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -4900,7 +4900,7 @@ binding slots have been popped."
(defun byte-compile-save-restriction (form)
(byte-compile-out 'byte-save-restriction 0)
(byte-compile-body-do-effect (cdr form))
- (byte-compile-out 'byte-unbind 2))
+ (byte-compile-out 'byte-unbind 1))
(defun byte-compile-save-current-buffer (form)
(byte-compile-out 'byte-save-current-buffer 0)
diff --git a/src/bytecode.c b/src/bytecode.c
index 8e214560f3..124348e5b3 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -942,8 +942,6 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
CASE (Bsave_restriction):
record_unwind_protect (save_restriction_restore,
save_restriction_save ());
- record_unwind_protect (narrowing_locks_restore,
- narrowing_locks_save ());
NEXT;
CASE (Bcatch): /* Obsolete since 25. */
diff --git a/src/comp.c b/src/comp.c
index 0e2dfd3913..10cf7962ba 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -5063,8 +5063,6 @@ helper_save_restriction (void)
{
record_unwind_protect (save_restriction_restore,
save_restriction_save ());
- record_unwind_protect (narrowing_locks_restore,
- narrowing_locks_save ());
}
static bool
diff --git a/src/editfns.c b/src/editfns.c
index ce133785e0..f83c5c7259 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2794,7 +2794,7 @@ reset_outermost_narrowings (void)
/* Helper functions to save and restore the narrowing locks of the
current buffer in Fsave_restriction. */
-Lisp_Object
+static Lisp_Object
narrowing_locks_save (void)
{
Lisp_Object buf = Fcurrent_buffer ();
@@ -2804,7 +2804,7 @@ narrowing_locks_save (void)
return Fcons (buf, Fcopy_sequence (locks));
}
-void
+static void
narrowing_locks_restore (Lisp_Object buf_and_saved_locks)
{
Lisp_Object buf = XCAR (buf_and_saved_locks);
@@ -2975,8 +2975,8 @@ This is an internal function used by
`without-restriction'. */)
return Qnil;
}
-Lisp_Object
-save_restriction_save (void)
+static Lisp_Object
+save_restriction_save_1 (void)
{
if (BEGV == BEG && ZV == Z)
/* The common case that the buffer isn't narrowed.
@@ -2999,8 +2999,8 @@ save_restriction_save (void)
}
}
-void
-save_restriction_restore (Lisp_Object data)
+static void
+save_restriction_restore_1 (Lisp_Object data)
{
struct buffer *cur = NULL;
struct buffer *buf = (CONSP (data)
@@ -3068,6 +3068,21 @@ save_restriction_restore (Lisp_Object data)
set_buffer_internal (cur);
}
+Lisp_Object
+save_restriction_save (void)
+{
+ Lisp_Object restr = save_restriction_save_1 ();
+ Lisp_Object locks = narrowing_locks_save ();
+ return Fcons (restr, locks);
+}
+
+void
+save_restriction_restore (Lisp_Object data)
+{
+ narrowing_locks_restore (XCDR (data));
+ save_restriction_restore_1 (XCAR (data));
+}
+
DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED,
0,
doc: /* Execute BODY, saving and restoring current buffer's
restrictions.
The buffer's restrictions make parts of the beginning and end invisible.
@@ -3092,7 +3107,6 @@ usage: (save-restriction &rest BODY) */)
specpdl_ref count = SPECPDL_INDEX ();
record_unwind_protect (save_restriction_restore, save_restriction_save ());
- record_unwind_protect (narrowing_locks_restore, narrowing_locks_save ());
val = Fprogn (body);
return unbind_to (count, val);
}
diff --git a/src/lisp.h b/src/lisp.h
index 93197d3817..1276285e2f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4684,8 +4684,6 @@ extern void save_excursion_save (union specbinding *);
extern void save_excursion_restore (Lisp_Object, Lisp_Object);
extern Lisp_Object save_restriction_save (void);
extern void save_restriction_restore (Lisp_Object);
-extern Lisp_Object narrowing_locks_save (void);
-extern void narrowing_locks_restore (Lisp_Object);
extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool);
extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t,
ptrdiff_t, bool);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 5206a551c1: Improve backward compatibility of save-restriction,
Gregory Heytings <=