summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2023-11-13 04:11:09 -0600
committerJoão Távora <joaotavora@gmail.com>2023-11-13 04:11:35 -0600
commit8090ab05434f39b73e6238ebc5ab8e4fcc52acf3 (patch)
tree9ea73939b7b6b883363ea648a4d57ae73a7c71bc
parent4dc26a1e6e11416ea631121e46e2084d4fc29203 (diff)
downloademacs-8090ab05434f39b73e6238ebc5ab8e4fcc52acf3.tar.gz
emacs-8090ab05434f39b73e6238ebc5ab8e4fcc52acf3.tar.bz2
emacs-8090ab05434f39b73e6238ebc5ab8e4fcc52acf3.zip
Fix hanful-insert-character (bug#66970)
* lisp/leim/quail/hangul.el (hangul-insert-character): Rework.
-rw-r--r--lisp/leim/quail/hangul.el43
1 files changed, 28 insertions, 15 deletions
diff --git a/lisp/leim/quail/hangul.el b/lisp/leim/quail/hangul.el
index 46a2e5a6ba2..f399a20a41c 100644
--- a/lisp/leim/quail/hangul.el
+++ b/lisp/leim/quail/hangul.el
@@ -146,21 +146,34 @@ Setup `quail-overlay' to the last character."
(progn
(delete-region (region-beginning) (region-end))
(deactivate-mark)))
- (quail-delete-region)
- (let ((first (car queues)))
- (insert
- (hangul-character
- (+ (aref first 0) (hangul-djamo 'cho (aref first 0) (aref first 1)))
- (+ (aref first 2) (hangul-djamo 'jung (aref first 2) (aref first 3)))
- (+ (aref first 4) (hangul-djamo 'jong (aref first 4) (aref first 5))))))
- (move-overlay quail-overlay (overlay-start quail-overlay) (point))
- (dolist (queue (cdr queues))
- (insert
- (hangul-character
- (+ (aref queue 0) (hangul-djamo 'cho (aref queue 0) (aref queue 1)))
- (+ (aref queue 2) (hangul-djamo 'jung (aref queue 2) (aref queue 3)))
- (+ (aref queue 4) (hangul-djamo 'jong (aref queue 4) (aref queue 5)))))
- (move-overlay quail-overlay (1+ (overlay-start quail-overlay)) (point))))
+ (let* ((chars-to-insert
+ (with-temp-buffer
+ (dolist (queue queues (mapcar #'identity (buffer-string)))
+ (insert
+ (hangul-character
+ (+ (aref queue 0) (hangul-djamo 'cho (aref queue 0) (aref queue 1)))
+ (+ (aref queue 2) (hangul-djamo 'jung (aref queue 2) (aref queue 3)))
+ (+ (aref queue 4) (hangul-djamo 'jong (aref queue 4) (aref queue 5))))))))
+ (overwrite-maybe
+ (or
+ ;; If the overlay isn't showing (i.e. it has 0 length) then
+ ;; we may want to insert char overwriting (iff overwrite-mode is
+ ;; non-nil, of course)
+ (= (overlay-start quail-overlay) (overlay-end quail-overlay))
+ ;; Likewise we want to do it if there is more then one
+ ;; character that were combined.
+ (cdr chars-to-insert))))
+ (quail-delete-region) ; this empties the overlay
+ (dolist (c chars-to-insert)
+ (let ((last-command-event c)
+ (overwrite-mode (and overwrite-mode
+ overwrite-maybe
+ overwrite-mode)))
+ (self-insert-command 1)
+ ;; For chars other than fhe first, no more overwrites desired
+ (setq overwrite-maybe nil)))
+ ; this shows the overlay again (TODO: do we really always revive?)
+ (move-overlay quail-overlay (1- (point)) (point))))
(defun hangul-djamo (jamo char1 char2)
"Return the double Jamo index calculated from the arguments.