diff options
| author | Kenichi Handa | 2012-03-12 16:42:02 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2012-03-12 16:42:02 +0900 |
| commit | 4b05d72231e7653b1c4eee9ecf95758f7767764a (patch) | |
| tree | d847285dd1d58c5354a8c2b3698381e965079675 | |
| parent | d1f55f1668a70cc196509d11c7c92d22b1aa5ee7 (diff) | |
| download | emacs-4b05d72231e7653b1c4eee9ecf95758f7767764a.tar.gz emacs-4b05d72231e7653b1c4eee9ecf95758f7767764a.zip | |
international/quail.el (quail-insert-kbd-layout): Surround each row by LRO and PDF instead of inserting many LRMs. Pad the left and right of each non-spacing marks. Insert invisible space between lower and upper characters to prevent composition.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/international/quail.el | 39 |
2 files changed, 30 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5021fbde22c..f9e7eac9123 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-03-12 Kenichi Handa <handa@m17n.org> | ||
| 2 | |||
| 3 | * international/quail.el (quail-insert-kbd-layout): Surround each | ||
| 4 | row by LRO and PDF instead of inserting many LRMs. Pad the left | ||
| 5 | and right of each non-spacing marks. Insert invisible space | ||
| 6 | between lower and upper characters to prevent composition. | ||
| 7 | |||
| 1 | 2012-03-12 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2012-03-12 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * minibuffer.el (minibuffer-complete): Don't get confused when the | 10 | * minibuffer.el (minibuffer-complete): Don't get confused when the |
diff --git a/lisp/international/quail.el b/lisp/international/quail.el index 4e068741e43..e0e6bfd465b 100644 --- a/lisp/international/quail.el +++ b/lisp/international/quail.el | |||
| @@ -825,28 +825,35 @@ The format of KBD-LAYOUT is the same as `quail-keyboard-layout'." | |||
| 825 | (setq i 0) | 825 | (setq i 0) |
| 826 | (while (< i quail-keyboard-layout-len) | 826 | (while (< i quail-keyboard-layout-len) |
| 827 | (when (= (% i 30) 0) | 827 | (when (= (% i 30) 0) |
| 828 | ;; Insert LRO to avoid bidi-reordering of keyboard cells. | ||
| 829 | (insert (propertize (string ?\x202d) 'invisible t)) | ||
| 828 | (setq row (/ i 30)) | 830 | (setq row (/ i 30)) |
| 829 | (if (> row 1) | 831 | (if (> row 1) |
| 830 | (insert-char 32 (+ row (/ (- row 2) 2))))) | 832 | (insert-char 32 (+ row (/ (- row 2) 2))))) |
| 831 | (setq lower (aref layout i) | 833 | (setq lower (aref layout i) |
| 832 | upper (aref layout (1+ i))) | 834 | upper (aref layout (1+ i))) |
| 833 | (insert bar) | 835 | (insert bar) |
| 834 | (if (= (if (stringp lower) (string-width lower) (char-width lower)) 1) | 836 | (if (< (if (stringp lower) (string-width lower) (char-width lower)) 2) |
| 835 | (insert " ")) | 837 | (insert " ")) |
| 836 | ;; Insert invisible LRM characters to force each keyboard row | 838 | (if (and (characterp lower) |
| 837 | ;; be rendered left to right, and also to prevent reordering of | 839 | (eq (get-char-code-property lower 'general-category) 'Mn)) |
| 838 | ;; individual characters within each cell. See | 840 | ;; Pad the left and right of non-spacing characters. |
| 839 | ;; http://lists.gnu.org/archive/html/emacs-devel/2012-03/msg00085.html | 841 | (setq lower (compose-string (string lower) 0 1 |
| 840 | ;; for the reasons. | 842 | (format "\t%c\t" lower)))) |
| 841 | (insert (propertize (string ?\x200e) 'invisible t)) | 843 | (if (and (characterp upper) |
| 842 | (insert lower) | 844 | (eq (get-char-code-property upper 'general-category) 'Mn)) |
| 843 | (insert (propertize (string ?\x200e) 'invisible t)) | 845 | ;; Pad the left and right of non-spacing characters. |
| 844 | (insert upper) | 846 | (setq upper (compose-string (string upper) 0 1 |
| 845 | (if (= (if (stringp upper) (string-width upper) (char-width upper)) 1) | 847 | (format "\t%c\t" upper)))) |
| 848 | (insert lower (propertize " " 'invisible t) upper) | ||
| 849 | (if (< (if (stringp upper) (string-width upper) (char-width upper)) 2) | ||
| 846 | (insert " ")) | 850 | (insert " ")) |
| 847 | (setq i (+ i 2)) | 851 | (setq i (+ i 2)) |
| 848 | (if (= (% i 30) 0) | 852 | (if (= (% i 30) 0) |
| 849 | (insert bar "\n"))) | 853 | (insert bar |
| 854 | ;; Insert PDF to deny the previously inserted LRO. | ||
| 855 | (propertize (string ?\x202c) 'invisible t) | ||
| 856 | "\n"))) | ||
| 850 | ;; Insert horizontal lines while deleting blank key columns at the | 857 | ;; Insert horizontal lines while deleting blank key columns at the |
| 851 | ;; beginning and end of each line. | 858 | ;; beginning and end of each line. |
| 852 | (save-restriction | 859 | (save-restriction |
| @@ -857,21 +864,21 @@ The format of KBD-LAYOUT is the same as `quail-keyboard-layout'." | |||
| 857 | ;;(delete-region pos (point))) | 864 | ;;(delete-region pos (point))) |
| 858 | (let ((from1 100) (to1 0) from2 to2) | 865 | (let ((from1 100) (to1 0) from2 to2) |
| 859 | (while (not (eobp)) | 866 | (while (not (eobp)) |
| 860 | (if (looking-at "[| \u200e]*$") | 867 | (if (looking-at "[| \u202c\u202d]*$") |
| 861 | ;; The entire row is blank. | 868 | ;; The entire row is blank. |
| 862 | (delete-region (point) (match-end 0)) | 869 | (delete-region (point) (match-end 0)) |
| 863 | ;; Delete blank key columns at the head. | 870 | ;; Delete blank key columns at the head. |
| 864 | (if (looking-at " *\\(| \u200e \u200e \\)+") | 871 | (if (looking-at "\u202d? *\\(| \\)+") |
| 865 | (subst-char-in-region (point) (match-end 0) ?| ? )) | 872 | (subst-char-in-region (point) (match-end 0) ?| ? )) |
| 866 | ;; Delete blank key columns at the tail. | 873 | ;; Delete blank key columns at the tail. |
| 867 | (if (re-search-forward "\\( \u200e \u200e |\\)+$" | 874 | (if (re-search-forward "\\( |\\)+\u202c?$" |
| 868 | (line-end-position) t) | 875 | (line-end-position) t) |
| 869 | (delete-region (match-beginning 0) (point))) | 876 | (delete-region (match-beginning 0) (point))) |
| 870 | (beginning-of-line)) | 877 | (beginning-of-line)) |
| 871 | ;; Calculate the start and end columns of a horizontal line. | 878 | ;; Calculate the start and end columns of a horizontal line. |
| 872 | (if (eolp) | 879 | (if (eolp) |
| 873 | (setq from2 from1 to2 to1) | 880 | (setq from2 from1 to2 to1) |
| 874 | (skip-chars-forward " \u200e") | 881 | (skip-chars-forward " \u202d") |
| 875 | (setq from2 (current-column)) | 882 | (setq from2 (current-column)) |
| 876 | (end-of-line) | 883 | (end-of-line) |
| 877 | (setq to2 (current-column)) | 884 | (setq to2 (current-column)) |