m17n-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Repost: [Patch] Improvement for unicode.mim, allow all Unicode chars, no


From: Mike FABIAN
Subject: Repost: [Patch] Improvement for unicode.mim, allow all Unicode chars, not only BMP
Date: Mon, 20 Jun 2022 09:31:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Apparently this patch got lost when I last sent it, I am trying again here:

unicode.mim currently supports only characters from the BMP.

And it commits after typing 4 hex digits without waiting for a space to
commit which causes problems for some users, see:

https://github.com/ibus/ibus-m17n/issues/4

I improved unicode.mim to allow typing all Unicode characters like this:

- I allowed typing any number of hex digits and made it commit only
  when a space is typed.
- When more than 5 hex digits are typed and space is used to commit,
  an empty string is committed.

A patch 0001-Improve-unicode.mim-to-allow-input-of-characters-abo.patch
is attached.

This patch makes the behaviour almost the same as the Shift+Ctrl+u Unicode input
ibus offers.

“Almost” because ibus uses just “u” as the prompt whereas unicode.mim
uses “U+” as the prompt. I thought keeping that difference in the
prompt is good so one can easily see which Unicode input mechanism is used.
In case somebody reports a problem one could ask how the prompt looks like
to know immediately whether the problem is m17n or ibus related.

But apart from the prompt it is probably better to make the rest of
the behaviour the same.

-- 
Mike FABIAN <mfabian@redhat.com>
睡眠不足はいい仕事の敵だ。

>From d5f33f6f9c38880fb6c1e7b8a461ac23f3a5c4f3 Mon Sep 17 00:00:00 2001
From: Mike FABIAN <mfabian@redhat.com>
Date: Thu, 24 Feb 2022 12:19:00 +0100
Subject: [PATCH] Improve unicode.mim to allow input of characters above the
 BMP

Allow typing of all Unicode characters by hexadecimal numbers [0-9A-Fa-f]
of a Unicode character code.

To finish and insert the resulting character, type a space.

If you type more than 5 hex digits and finish with space,
the result is empty and nothing at all is inserted.
---
 MIM/unicode.mim | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/MIM/unicode.mim b/MIM/unicode.mim
index 6b4981c..fb374b7 100644
--- a/MIM/unicode.mim
+++ b/MIM/unicode.mim
@@ -23,9 +23,13 @@
 
 (input-method t unicode)
 
-(description (_"Input method for Unicode BMP characters using hexadigits.
-Type C-u followed by four hexadecimal numbers [0-9A-Fa-f]
+(description (_"Input method for Unicode characters using hexadigits.
+Type C-u followed by hexadecimal numbers [0-9A-Fa-f]
 of a Unicode character code.
+To finish and insert the resulting character, type a space.
+
+If you type more than 5 hex digits and finish with space,
+the result is empty and nothing at all is inserted.
 "))
 
 (title "UNICODE")
@@ -44,6 +48,7 @@ Start typing hexadecimal numbers of Unicode character.")
   (start prompt))
 
  (hex
+  (" " " ") ; The space key is used to commit
   ("0" "0") ("1" "1") ("2" "2") ("3" "3") ("4" "4")
   ("5" "5") ("6" "6") ("7" "7") ("8" "8") ("9" "9")
   ("A" "A") ("B" "B") ("C" "C") ("D" "D") ("E" "E") ("F" "F")
@@ -60,9 +65,11 @@ Start typing hexadecimal numbers of Unicode character.")
   (hex (set this @-1)
        (cond ((< @-1 ?A) (sub this 48))
             (1 (sub this 55)))
-       (set code (+ (* code 16) this))
+       (cond ((= @-1 0x0020) (set code code))
+             ((> count 4) (set code 0))
+             (1 (set code (+ (* code 16) this))))
        (set count (+ count 1))
-       (cond ((= count 4)
+       (cond ((= @-1 0x0020)
              (delete @<) (insert code) (shift init))))
   (backspace (undo))))
 
-- 
2.36.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]