Commits

Anonymous committed 233b338

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.

Comments (0)

Files changed (3)

+2011-12-05  Eli Zaretskii  <eliz@gnu.org>
+
+	* 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  <cyd@gnu.org>
 
 	* faces.el (read-color): Doc fix.

lisp/descr-text.el

               (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),
 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))
 		     (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)))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.