Re: [PATCH v4] Emacs: Force left-to-right display for message headers
* 2020-08-06 17:50:36+03, Teemu Likonen wrote: > But here is another idea for the whole thing: When displaying a message > in notmuch-show buffer check if message's From header has any > right-to-left characters and only if it does add invisible U+200E > character at the beginning, otherwise don't bother. This way those tests > probably won't be affected. What do you think? > > Below is a quick try on the top of my previous (v4) patch. I'll do a > proper patch later. Better version which is not based on any patches but the Git version: diff --git c/emacs/notmuch-show.el w/emacs/notmuch-show.el index c9170466..0eb27e33 100644 --- c/emacs/notmuch-show.el +++ w/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 ") (" -- /// Teemu Likonen - .-.. http://www.iki.fi/tlikonen/ // OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450 signature.asc Description: PGP signature ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH v4] Emacs: Force left-to-right display for message headers
* 2020-08-06 09:04:50-03, David Bremner wrote: > This causes 10 tests to fail for me. At a guess, the added > LEFT-TO-RIGHT MARK should probably be stripped out in the test > framework. Either that or added to test output files. The latter > sounds easy to miss when editing. For the first time I ran the tests and got over 60 test fails. :-) I'm probably doing something wrong and have to study the test framework better. I don't know which tests are related to the U+200E LEFT-TO-RIGHT MARK patch but if test output files are representing the content of notmuch-show-mode buffer then I think U+200E belongs in those expected output files, even if the character is invisible. But here is another idea for the whole thing: When displaying a message in notmuch-show buffer check if message's From header has any right-to-left characters and only if it does add invisible U+200E character at the beginning, otherwise don't bother. This way those tests probably won't be affected. What do you think? Below is a quick try on the top of my previous (v4) patch. I'll do a proper patch later. diff --git i/emacs/notmuch-show.el w/emacs/notmuch-show.el index 6548891f..6b7d70d9 100644 --- i/emacs/notmuch-show.el +++ w/emacs/notmuch-show.el @@ -465,22 +465,23 @@ 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 (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 - ") (" - (notmuch-tag-format-tags tags tags) - ")\n") + (let ((start (point)) +(from (notmuch-sanitize + (notmuch-show-clean-address (plist-get headers :From) +(insert (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. + (propertize (string ?\x200e) 'invisible t)) +(notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth)) +from +" (" +date +") (" +(notmuch-tag-format-tags tags tags) +")\n") (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face))) (defun notmuch-show-insert-header (header header-value) "Insert a single header." -- /// Teemu Likonen - .-.. http://www.iki.fi/tlikonen/ // OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450 signature.asc Description: PGP signature ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH v4] Emacs: Force left-to-right display for message headers
Teemu Likonen writes: > 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. This causes 10 tests to fail for me. At a guess, the added LEFT-TO-RIGHT MARK should probably be stripped out in the test framework. Either that or added to test output files. The latter sounds easy to miss when editing. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH v4] Emacs: Force left-to-right display for message headers
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 --- 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-le...@notmuchmail.org