aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Ruffing2023-12-27 14:26:26 +0100
committerStefan Monnier2024-03-10 10:40:01 -0400
commitfbc5fb2561d9e1d4e5b69b349a26c49d30ffc938 (patch)
tree14f9a5b84f7cc25b4ba48450c0beb50a42ba3f7f /src
parentf3da3d1c68bef60ef28d67c6d8fa5d0cba8c9f08 (diff)
downloademacs-fbc5fb2561d9e1d4e5b69b349a26c49d30ffc938.tar.gz
emacs-fbc5fb2561d9e1d4e5b69b349a26c49d30ffc938.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c3
-rw-r--r--src/macros.c12
-rw-r--r--src/macros.h5
3 files changed, 18 insertions, 2 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index eb0de98bad1..b6fc568cde5 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2637,8 +2637,7 @@ read_char (int commandflag, Lisp_Object map,
2637 /* Exit the macro if we are at the end. 2637 /* Exit the macro if we are at the end.
2638 Also, some things replace the macro with t 2638 Also, some things replace the macro with t
2639 to force an early exit. */ 2639 to force an early exit. */
2640 if (EQ (Vexecuting_kbd_macro, Qt) 2640 if (at_end_of_macro_p ())
2641 || executing_kbd_macro_index >= XFIXNAT (Flength (Vexecuting_kbd_macro)))
2642 { 2641 {
2643 XSETINT (c, -1); 2642 XSETINT (c, -1);
2644 goto exit; 2643 goto exit;
diff --git a/src/macros.c b/src/macros.c
index 5f71bcbd361..faec9dc646d 100644
--- a/src/macros.c
+++ b/src/macros.c
@@ -353,6 +353,18 @@ init_macros (void)
353 executing_kbd_macro = Qnil; 353 executing_kbd_macro = Qnil;
354} 354}
355 355
356/* Whether the execution of a macro has reached its end.
357 This should be called only while executing a macro. */
358
359bool
360at_end_of_macro_p (void)
361{
362 eassume (!NILP (Vexecuting_kbd_macro));
363 /* Some things replace the macro with t to force an early exit. */
364 return EQ (Vexecuting_kbd_macro, Qt)
365 || executing_kbd_macro_index >= XFIXNAT (Flength (Vexecuting_kbd_macro));
366}
367
356void 368void
357syms_of_macros (void) 369syms_of_macros (void)
358{ 370{
diff --git a/src/macros.h b/src/macros.h
index 51599a29bcd..cb6ac8aa206 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -47,4 +47,9 @@ extern void finalize_kbd_macro_chars (void);
47 47
48extern void store_kbd_macro_char (Lisp_Object); 48extern void store_kbd_macro_char (Lisp_Object);
49 49
50/* Whether the execution of a macro has reached its end.
51 This should be called only while executing a macro. */
52
53extern bool at_end_of_macro_p (void);
54
50#endif /* EMACS_MACROS_H */ 55#endif /* EMACS_MACROS_H */