all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, 66970@debbugs.gnu.org
Subject: bug#66970: 29.1; Overwrite-mode is not working with Korean characters
Date: Thu, 9 Nov 2023 16:37:17 +0000	[thread overview]
Message-ID: <CALDnm53-F5_eTNTtqNeFB2PppEe9yV93GZvZhcPPx2n=e4BvgA@mail.gmail.com> (raw)
In-Reply-To: <53b382ce-b331-4473-807c-e453df9ea250@gmail.com>

Eli brought up this bug in emacs-devel and I thought
I would give it a shot.

I had never touched this code or anything like it, but I do
use input methods a bit for portuguese.  Let me know what
you think.

diff --git a/lisp/leim/quail/hangul.el b/lisp/leim/quail/hangul.el
index 46a2e5a6ba2..7e6c7310179 100644
--- a/lisp/leim/quail/hangul.el
+++ b/lisp/leim/quail/hangul.el
@@ -146,21 +146,34 @@ hangul-insert-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))))))))
+         (may-have-to-overwrite-p
+          (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 kills the overlay
+    (dolist (c chars-to-insert)
+      (let ((last-command-event c)
+            (overwrite-mode (and overwrite-mode
+                                 may-have-to-overwrite-p
+                                 overwrite-mode)))
+        (self-insert-command 1)
+        ;; TODO: maybe use cl-loop for an easier-to-read loop?
+        (setq may-have-to-overwrite-p nil)))
+    ; this revives it (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.



-- 
João Távora





  parent reply	other threads:[~2023-11-09 16:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-06 16:07 bug#66970: 29.1; Overwrite-mode is not working with Korean characters SUKBEOM KIM
2023-11-06 16:37 ` bug#66970: (no subject) SUKBEOM KIM
2023-11-06 17:03   ` Eli Zaretskii
2023-11-06 23:19     ` bug#66970: 29.1; Overwrite-mode is not working with Korean characters SUKBEOM KIM
2023-11-08 13:18       ` Eli Zaretskii
2023-11-08  0:48     ` bug#66970: (no subject) Sukbeom Kim
2023-11-06 16:41 ` bug#66970: 29.1; Overwrite-mode is not working with Korean characters Eli Zaretskii
2023-11-09 16:37 ` João Távora [this message]
2023-11-09 16:50   ` Eli Zaretskii
2023-11-10  0:34     ` Sukbeom Kim
2023-11-10  7:13       ` Eli Zaretskii
2023-11-10 22:32         ` Sukbeom Kim
2023-11-13 12:41         ` João Távora
2023-11-13 14:31           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALDnm53-F5_eTNTtqNeFB2PppEe9yV93GZvZhcPPx2n=e4BvgA@mail.gmail.com' \
    --to=joaotavora@gmail.com \
    --cc=66970@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.