- (let (repeat-on-final-keystroke)
- (while (eq (read-event) repeat-repeat-char)
- ;; Make each repetition undo separately.
- (undo-boundary)
- (repeat repeat-arg))
+ (let (repeat-on-final-keystroke
+ ;; Bind `undo-inhibit-record-point' to t in order to avoid
+ ;; recording point in `buffer-undo-list' here. We have to
+ ;; do this since the command loop does not set the last
+ ;; position of point thus confusing the point recording
+ ;; mechanism when inserting or deleting text.
+ (undo-inhibit-record-point t))
+ (setq real-last-command 'repeat)
+ (setq repeat-undo-count 1)
+ (unwind-protect
+ (while (let ((evt (read-event))) ;FIXME: read-key maybe?
+ ;; For clicks, we need to strip the meta-data to
+ ;; check the underlying event name.
+ (eq (or (car-safe evt) evt)
+ (or (car-safe repeat-repeat-char)
+ repeat-repeat-char)))
+ (repeat repeat-arg))
+ ;; Make sure `repeat-undo-count' is reset.
+ (setq repeat-undo-count nil))