emacs-devel
[Top][All Lists]
Advanced

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

Re: Issues with quail.el


From: K. Handa
Subject: Re: Issues with quail.el
Date: Thu, 17 May 2018 21:31:01 +0900

Hi,

In article <address@hidden>, address@hidden (K. Handa) writes:

> diff --git a/lisp/international/quail.el b/lisp/international/quail.el
> index eece836354..a81244a1db 100644
> --- a/lisp/international/quail.el
> +++ b/lisp/international/quail.el
> @@ -815,7 +815,7 @@ quail-insert-kbd-layout
>                              (aref (cdr translation) 0)
>                            " ")))
>             (setq done-list (cons translation done-list)))
> -       (setq translation (aref kbd-layout i)))
> +       (setq translation ch))
>       (aset layout i translation))
>        (setq i (1+ i)))
 
Have you tried the above patch?  Did it work?

> [...]
> > What I get for the second letter (TET, ט) is:

> >    ט can't be input by the current input method

> I confimed this bug, but it seems that fixing take more time.   Please wait.

Here's the patch to fix it.  Could you please try it?

diff --git a/lisp/international/quail.el b/lisp/international/quail.el
index eece836354..bcbb0c0958 100644
--- a/lisp/international/quail.el
+++ b/lisp/international/quail.el
@@ -786,6 +786,36 @@ quail-keyboard-translate
                char)
            ch))))))
 
+(defun quail-keyboard-untranslate (char)
+  "Translate CHAR back to the one on the current keyboard layout.
+CHAR is the one on the standard keyboard layout.
+If the current keyboard layout does not have the corresponding character,
+return nil."
+  (if (eq quail-keyboard-layout quail-keyboard-layout-standard)
+      ;; All Quail packages are designed based on
+      ;; `quail-keyboard-layout-standard'.
+      char
+    (let ((i 0))
+      ;; Find the key location on the standard keyboard layout.
+      (while (and (< i quail-keyboard-layout-len)
+                 (/= char (aref quail-keyboard-layout-standard i)))
+       (setq i (1+ i)))
+      (if (= i quail-keyboard-layout-len)
+         ;; CHAR is not in the current keyboard layout, which means
+         ;; that a user can not type a key which generates CHAR.
+         ;; Just return nil.
+          nil
+       (let ((ch (aref quail-keyboard-layout i)))
+         (if (= ch ?\ )
+             ;; This location not available in the current keyboard
+             ;; layout.  Check if the location is used to substitute
+             ;; for the other location of the standard layout.
+             (if (setq i (cdr (rassq i quail-keyboard-layout-substitution)))
+                 (aref quail-keyboard-layout i)
+               ;; Just return il as well as above.
+               nil)
+           ch))))))
+
 (defun quail-keyseq-translate (keyseq)
   (apply 'string
         (mapcar (function (lambda (x) (quail-keyboard-translate x)))
@@ -2843,8 +2873,27 @@ quail-show-key
       (error "No input method is activated"))
   (or (assoc current-input-method quail-package-alist)
       (error "The current input method does not use Quail"))
-  (let* ((char (following-char))
-        (key-list (quail-find-key char)))
+  (let ((char (following-char))
+        key-list)
+    ;; Get a list of keyseqs (the standard keyboard layout based) to type CHAR.
+    (let ((quail-keyboard-layout quail-keyboard-layout-standard))
+      (setq key-list (quail-find-key char)))
+    ;; Then convert each key (of each keyseq if any) to the key of the
+    ;; current keyboard layout.
+    (if (and (consp key-list)
+             (quail-kbd-translate))
+        (let (untranslated-key-list)
+          (dolist (keyseq key-list)
+            (setq keyseq
+                  (catch 'tag
+                    (mapconcat #'(lambda (key)
+                                   (setq key (quail-keyboard-untranslate key))
+                                   (if key
+                                       (string key)
+                                     (throw 'tag nil)))
+                               keyseq "")))
+            (if keyseq (push keyseq untranslated-key-list)))
+          (setq key-list (nreverse untranslated-key-list))))
     (cond ((consp key-list)
           (message "To input `%c', type \"%s\""
                    char



reply via email to

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