Re: [PATCH v5] Emacs: Ensure left-to-right display for message headers

Subject: Re: [PATCH v5] Emacs: Ensure left-to-right display for message headers

Date: Sun, 09 Aug 2020 23:12:28 +0300

To: Teemu Likonen, notmuch@notmuchmail.org

Cc:

From: T‮omi Ollila


How about this =D

(Sorry how the headers might look...)

From: contains U+202E (LEFT-TO-RIGHT OVERRIDE) (in =?utf-8?Q?T=E2=80=AEomi?=)

https://www.fileformat.info/info/unicode/char/202e/index.htm

Tomi

---

(top-posting on purpose, all rest is for reference only)

On Fri, Aug 07 2020, Teemu Likonen wrote:

> In notmuch-show buffer insert invisible U+200E LEFT-TO-RIGHT MARK
> character at the beginning of message header paragraph if the From
> header contains a right-to-left character. This ensures that the
> header paragraph is always rendered in left-to-right mode.
>
> See Emacs Lisp reference manual section "(elisp) Bidirectional
> Display" for more info.
> ---
>  emacs/notmuch-show.el | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
>
> As the commit description says this version inserts U+200E
> LEFT-TO-RIGHT MARK only if the first header line (From header)
> contains a right-to-left character.
>
> This version is probably friendlier to the current test files which
> don't expect to see U+200E LEFT-TO-RIGHT MARK in the output.
>
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index c9170466..0eb27e33 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -466,10 +466,16 @@ unchanged ADDRESS if parsing fails."
>  (defun notmuch-show-insert-headerline (headers date tags depth)
>    "Insert a notmuch style headerline based on HEADERS for a
>  message at DEPTH in the current thread."
> -  (let ((start (point)))
> +  (let ((start (point))
> +	(from (notmuch-sanitize
> +	       (notmuch-show-clean-address (plist-get headers :From)))))
> +    (when (string-match "\\cR" from)
> +      ;; If the From header has a right-to-left character add
> +      ;; invisible U+200E LEFT-TO-RIGHT MARK character which forces
> +      ;; the header paragraph as left-to-right text.
> +      (insert (propertize (string ?\x200e) 'invisible t)))
>      (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
> -	    (notmuch-sanitize
> -	     (notmuch-show-clean-address (plist-get headers :From)))
> +	    from
>  	    " ("
>  	    date
>  	    ") ("
> -- 
> 2.20.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: