(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))))))
\f
;; Initialize read-expression-map. It is defined at C level.
(let ((m (make-sparse-keymap)))