1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

* 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>
This commit is contained in:
Tim Ruffing 2024-03-09 12:29:39 +01:00 committed by Stefan Monnier
parent d444390ec5
commit df3e0bcbdb

View File

@ -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)