[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Patch] Improvement for unicode.mim, allow all Unicode chars, not on
From: |
Mike FABIAN |
Subject: |
Re: [Patch] Improvement for unicode.mim, allow all Unicode chars, not only BMP |
Date: |
Thu, 24 Feb 2022 16:21:29 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Sorry, my last mail did not have the patch attached but instead a draft
of my mail ☹.
I am attaching the patch here!
Mike FABIAN <mfabian@redhat.com> さんはかきました:
> 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.
>
> The default key binding for ibus to start Unicode code point input is
> Shift+Control+u. In case of unicode.mim, both Control+u *and*
> Shift+Control+u start the Unicode code point input.
>
> Control+u seems to cause a problem for some users because it masks
> that keyboard shortcut for example in LibreOffice Writer where it is used
> to underline text. See:
>
> https://github.com/ibus/ibus-m17n/issues/44#issuecomment-1047663137
>
> unicode.mim contains this to define the keybinding to start Unicode
> code point input:
>
> (command
> (start (_"Start Unicode
> Start typing hexadecimal numbers of Unicode character.")
> (C-U)))
>
> But even though Shift is not mentioned there, both Shift+Control+u *and*
> Control+u start Unicode code point input!
>
> I tried to change that to (S-C-U), (S-C-u), (C-S-U), or (C-S-u) but
> that doesn’t change anything at all, still Unicode code point input
> is started both with Shift+Control+u *and* Control+u.
>
> Then I changed it to (C-a) and now I can also start Unicode code point
> input by typing Control+a *but* the original key binding Control+u is
> also still working.
>
> So the Control+u seems to be hardcoded somewhere else outside of the
> unicode.mim
> file, maybe somewhere in m17n-lib.
>
> How can that be changed? Changing it to Shift+Control+u would probably cause
> less conflict with key bindings in other programs.
>
> Another thing which I didn’t know and which surprised me a lot is this:
>
> One does not need to explicitly switch to the unicode.mim input method
> to do this Unicode code point input. Using *any* m17n input method
> seems to implicitly also load unicode.mim somehow.
>
> For example, I can use the hi-itrans.mim input method and while
> using that type Control+u and input a Unicode character by its code point.
>
> That is quite convenient because one can keep using hi-itrans.mim and quickly
> input a character not available in hi-itrans.mim without having to switch
> explicitly to unicode.mim. This is really nice, but it makes the conflict
> of Control+u with key bindings in other programs more serious.
--
Mike FABIAN <mfabian@redhat.com>
睡眠不足はいい仕事の敵だ。
>From e94fc78cbab6b524065a98c9a674eae19bad89e4 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.35.1