[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Collation tests in fns-tests.el
From: |
Eli Zaretskii |
Subject: |
Re: Collation tests in fns-tests.el |
Date: |
Fri, 30 Oct 2015 22:28:09 +0200 |
> From: Ken Brown <address@hidden>
> Date: Fri, 30 Oct 2015 13:51:45 -0400
> Cc: Emacs <address@hidden>
>
> I'm curious why you put the following test in fns-tests.el:
>
> ;; Punctuation and whitespace characters are not taken into account
> ;; for collation in other locales.
> (should
> (equal
> (sort '("11" "12" "1 1" "1 2" "1.1" "1.2")
> (lambda (a b)
> (let ((w32-collate-ignore-punctuation t))
> (string-collate-lessp
> a b (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8")))))
> '("11" "1 1" "1.1" "12" "1 2" "1.2")))
>
> This suggests that punctuation and whitespace should definitely not be
> taken into account in non-POSIX locales.
They were found to be ignored in all the cases we tested until now.
> But the docstring of 'sort' is much less definitive:
>
> "This function obeys the conventions for collation order in your locale
> settings. For example, punctuation and whitespace characters *might* be
> considered less significant for sorting." [My emphasis.]
>
> Is there some place where emacs relies on punctuation and whitespace
> being ignored?
Listing of files generally ignores them, as one example. ls-lisp.el
relies on that to emulate what 'ls' the program does on Posix hosts.
> P.S. My question is motivated by the fact that punctuation and
> whitespace are not ignored on Cygwin in non-POSIX locales, and it does
> not seem to be easy to make this happen. If you're interested in the
> gory details, start here:
>
> https://www.cygwin.com/ml/cygwin/2015-10/msg00516.html
You already said in that discussion what I'd suggest ;-)
Since Cygwin tries to be compatible to GNU/Linux (i.e. glibc), it
should indeed use some non-zero flags in its implementation of string
collation-dependent comparison. IMO, it makes no sense not to do
that, since users expect that to happen. Then the above test will
work for it, and moreover, ls-lisp.el will, too.