]> git.eshelyaron.com Git - emacs.git/commitdiff
Extract check for end of macro to function
authorTim Ruffing <crypto@timruffing.de>
Wed, 27 Dec 2023 13:26:26 +0000 (14:26 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 11 Mar 2024 09:26:02 +0000 (10:26 +0100)
* 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.

(cherry picked from commit fbc5fb2561d9e1d4e5b69b349a26c49d30ffc938)

src/keyboard.c
src/macros.c
src/macros.h

index eb0de98bad10ed99defb209f705fa9dc0d1d901f..b6fc568cde5b93628c950363fa53147de1a840cb 100644 (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;
index 5f71bcbd3610c840a4884e769768b6b3a9415311..faec9dc646dd31cfcbc80778dc3b44ee0249c4e8 100644 (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)
 {
index 51599a29bcdbdb526586d79ab1c3209a750d1776..cb6ac8aa2062cde6f56384372e310e9b7e5fa7e2 100644 (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 */