mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-26 07:33:47 +00:00
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.
This commit is contained in:
parent
accd88d554
commit
5206a551c1
@ -4900,7 +4900,7 @@ binding slots have been popped."
|
|||||||
(defun byte-compile-save-restriction (form)
|
(defun byte-compile-save-restriction (form)
|
||||||
(byte-compile-out 'byte-save-restriction 0)
|
(byte-compile-out 'byte-save-restriction 0)
|
||||||
(byte-compile-body-do-effect (cdr form))
|
(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)
|
(defun byte-compile-save-current-buffer (form)
|
||||||
(byte-compile-out 'byte-save-current-buffer 0)
|
(byte-compile-out 'byte-save-current-buffer 0)
|
||||||
|
@ -942,8 +942,6 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
|
|||||||
CASE (Bsave_restriction):
|
CASE (Bsave_restriction):
|
||||||
record_unwind_protect (save_restriction_restore,
|
record_unwind_protect (save_restriction_restore,
|
||||||
save_restriction_save ());
|
save_restriction_save ());
|
||||||
record_unwind_protect (narrowing_locks_restore,
|
|
||||||
narrowing_locks_save ());
|
|
||||||
NEXT;
|
NEXT;
|
||||||
|
|
||||||
CASE (Bcatch): /* Obsolete since 25. */
|
CASE (Bcatch): /* Obsolete since 25. */
|
||||||
|
@ -5063,8 +5063,6 @@ helper_save_restriction (void)
|
|||||||
{
|
{
|
||||||
record_unwind_protect (save_restriction_restore,
|
record_unwind_protect (save_restriction_restore,
|
||||||
save_restriction_save ());
|
save_restriction_save ());
|
||||||
record_unwind_protect (narrowing_locks_restore,
|
|
||||||
narrowing_locks_save ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -2794,7 +2794,7 @@ reset_outermost_narrowings (void)
|
|||||||
|
|
||||||
/* Helper functions to save and restore the narrowing locks of the
|
/* Helper functions to save and restore the narrowing locks of the
|
||||||
current buffer in Fsave_restriction. */
|
current buffer in Fsave_restriction. */
|
||||||
Lisp_Object
|
static Lisp_Object
|
||||||
narrowing_locks_save (void)
|
narrowing_locks_save (void)
|
||||||
{
|
{
|
||||||
Lisp_Object buf = Fcurrent_buffer ();
|
Lisp_Object buf = Fcurrent_buffer ();
|
||||||
@ -2804,7 +2804,7 @@ narrowing_locks_save (void)
|
|||||||
return Fcons (buf, Fcopy_sequence (locks));
|
return Fcons (buf, Fcopy_sequence (locks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
narrowing_locks_restore (Lisp_Object buf_and_saved_locks)
|
narrowing_locks_restore (Lisp_Object buf_and_saved_locks)
|
||||||
{
|
{
|
||||||
Lisp_Object buf = XCAR (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;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lisp_Object
|
static Lisp_Object
|
||||||
save_restriction_save (void)
|
save_restriction_save_1 (void)
|
||||||
{
|
{
|
||||||
if (BEGV == BEG && ZV == Z)
|
if (BEGV == BEG && ZV == Z)
|
||||||
/* The common case that the buffer isn't narrowed.
|
/* The common case that the buffer isn't narrowed.
|
||||||
@ -2999,8 +2999,8 @@ save_restriction_save (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
save_restriction_restore (Lisp_Object data)
|
save_restriction_restore_1 (Lisp_Object data)
|
||||||
{
|
{
|
||||||
struct buffer *cur = NULL;
|
struct buffer *cur = NULL;
|
||||||
struct buffer *buf = (CONSP (data)
|
struct buffer *buf = (CONSP (data)
|
||||||
@ -3068,6 +3068,21 @@ save_restriction_restore (Lisp_Object data)
|
|||||||
set_buffer_internal (cur);
|
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,
|
DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0,
|
||||||
doc: /* Execute BODY, saving and restoring current buffer's restrictions.
|
doc: /* Execute BODY, saving and restoring current buffer's restrictions.
|
||||||
The buffer's restrictions make parts of the beginning and end invisible.
|
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 ();
|
specpdl_ref count = SPECPDL_INDEX ();
|
||||||
|
|
||||||
record_unwind_protect (save_restriction_restore, save_restriction_save ());
|
record_unwind_protect (save_restriction_restore, save_restriction_save ());
|
||||||
record_unwind_protect (narrowing_locks_restore, narrowing_locks_save ());
|
|
||||||
val = Fprogn (body);
|
val = Fprogn (body);
|
||||||
return unbind_to (count, val);
|
return unbind_to (count, val);
|
||||||
}
|
}
|
||||||
|
@ -4684,8 +4684,6 @@ extern void save_excursion_save (union specbinding *);
|
|||||||
extern void save_excursion_restore (Lisp_Object, Lisp_Object);
|
extern void save_excursion_restore (Lisp_Object, Lisp_Object);
|
||||||
extern Lisp_Object save_restriction_save (void);
|
extern Lisp_Object save_restriction_save (void);
|
||||||
extern void save_restriction_restore (Lisp_Object);
|
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 (ptrdiff_t, ptrdiff_t, bool);
|
||||||
extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t,
|
extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t,
|
||||||
ptrdiff_t, bool);
|
ptrdiff_t, bool);
|
||||||
|
Loading…
Reference in New Issue
Block a user