From: Teemu Likonen <tlikonen@iki.fi>
To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org
Cc: David Edmondson <dme@dme.org>
Subject: Re: [PATCH 1/2] Emacs: Add a new function for balancing bidi control chars
Date: Sun, 16 Aug 2020 20:41:55 +0300 [thread overview]
Message-ID: <87v9hi8p3w.fsf@iki.fi> (raw)
In-Reply-To: <m24kp2k118.fsf@guru.guru-group.fi>
[-- Attachment #1.1: Type: text/plain, Size: 1957 bytes --]
* 2020-08-16 19:28:51+03, Tomi Ollila wrote:
> Good stuff -- implementation looks like port of the php code in
>
> https://www.iamcal.com/understanding-bidirectional-text
>
> to emacs lisp... anyway nice implementation took be a bit of
> time for me to understand it...
I don't read PHP and didn't try to read that code at all but the idea is
simple enough.
> thoughts
>
> - is it slow to execute it always, pure lisp implementation;
> (string-match "[\u202a-\u202e]") could be done before that.
> (if it were executed often could loop with `looking-at`
> (and then moving point based on match-end) be faster...
I don't see any speed issues but if we want to optimize I would create a
new sanitize function which walks just once across the characters
without using regular expressions. But currently I think it's
unnecessary micro optimization.
> - *but* adding U+202C's in `notmuch-sanitize` is doing it too early, as
> some functions truncate the strings afterwards if those are too long
> (e.g. `notmuch-search-insert-authors`) so those get lost..
Good point. This would mean that we shouldn't do "bidi ctrl char
balancing" in notmuch-sanitize. We should call the new
notmuch-balance-bidi-ctrl-chars function in various places before
inserting arbitrary strings to buffer and before combining such strings
with other strings.
> (what I noticed when looking `notmuch-search-insert-authors` that it uses
> `length` to check the length of a string -- but that also counts these bidi
> mode changing "characters" (as one char). `string-width` would be better
> there -- and probably in many other places.)
Yes, definitely string-width when truncating is based on width and when
using tabular format in buffers. With that function zero-width
characters really have no width.
--
/// 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 prev parent reply other threads:[~2020-08-16 17:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-15 9:30 [PATCH 0/2] Balance bidi control chars Teemu Likonen
2020-08-15 9:30 ` [PATCH 1/2] Emacs: Add a new function for balancing " Teemu Likonen
2020-08-16 16:28 ` Tomi Ollila
2020-08-16 17:41 ` Teemu Likonen [this message]
2020-08-15 9:30 ` [PATCH 2/2] Emacs: Call notmuch-balance-bidi-ctrl-chars in notmuch-sanitize Teemu Likonen
2020-08-15 9:44 ` [PATCH 0/2] Balance 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=87v9hi8p3w.fsf@iki.fi \
--to=tlikonen@iki.fi \
--cc=dme@dme.org \
--cc=notmuch@notmuchmail.org \
--cc=tomi.ollila@iki.fi \
/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).