From: Jay Belanger Date: Sat, 10 Oct 2015 22:21:44 +0000 (-0500) Subject: Use events instead of chars to keep track of steps. X-Git-Tag: emacs-25.0.90~1172 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5186c998574a8807713b9a43518fdeae52feac67;p=emacs.git 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. --- diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el index 57af0d27822..c5a837d3260 100644 --- a/lisp/calc/calc-prog.el +++ b/lisp/calc/calc-prog.el @@ -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)