On Mon, Jan 6, 2025 at 7:38 PM Ihor Radchenko <yanta...@posteo.net> wrote:
> There was a transient problem on main. Now, make test should run. Now I see, fixed a few minutes before my post, thank you. This reveals that the test failure discussed here is the same on main as on bugfix. In the following I will use the term "bifurcation" as short for: Using ~(string-collate-lessp "a" "B" nil t)~ for the purpose of telling whether the parameter to ignore case has an effect on ~string-collate-lessp~ or not and to choose the right expected test result (the currently implemented case-insensitive or the to be added case-sensitive) for a test result involving ~string-collate-lessp~. > AFAIU, this is more complex. https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59275 looks complicated to me too, but just the very narrow sub-subject of bifurcation seems quite simple to me and I don't agree. > We cannot have a simple test for all possible locales. Why is bifurcation not doing it? > Or did you find one? To my understanding it is bifurcation. > My conclusion from bug#59275 discussion is that simple tries like > (string-collate-lessp "a" "B" locale t) > will not work. I have read a large part of bug#59275 but missed what you mean by will not work. Probably not work for this and that, but for the purpose of just bifurcation I expect ~(string-collate-lessp "a" "B" null t)~ to be sufficient. > Especially for non-US locales. I expect bifurcation to work with _any_ existing or future locale. ~(org-test-string-collate-lessp-ignore-case-supported-p)~ simply measures whether the parameter for ignore case of ~string-collate-lessp~ has an effect in the locale of the current scope, in any locale, libc etc., regardless of how complicated their impact on this matter is. Although it is not necessary for bifurcation alone, the locale in the scope of #+begin_src emacs-lisp ;; Sort alphabetically. Enforce the C locale for consistent results. (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp))) (cl-letf (((symbol-function 'string-collate-lessp) (lambda (s1 s2 &optional _locale ignore-case) (funcall original-string-collate-lessp s1 s2 "C" ignore-case)))) #+end_src in test-org-table/sort-lines is even clearly defined and a very well known and simple one. I don't have any concern about bifurcation. I would even go further and suspect that my patch not just fixes the tests but (as a side effect, not as my goal) obsoletes the current "Enforce the C locale for consistent results". My patch _neutralizes_ the ignore case behavior of ~string-collate-lessp~. Contrary, the current implementation tries to _fixate_ at least the ignore case behavior of ~string-collate-lessp~ which is not possible for some cases according to its docstring.