[PATCH v4] Emacs: Force left-to-right display for message headers

Subject: [PATCH v4] Emacs: Force left-to-right display for message headers

Date: Wed, 5 Aug 2020 13:32:07 +0300

To: notmuch@notmuchmail.org

Cc: Teemu Likonen, David Edmondson

From: Teemu Likonen


Insert invisible U+200E LEFT-TO-RIGHT MARK character at the beginning
of message header paragraph in notmuch-show buffer. The U+200E
character forces the header paragraph as left-to-right text even if
the header content started with right-to-left characters.

See Emacs Lisp reference manual section "(elisp) Bidirectional
Display" for more info.

Reviewed-by: David Edmondson <dme@dme.org>
---
 emacs/notmuch-show.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index c9170466..6548891f 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -466,9 +466,14 @@ 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)))
-    (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
+    (insert (propertize (string ?\x200e) 'invisible t)
+	    ;; Add invisible U+200E LEFT-TO-RIGHT MARK character (see
+	    ;; above) to force the header paragraph as left-to-right
+	    ;; text even if the header content started with
+	    ;; right-to-left characters.
+	    (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
 	    (notmuch-sanitize
 	     (notmuch-show-clean-address (plist-get headers :From)))
 	    " ("
 	    date
-- 
2.20.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: