emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unicode confusables and reordering characters considered harmful


From: Andreas Schwab
Subject: Re: Unicode confusables and reordering characters considered harmful
Date: Wed, 03 Nov 2021 12:29:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

On Nov 03 2021, Gregory Heytings wrote:

> diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
> index db350a5f70..0005d3d4d7 100644
> --- a/lisp/progmodes/prog-mode.el
> +++ b/lisp/progmodes/prog-mode.el
> @@ -289,6 +289,24 @@ turn-on-prettify-symbols-mode
>               (local-variable-p 'prettify-symbols-alist))
>      (prettify-symbols-mode 1)))
>  
> +(defun fontify-bidi-reordering-characters ()
> +  (font-lock-add-keywords nil '(("⁩\\|‬\\|⁨\\|⁧\\|⁦\\|‫\\|‪\\|‮\\|‭" . 
> 'font-lock-warning-face))))
> +
> +(defun make-bidi-reordering-characters-visible ()
> +  (setq buffer-display-table (or buffer-display-table
> +                                 standard-display-table
> +                                 (make-display-table)))
> +  (aset buffer-display-table ?‪ [?→])
> +  (aset buffer-display-table ?‫ [?←])
> +  (aset buffer-display-table ?‭ [?→])
> +  (aset buffer-display-table ?‮ [?←])
> +  (aset buffer-display-table ?⁦ [?→])
> +  (aset buffer-display-table ?⁧ [?←])
> +  (aset buffer-display-table ?⁨ [?↓])
> +  (aset buffer-display-table ?‬ [?↑])
> +  (aset buffer-display-table ?⁩ [?↑])

A perfect example of how legitimate use of these characters can mess up
your source. :-)

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]