From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#59275: Unexpected return value of `string-collate-lessp' on Mac Date: Wed, 16 Nov 2022 01:34:09 +0000 Message-ID: <8735ajel7y.fsf@localhost> References: <87zgcsdfma.fsf@localhost> <83iljgib4w.fsf@gnu.org> <87h6z0cl6b.fsf@localhost> <837czwi6yp.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17169"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59275@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 16 02:34:29 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ov7Jt-0004F6-Fb for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 16 Nov 2022 02:34:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ov7Jb-00011A-4X; Tue, 15 Nov 2022 20:34:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ov7JS-00010j-Oh for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2022 20:34:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ov7JS-0005Hs-GO for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2022 20:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ov7JS-0002hA-C3 for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2022 20:34:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Nov 2022 01:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59275 X-GNU-PR-Package: emacs Original-Received: via spool by 59275-submit@debbugs.gnu.org id=B59275.166856242010330 (code B ref 59275); Wed, 16 Nov 2022 01:34:02 +0000 Original-Received: (at 59275) by debbugs.gnu.org; 16 Nov 2022 01:33:40 +0000 Original-Received: from localhost ([127.0.0.1]:55619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov7J6-0002gX-1E for submit@debbugs.gnu.org; Tue, 15 Nov 2022 20:33:40 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:57717) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov7J1-0002gI-Tp for 59275@debbugs.gnu.org; Tue, 15 Nov 2022 20:33:38 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 13806240026 for <59275@debbugs.gnu.org>; Wed, 16 Nov 2022 02:33:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1668562410; bh=1rLJfVO6Z6jbNFXq2WWolXgH710kNNw2SyN5NXhfsGM=; h=From:To:Cc:Subject:Date:From; b=oPNf7vYbHt4dwRx8/GtuL/WiOy3N2pKUM4dYPPQIS5B1pxp4sbjmrHUVdU5xLXGYo WAyiHVLlpcRilAqTnHNefSkVs3CNFo0wFNbywad4IxK8EUwr26LVbanYIuUVCeArgk bk84eOHtbGUGeLAnhf0Jfa318crCn040QhLP3f8lmZDYdPx9kjNM9gVJhIfdrtSpWJ rm/SgPyqb+YRtprpGDNlUZAFQZPmR+aHFskhw9fqRJoJ1JqWJW7FD1kMQgR4nQ4NlR KAr1IlppVXwMu9xwGCBjkBdXitLdYE1JFpuOrZe0u/xc+vx8HQW5+ecDJIp/NJCWW1 ABK7c4yur+0MA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NBltc3lCfz9rxF; Wed, 16 Nov 2022 02:33:27 +0100 (CET) In-Reply-To: <837czwi6yp.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:247983 Archived-At: Eli Zaretskii writes: >> > string-collate-lessp is inherently platform- (and locale-) dependent. >> > Don't use it if you want consistent results across platforms and >> > locales. >>=20 >> Is there a better alternative? > > Alternative to do what job? Reliable sorting. In particular, I am looking for a better PREDICATE argument for `sort-subr' for case-sensitive and case-insensitive sorting of strings. >> Also, do I miss something, or is this pitfall not documented in the >> docstring of `string-collate-lessp'? > > It isn't? then what is this about: > > 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: > > (sort '("11" "12" "1 1" "1 2" "1.1" "1.2") 'string-collate-lessp) > =3D> ("11" "1 1" "1.1" "12" "1 2" "1.2") > [...] > To emulate Unicode-compliant collation on MS-Windows systems, > bind =E2=80=98w32-collate-ignore-punctuation=E2=80=99 to a non-nil valu= e, since > the codeset part of the locale cannot be "UTF-8" on MS-Windows. The above sounds like we just need to worry about some edge cases where different approaches may exist to sorting. Like with punctuation, numbers, and spaces. Having (string-collate-lessp "a" "B" "C" t) ; =3D> nil is totally unexpected because case-insensitive "a"<"B"<"C" sounds like the only reasonable outcome. I'd like the warning to be even more prominent. Feel free to disagree. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at