From 6edc10194b896d7e6a6cb3c42d0e5afdd8f6327e Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 13 Jun 2022 01:26:19 +0530 Subject: Delete space when reversing strokes. * thogai.el (thogai-reverse-strokes): Delete space if present. (thogai-insert-stroke): Depend on thogai-reverse-strokes to delete space. --- thogai.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/thogai.el b/thogai.el index faca653..237be6f 100644 --- a/thogai.el +++ b/thogai.el @@ -303,7 +303,14 @@ is unaltered." (thogai-delete (with-temp-buffer (thogai-inject-strokes strokes (make-ring (length strokes))) - (buffer-string)))) + (buffer-string))) + ;; Delete space before strokes unless we are at the beginning of the + ;; line. Note that attached and glued strokes do not emit + ;; spaces. So, we cannot mindlessly delete a character without + ;; checking if it is a space. + (unless (= (line-beginning-position) + (point)) + (thogai-delete " "))) (defun thogai-inject-strokes (strokes &optional stroke-ring) "Inject STROKES into STROKE-RING. @@ -334,13 +341,6 @@ should typically be `thogai-stroke-ring'." (list (ring-ref stroke-ring 0))))) ;; Reverse the previous group of strokes. (thogai-reverse-strokes matched-strokes) - ;; Delete space before strokes unless we are at the - ;; beginning of the line. Note that attached and glued - ;; strokes do not emit spaces. So, we cannot mindlessly - ;; delete a character without checking if it is a space. - (unless (= (line-beginning-position) - (point)) - (thogai-delete " ")) ;; Re-insert the previous group of strokes except for the ;; newest stroke. (pcase (reverse matched-strokes) -- cgit v1.2.3