[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master df3e0bcbdbc 6/7: * lisp/calc/calc-prog.el: Switch to new method o
From: |
Stefan Monnier |
Subject: |
master df3e0bcbdbc 6/7: * lisp/calc/calc-prog.el: Switch to new method of detecting end of kbd macro |
Date: |
Sun, 10 Mar 2024 10:48:13 -0400 (EDT) |
branch: master
commit df3e0bcbdbcfe907d7572b5561dd2bf9c3715a4a
Author: Tim Ruffing <crypto@timruffing.de>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* lisp/calc/calc-prog.el: Switch to new method of detecting end of kbd macro
'read-char' will no longer return -1 as of
ac82baea1c41ec974ad49f2861ae6c06bda2b4ed. This switches to a cleaner
method of detecting whether the end of a keyboard macro has been
reached.
* lisp/calc/calc-prog.el (calc--at-end-of-kmacro-p): New function.
(calc-kbd-skip-to-else-if): Use the function.
Co-authored-by: Stefan Monnier <monnier@iro.umontreal.ca>
---
lisp/calc/calc-prog.el | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el
index 03210995eb3..8dff7f1f264 100644
--- a/lisp/calc/calc-prog.el
+++ b/lisp/calc/calc-prog.el
@@ -1225,13 +1225,17 @@ Redefine the corresponding command."
(interactive)
(calc-kbd-if))
+(defun calc--at-end-of-kmacro-p ()
+ (and (arrayp executing-kbd-macro)
+ (>= executing-kbd-macro-index (length executing-kbd-macro))))
+
(defun calc-kbd-skip-to-else-if (else-okay)
(let ((count 0)
ch)
(while (>= count 0)
- (setq ch (read-char))
- (if (= ch -1)
+ (if (calc--at-end-of-kmacro-p)
(error "Unterminated Z[ in keyboard macro"))
+ (setq ch (read-char))
(if (= ch ?Z)
(progn
(setq ch (read-char))
@@ -1299,9 +1303,9 @@ Redefine the corresponding command."
(or executing-kbd-macro
(message "Reading loop body..."))
(while (>= count 0)
- (setq ch (read-event))
- (if (eq ch -1)
+ (if (calc--at-end-of-kmacro-p)
(error "Unterminated Z%c in keyboard macro" open))
+ (setq ch (read-event))
(if (eq ch ?Z)
(progn
(setq ch (read-event)
@@ -1427,9 +1431,9 @@ Redefine the corresponding command."
(if defining-kbd-macro
(message "Reading body..."))
(while (>= count 0)
- (setq ch (read-char))
- (if (= ch -1)
+ (if (calc--at-end-of-kmacro-p)
(error "Unterminated Z` in keyboard macro"))
+ (setq ch (read-char))
(if (= ch ?Z)
(progn
(setq ch (read-char)
- master updated (f3da3d1c68b -> 2fdb281a276), Stefan Monnier, 2024/03/10
- master d444390ec56 5/7: Remove workarounds for solved 'read-event' bug, Stefan Monnier, 2024/03/10
- master 385a02cffde 2/7: * src/keyboard.c (requeued_events_pending_p): Improve name and fix comment, Stefan Monnier, 2024/03/10
- master 2fdb281a276 7/7: * src/keyboard.c (read_key_sequence): Remove MSVC compatibility hack, Stefan Monnier, 2024/03/10
- master df3e0bcbdbc 6/7: * lisp/calc/calc-prog.el: Switch to new method of detecting end of kbd macro,
Stefan Monnier <=
- master fbc5fb2561d 1/7: Extract check for end of macro to function, Stefan Monnier, 2024/03/10
- master d6f326452ec 3/7: * src/keyboard.c (requeued_events_pending_p): New function, Stefan Monnier, 2024/03/10
- master 6f46dd516b8 4/7: Continue reading in 'read-event' etc. at the end of a keyboard macro, Stefan Monnier, 2024/03/10