From: Teemu Likonen <tlikonen@iki.fi>
To: notmuch@notmuchmail.org
Subject: Message headers in right-to-left mode in Emacs notmuch-show-mode
Date: Mon, 03 Aug 2020 09:13:35 +0300 [thread overview]
Message-ID: <87lfiwxnn4.fsf@iki.fi> (raw)
[-- Attachment #1.1.1: Type: text/plain, Size: 4109 bytes --]
Emacs uses setting bidi-paragraph-direction=nil by default which means
that paragraph's text direction can change automatically, for example:
right-to-left. A quote from the variable's description:
If this is nil (the default), the direction of each paragraph is
determined by the first strong directional character of its text.
So, in notmuch-show-mode the message header paragraph is switched to
right-to-left mode if headers contain a "strong directional"
right-to-left character.
The result can be seen in the attached jpg image which displays part of
the message <id:20200614013343.GB1808@freeshell.de>
<https://lists.debian.org/debian-devel/2020/06/msg00099.html>.
I think message headers should always be in left-to-right mode but
message contents should follow the Emacs default (choose automatically
from the content). I believe the header part can be switched to
left-to-right mode by using function bidi-string-mark-left-to-right.
Below is a relevant quote from Emacs Lisp reference manual.
Unfortunately I don't know Notmuch Emacs code (at least not yet). So
this message is mainly for documenting the current behavior.
Emacs Lisp reference manual, section "Bidirectional Display".
https://www.gnu.org/software/emacs/manual/html_node/elisp/Bidirectional-Display.html#Bidirectional-Display
Bidirectional reordering can have surprising and unpleasant effects
when two strings with bidirectional content are juxtaposed in a
buffer, or otherwise programmatically concatenated into a string of
text. A typical problematic case is when a buffer consists of
sequences of text fields separated by whitespace or punctuation
characters, like Buffer Menu mode or Rmail Summary Mode. Because the
punctuation characters used as separators have “weak
directionality”, they take on the directionality of surrounding
text. As result, a numeric field that follows a field with
bidirectional content can be displayed _to the left_ of the
preceding field, messing up the expected layout. There are several
ways to avoid this problem:
− Append the special character U+200E LEFT-TO-RIGHT MARK, or LRM,
to the end of each field that may have bidirectional content,
or prepend it to the beginning of the following field. The
function ‘bidi-string-mark-left-to-right’, described below,
comes in handy for this purpose. (In a right-to-left paragraph,
use U+200F RIGHT-TO-LEFT MARK, or RLM, instead.) This is one of
the solutions recommended by the UBA.
− Include the tab character in the field separator. The tab
character plays the role of “segment separator” in
bidirectional reordering, causing the text on either side to be
reordered separately.
− Separate fields with a ‘display’ property or overlay with a
property value of the form ‘(space . PROPS)’ (*note Specified
Space::). Emacs treats this display specification as a
“paragraph separator”, and reorders the text on either side
separately.
-- Function: bidi-string-mark-left-to-right string
This function returns its argument STRING, possibly modified,
such that the result can be safely concatenated with another
string, or juxtaposed with another string in a buffer, without
disrupting the relative layout of this string and the next one
on display. If the string returned by this function is
displayed as part of a left-to-right paragraph, it will always
appear on display to the left of the text that follows it. The
function works by examining the characters of its argument, and
if any of those characters could cause reordering on display,
the function appends the LRM character to the string. The
appended LRM character is made invisible by giving it an
‘invisible’ text property of ‘t’ (*note Invisible Text::).
[-- Attachment #1.1.2: notmuch-show-right-to-left.jpg --]
[-- Type: image/jpeg, Size: 79264 bytes --]
[-- Attachment #1.1.3: Type: text/plain, Size: 110 bytes --]
--
/// Teemu Likonen - .-.. http://www.iki.fi/tlikonen/
// OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 251 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
next reply other threads:[~2020-08-03 6:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-03 6:13 Teemu Likonen [this message]
2020-08-03 7:37 ` Message headers in right-to-left mode in Emacs notmuch-show-mode Teemu Likonen
2020-08-04 12:16 ` [PATCH v2] Emacs: Force left-to-right display for message headers Teemu Likonen
2020-08-04 18:02 ` [PATCH v3] " Teemu Likonen
2020-08-05 8:45 ` David Edmondson
2020-08-05 9:40 ` Teemu Likonen
2020-08-05 9:50 ` Teemu Likonen
2020-08-05 10:03 ` David Edmondson
2020-08-05 10:32 ` [PATCH v4] " Teemu Likonen
2020-08-06 12:04 ` David Bremner
2020-08-06 14:50 ` Teemu Likonen
2020-08-06 14:59 ` Teemu Likonen
2020-08-07 4:46 ` [PATCH v5] Emacs: Ensure " Teemu Likonen
2020-08-07 9:23 ` David Edmondson
2020-08-08 19:21 ` David Bremner
2020-08-09 20:12 ` =?utf-8?Q?T=E2=80=AEomi?= Ollila
2020-08-10 8:43 ` David Edmondson
2020-08-10 16:45 ` Teemu Likonen
2020-08-10 18:27 ` Sanitize bidi control chars Teemu Likonen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lfiwxnn4.fsf@iki.fi \
--to=tlikonen@iki.fi \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).