From: Ruijie Yu via "General discussions about Org-mode." <emacs-orgmode@gnu.org>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Axel Kielhorn <org-mode@axelkielhorn.de>, emacs-orgmode@gnu.org
Subject: Re: [DRAFT PATCH v2] Decouple LANG= and testing (was: Test failure due to LANG)
Date: Tue, 25 Apr 2023 23:14:36 +0800 [thread overview]
Message-ID: <sdv354ornuv.fsf@netyu.xyz> (raw)
In-Reply-To: <87v8hks24j.fsf@localhost>
Ihor Radchenko <yantar92@posteo.net> writes:
>> +(defun org-columns--substring-below-width (string start width)
>> + "Similar to `substring', but use `string-width' to check width.
>
> This is not really similar to `substring' as `substring' has totally
> different third argument.
Addressed in v6 -- see my update in the other subthread.
>> +The returned value is a substring of STRING, starting at START,
>> +and is the largest possible substring whose width does not exceed
>> +WIDTH."
>> + (let ((end (min (+ start width) (length string))) res)
>> + (while (and end (>= end start))
>> + (let* ((curr (string-width string start end))
>> + (excess (- curr width)))
>> + (if (cl-plusp excess)
>
> Why not simply (> excess 0)? `cl-plusp' is a bit confusing - we
> generally avoid cl-lib functions unless necessary. (I've never seen
> `cl-plusp' used frequently)
Well, one of the courses I took last year used Common Lisp, where plusp
and minusp were largely preferred over (> x 0), hence the habit. I have
switched over accordingly in v6.
>> (defun org-columns-add-ellipses (string width)
>> "Truncate STRING with WIDTH characters, with ellipses."
>> (cond
>> - ((<= (length string) width) string)
>> - ((<= width (length org-columns-ellipses))
>> - (substring org-columns-ellipses 0 width))
>> - (t (concat (substring string 0 (- width (length org-columns-ellipses)))
>> - org-columns-ellipses))))
>> + ((<= (string-width string) width) string)
>> + ((<= width (string-width org-columns-ellipses))
>> + (org-columns--substring-below-width org-columns-ellipses 0 width))
>> + (t (concat
>> + (org-columns--substring-below-width
>> + string 0 (- width (length org-columns-ellipses)))
>> + org-columns-ellipses))))
>
> It will be best to write dedicated tests here that will clearly indicate
> issues when some non-standard LANG environment is used. The current
> failure is rather difficult to debug.
Done -- somewhat. At the time I wrote the tests I misunderstood what
you said, so now we have a test on org-columns--truncate-below-width
(renamed from org-columns--substring-below-width). I can add a test on
org-columns-add-ellipses as well, if you think it is necessary. But
probably tomorrow.
--
Best,
RY
[Please note that this mail might go to spam due to some
misconfiguration in my mail server -- still investigating.]
next prev parent reply other threads:[~2023-04-25 15:25 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-22 7:11 Test failure due to LANG Axel Kielhorn
2023-04-22 9:51 ` Ruijie Yu via General discussions about Org-mode.
2023-04-22 10:15 ` Ruijie Yu via General discussions about Org-mode.
2023-04-22 12:37 ` Ruijie Yu via General discussions about Org-mode.
2023-04-22 13:01 ` [DRAFT PATCH v2] Decouple LANG= and testing (was: Test failure due to LANG) Ruijie Yu via General discussions about Org-mode.
2023-04-22 13:51 ` Ruijie Yu via General discussions about Org-mode.
2023-04-23 10:54 ` Ihor Radchenko
[not found] ` <sdvjzy2rhne.fsf@netyu.xyz>
2023-04-23 11:19 ` Ihor Radchenko
2023-04-23 14:30 ` Ruijie Yu via General discussions about Org-mode.
2023-04-23 15:03 ` Ihor Radchenko
2023-04-23 15:15 ` Ruijie Yu via General discussions about Org-mode.
2023-04-25 10:11 ` Ihor Radchenko
2023-04-25 15:14 ` Ruijie Yu via General discussions about Org-mode. [this message]
2023-04-22 14:50 ` Axel Kielhorn
2023-04-22 15:03 ` Ruijie Yu via General discussions about Org-mode.
2023-04-23 1:47 ` [DRAFT PATCH v3] " Ruijie Yu via General discussions about Org-mode.
2023-04-23 5:36 ` Axel Kielhorn
2023-04-23 6:46 ` [DRAFT PATCH v4] " Ruijie Yu via General discussions about Org-mode.
2023-04-23 11:17 ` Ihor Radchenko
2023-04-23 13:57 ` Ruijie Yu via General discussions about Org-mode.
2023-04-23 15:07 ` Ihor Radchenko
2023-04-25 8:02 ` [DRAFT PATCH v5] " Ruijie Yu via General discussions about Org-mode.
2023-04-25 15:19 ` [DRAFT PATCH v6] " Ruijie Yu via General discussions about Org-mode.
2023-04-26 9:05 ` Ihor Radchenko
2023-04-26 8:44 ` [DRAFT PATCH v5] " Ihor Radchenko
2023-07-17 8:58 ` Ihor Radchenko
2023-04-22 14:28 ` Test failure due to LANG Axel Kielhorn
2023-04-22 12:35 ` Ihor Radchenko
2023-04-22 13:00 ` Ruijie Yu via General discussions about Org-mode.
2023-04-22 14:21 ` Max Nikulin
2023-04-22 14:35 ` Ihor Radchenko
2023-04-22 14:40 ` Axel Kielhorn
2023-04-22 16:14 ` Max Nikulin
2023-04-22 14:36 ` Axel Kielhorn
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://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sdv354ornuv.fsf@netyu.xyz \
--to=emacs-orgmode@gnu.org \
--cc=org-mode@axelkielhorn.de \
--cc=ruijie@netyu.xyz \
--cc=yantar92@posteo.net \
/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://git.savannah.gnu.org/cgit/emacs/org-mode.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).