aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/international
diff options
context:
space:
mode:
authorEli Zaretskii <[email protected]>2012-03-08 20:21:07 +0200
committerEli Zaretskii <[email protected]>2012-03-08 20:21:07 +0200
commit6ff6e72f7993e06f831428e0ad8ccc0c5bf2524a (patch)
tree16acb97af1eba84948f738e7740931b8acaa2c53 /lisp/international
parent9cec78342c003b09a961c1b501eba55e14ef32cc (diff)
Prevent bidi reordering of rows and keys in the quail layout display.
lisp/international/quail.el (quail-insert-kbd-layout): Insert invisible LRM characters before each character in a keyboard layout cell, to prevent their reordering by bidi display engine. For details, see the discussion in http://lists.gnu.org/archive/html/emacs-devel/2012-03/msg00085.html.
Diffstat (limited to 'lisp/international')
-rw-r--r--lisp/international/quail.el19
1 files changed, 14 insertions, 5 deletions
diff --git a/lisp/international/quail.el b/lisp/international/quail.el
index 48aa013c67..4e068741e4 100644
--- a/lisp/international/quail.el
+++ b/lisp/international/quail.el
@@ -833,7 +833,15 @@ The format of KBD-LAYOUT is the same as `quail-keyboard-layout'."
(insert bar)
(if (= (if (stringp lower) (string-width lower) (char-width lower)) 1)
(insert " "))
- (insert lower upper)
+ ;; Insert invisible LRM characters to force each keyboard row
+ ;; be rendered left to right, and also to prevent reordering of
+ ;; individual characters within each cell. See
+ ;; http://lists.gnu.org/archive/html/emacs-devel/2012-03/msg00085.html
+ ;; for the reasons.
+ (insert (propertize (string ?\x200e) 'invisible t))
+ (insert lower)
+ (insert (propertize (string ?\x200e) 'invisible t))
+ (insert upper)
(if (= (if (stringp upper) (string-width upper) (char-width upper)) 1)
(insert " "))
(setq i (+ i 2))
@@ -849,20 +857,21 @@ The format of KBD-LAYOUT is the same as `quail-keyboard-layout'."
;;(delete-region pos (point)))
(let ((from1 100) (to1 0) from2 to2)
(while (not (eobp))
- (if (looking-at "[| ]*$")
+ (if (looking-at "[| \u200e]*$")
;; The entire row is blank.
(delete-region (point) (match-end 0))
;; Delete blank key columns at the head.
- (if (looking-at " *\\(| \\)+")
+ (if (looking-at " *\\(| \u200e \u200e \\)+")
(subst-char-in-region (point) (match-end 0) ?| ? ))
;; Delete blank key columns at the tail.
- (if (re-search-forward "\\( |\\)+$" (line-end-position) t)
+ (if (re-search-forward "\\( \u200e \u200e |\\)+$"
+ (line-end-position) t)
(delete-region (match-beginning 0) (point)))
(beginning-of-line))
;; Calculate the start and end columns of a horizontal line.
(if (eolp)
(setq from2 from1 to2 to1)
- (skip-chars-forward " ")
+ (skip-chars-forward " \u200e")
(setq from2 (current-column))
(end-of-line)
(setq to2 (current-column))