Extract check for end of macro to function

* src/macros.h (at_end_of_macro_p):
* src/macros.c (at_end_of_macro_p):
New function.
* src/keyboard.c (read_char): Use the new function.
feature/positioned-lambdas
Tim Ruffing 2023-12-27 14:26:26 +01:00 committed by Stefan Monnier
parent f3da3d1c68
commit fbc5fb2561
3 changed files with 18 additions and 2 deletions

View File

@ -2637,8 +2637,7 @@ read_char (int commandflag, Lisp_Object map,
/* Exit the macro if we are at the end.
Also, some things replace the macro with t
to force an early exit. */
if (EQ (Vexecuting_kbd_macro, Qt)
|| executing_kbd_macro_index >= XFIXNAT (Flength (Vexecuting_kbd_macro)))
if (at_end_of_macro_p ())
{
XSETINT (c, -1);
goto exit;

View File

@ -353,6 +353,18 @@ init_macros (void)
executing_kbd_macro = Qnil;
}
/* Whether the execution of a macro has reached its end.
This should be called only while executing a macro. */
bool
at_end_of_macro_p (void)
{
eassume (!NILP (Vexecuting_kbd_macro));
/* Some things replace the macro with t to force an early exit. */
return EQ (Vexecuting_kbd_macro, Qt)
|| executing_kbd_macro_index >= XFIXNAT (Flength (Vexecuting_kbd_macro));
}
void
syms_of_macros (void)
{

View File

@ -47,4 +47,9 @@ extern void finalize_kbd_macro_chars (void);
extern void store_kbd_macro_char (Lisp_Object);
/* Whether the execution of a macro has reached its end.
This should be called only while executing a macro. */
extern bool at_end_of_macro_p (void);
#endif /* EMACS_MACROS_H */