From: Eli Zaretskii Date: Mon, 5 Dec 2011 17:46:27 +0000 (+0200) Subject: Fix "C-x =" wrt display of strong RTL characters and directional controls. X-Git-Tag: emacs-pretest-24.0.93~222 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=71cc0b7439279dacaa9fa8a6dd97fb073c46551b;p=emacs.git Fix "C-x =" wrt display of strong RTL characters and directional controls. lisp/descr-text.el (describe-char): Fix display of strong right-to-left characters and directional embeddings and overrides. lisp/simple.el (what-cursor-position): Fix display of codepoints of strong right-to-left characters by appending LRM. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ff9a8ad19df..8cb089d523e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2011-12-05 Eli Zaretskii + + * descr-text.el (describe-char): Fix display of strong + right-to-left characters and directional embeddings and overrides. + + * simple.el (what-cursor-position): Fix display of codepoints of + strong right-to-left characters. + 2011-12-05 Chong Yidong * faces.el (read-color): Doc fix. diff --git a/lisp/descr-text.el b/lisp/descr-text.el index f285fe42332..47f96e8d68f 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el @@ -422,6 +422,20 @@ as well as widgets, buttons, overlays, and text properties." (setq charset (char-charset char) code (encode-char char charset))) (setq code char)) + (cond + ;; Append a PDF character to directional embeddings and + ;; overrides, to prevent potential messup of the following + ;; text. + ((memq char '(?\x202a ?\x202b ?\x202d ?\x202e)) + (setq char-description + (concat char-description + (propertize (string ?\x202c) 'invisible t)))) + ;; Append a LRM character to any strong character to avoid + ;; messing up the numerical codepoint. + ((memq (get-char-code-property char 'bidi-class) '(R AL)) + (setq char-description + (concat char-description + (propertize (string ?\x200e) 'invisible t))))) (when composition ;; When the composition is trivial (i.e. composed only with the ;; current character itself without any alternate characters), diff --git a/lisp/simple.el b/lisp/simple.el index b718546248b..e9d88a210cf 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1052,16 +1052,23 @@ In addition, with prefix argument, show details about that character in *Help* buffer. See also the command `describe-char'." (interactive "P") (let* ((char (following-char)) - ;; If the character is one of LRE, LRO, RLE, RLO, it will - ;; start a directional embedding, which could completely - ;; disrupt the rest of the line (e.g., RLO will display the - ;; rest of the line right-to-left). So we put an invisible - ;; PDF character after these characters, to end the - ;; embedding, which eliminates any effects on the rest of the - ;; line. - (pdf (if (memq char '(?\x202a ?\x202b ?\x202d ?\x202e)) - (propertize (string ?\x202c) 'invisible t) - "")) + (bidi-fixer + (cond ((memq char '(?\x202a ?\x202b ?\x202d ?\x202e)) + ;; If the character is one of LRE, LRO, RLE, RLO, it + ;; will start a directional embedding, which could + ;; completely disrupt the rest of the line (e.g., RLO + ;; will display the rest of the line right-to-left). + ;; So we put an invisible PDF character after these + ;; characters, to end the embedding, which eliminates + ;; any effects on the rest of the line. + (propertize (string ?\x202c) 'invisible t)) + ;; Strong right-to-left characters cause reordering of + ;; the following numerical characters which show the + ;; codepoint, so append LRM to countermand that. + ((memq (get-char-code-property char 'bidi-class) '(R AL)) + (propertize (string ?\x200e) 'invisible t)) + (t + ""))) (beg (point-min)) (end (point-max)) (pos (point)) @@ -1125,14 +1132,15 @@ in *Help* buffer. See also the command `describe-char'." (if (< char 256) (single-key-description char) (buffer-substring-no-properties (point) (1+ (point)))) - pdf encoding-msg pos total percent beg end col hscroll) + bidi-fixer + encoding-msg pos total percent beg end col hscroll) (message "Char: %s%s %s point=%d of %d (%d%%) column=%d%s" (if enable-multibyte-characters (if (< char 128) (single-key-description char) (buffer-substring-no-properties (point) (1+ (point)))) (single-key-description char)) - pdf encoding-msg pos total percent col hscroll)))))) + bidi-fixer encoding-msg pos total percent col hscroll)))))) ;; Initialize read-expression-map. It is defined at C level. (let ((m (make-sparse-keymap)))