diff options
| author | Tim Ruffing | 2023-12-27 14:26:26 +0100 |
|---|---|---|
| committer | Stefan Monnier | 2024-03-10 10:40:01 -0400 |
| commit | fbc5fb2561d9e1d4e5b69b349a26c49d30ffc938 (patch) | |
| tree | 14f9a5b84f7cc25b4ba48450c0beb50a42ba3f7f /src | |
| parent | f3da3d1c68bef60ef28d67c6d8fa5d0cba8c9f08 (diff) | |
| download | emacs-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.c | 3 | ||||
| -rw-r--r-- | src/macros.c | 12 | ||||
| -rw-r--r-- | src/macros.h | 5 |
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 | |||
| 359 | bool | ||
| 360 | at_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 | |||
| 356 | void | 368 | void |
| 357 | syms_of_macros (void) | 369 | syms_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 | ||
| 48 | extern void store_kbd_macro_char (Lisp_Object); | 48 | extern 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 | |||
| 53 | extern bool at_end_of_macro_p (void); | ||
| 54 | |||
| 50 | #endif /* EMACS_MACROS_H */ | 55 | #endif /* EMACS_MACROS_H */ |