Use events instead of chars to keep track of steps.

* lisp/calc/calc-prog.el (calc-kbd-loop): Use events instead of chars
to keep track of steps.
This commit is contained in:
Jay Belanger 2015-10-10 17:21:44 -05:00
parent bb61fa8448
commit 5186c99857

View file

@ -1287,37 +1287,37 @@ Redefine the corresponding command."
(setq rpt-count (if rpt-count (prefix-numeric-value rpt-count) 1000000))
(let* ((count 0)
(parts nil)
(body "")
(body (vector) )
(open last-command-event)
(counter initial)
ch)
(or executing-kbd-macro
(message "Reading loop body..."))
(while (>= count 0)
(setq ch (read-char))
(if (= ch -1)
(setq ch (read-event))
(if (eq ch -1)
(error "Unterminated Z%c in keyboard macro" open))
(if (= ch ?Z)
(if (eq ch ?Z)
(progn
(setq ch (read-char)
body (concat body "Z" (char-to-string ch)))
(setq ch (read-event)
body (vconcat body (vector ?Z ch) ))
(cond ((memq ch '(?\< ?\( ?\{))
(setq count (1+ count)))
((memq ch '(?\> ?\) ?\}))
(setq count (1- count)))
((and (= ch ?/)
(= count 0))
(setq parts (nconc parts (list (concat (substring body 0 -2)
"Z]")))
(setq parts (nconc parts (list (vconcat (substring body 0 -2)
(vector ?Z ?\]) )))
body ""))
((eq ch 7)
(keyboard-quit))))
(setq body (concat body (char-to-string ch)))))
(setq body (vconcat body (vector ch)))))
(if (/= ch (cdr (assq open '( (?\< . ?\>) (?\( . ?\)) (?\{ . ?\}) ))))
(error "Mismatched Z%c and Z%c in keyboard macro" open ch))
(or executing-kbd-macro
(message "Looping..."))
(setq body (concat (substring body 0 -2) "Z]"))
(setq body (vconcat (substring body 0 -2) (vector ?Z ?\]) ))
(and (not executing-kbd-macro)
(= rpt-count 1000000)
(null parts)