aboutsummaryrefslogtreecommitdiff
path: root/thogai.el
diff options
context:
space:
mode:
Diffstat (limited to 'thogai.el')
-rw-r--r--thogai.el21
1 files changed, 6 insertions, 15 deletions
diff --git a/thogai.el b/thogai.el
index 1fc350f..2a4fa57 100644
--- a/thogai.el
+++ b/thogai.el
@@ -450,24 +450,15 @@ STROKES is injected first."
Process the most recent stroke, and insert its translation or
execute a command. STROKE-RING is the ring representing the
current state, and should typically be `thogai-stroke-ring'."
+ (undo-boundary)
(if (string= (ring-ref stroke-ring 0) "*")
;; Special case to handle the undo operation
(progn
- ;; Drop the "*" stroke from the state ring.
- (ring-remove stroke-ring 0)
- (let ((matched-strokes
- (or (thogai-longest-match (reverse (ring-elements stroke-ring)))
- (list (ring-ref stroke-ring 0)))))
- ;; Reverse the previous group of strokes.
- (thogai-reverse-strokes matched-strokes)
- ;; Re-insert the previous group of strokes except for the
- ;; newest stroke.
- (pcase (reverse matched-strokes)
- (`(,_ . ,other-strokes)
- (thogai-inject-strokes (reverse other-strokes)
- (make-ring (length other-strokes))))))
- ;; Remove the newest stroke from the state ring.
- (ring-remove stroke-ring 0))
+ (undo-only)
+ ;; Drop the "*" stroke and the stroke that was just undone.
+ (dotimes (i 2)
+ (unless (zerop (ring-length stroke-ring))
+ (ring-remove stroke-ring 0))))
(let ((matched-strokes
(thogai-longest-match (reverse (ring-elements stroke-ring)))))
;; Delete translation for earlier strokes that are captured by