From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxim Nikulin Newsgroups: gmane.emacs.bugs Subject: bug#59275: Unexpected return value of `string-collate-lessp' on Mac Date: Sun, 27 Nov 2022 22:19:24 +0700 Message-ID: <5fb31dfb-6bde-b895-4c0d-dc1f6eed704c@gmail.com> References: <87zgcsdfma.fsf@localhost> <83iljgib4w.fsf@gnu.org> <87h6z0cl6b.fsf@localhost> <837czwi6yp.fsf@gnu.org> <8735ajel7y.fsf@localhost> <83mt8rgill.fsf@gnu.org> <877czokbpk.fsf@localhost> <8335ac4eo5.fsf@gnu.org> <87ilj7dbms.fsf@localhost> <83sfib172p.fsf@gnu.org> <877czimpz4.fsf@localhost> <83r0xqta0d.fsf@gnu.org> <87v8n2je5q.fsf@localhost> <83k03it6i2.fsf@gnu.org> <2ed46071-5cd1-67ca-bd95-1c2a3060807d@gmail.com> <83mt8cpjbd.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25998"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: Ihor Radchenko , 59275@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 27 16:20:19 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 1ozJS7-0006ZJ-Na for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Nov 2022 16:20:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozJRt-00021A-1S; Sun, 27 Nov 2022 10:20:05 -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 1ozJRr-00020y-Kj for bug-gnu-emacs@gnu.org; Sun, 27 Nov 2022 10:20: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 1ozJRr-0003Ku-Bv for bug-gnu-emacs@gnu.org; Sun, 27 Nov 2022 10:20:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ozJRq-0005ht-DN for bug-gnu-emacs@gnu.org; Sun, 27 Nov 2022 10:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Maxim Nikulin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Nov 2022 15:20: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.166956237621926 (code B ref 59275); Sun, 27 Nov 2022 15:20:02 +0000 Original-Received: (at 59275) by debbugs.gnu.org; 27 Nov 2022 15:19:36 +0000 Original-Received: from localhost ([127.0.0.1]:42481 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozJRP-0005ha-FS for submit@debbugs.gnu.org; Sun, 27 Nov 2022 10:19:35 -0500 Original-Received: from mail-lf1-f44.google.com ([209.85.167.44]:36623) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozJRN-0005hU-20 for 59275@debbugs.gnu.org; Sun, 27 Nov 2022 10:19:33 -0500 Original-Received: by mail-lf1-f44.google.com with SMTP id g12so13862758lfh.3 for <59275@debbugs.gnu.org>; Sun, 27 Nov 2022 07:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=v1IH2fY7UeuaJ360fMY24t1ILDhlFl+99oNH8N+7nPg=; b=VVdfZ716W2Jyfg/5q9YvdY2fJ3VdW6krd64Lmkdn0WqmsKKh5rhwCsWr1X2kvE1WHW VYUxk0zqJsR70S+mWHI5x4EveOiA2JJAocwz1sqG99pkhHstCQPwn1CGIhdPOgKj/gBQ BElm490x5o/zmBcWrK5lQvhloOdg2wOwVs0GXx2DvMv5hLqt7S7O+Pg7B2eXM0ZuZbrz VJoMhzcdbD0N/XApqAdjBeQtCP0KktYarLBtO6dvSJQ/PJqE+2Cr2q/jTT2DgdTZSYuz FAJXgxMj32HgfGE8o6ZMDiAzBnJdLLfPf0DU1dkQkLHiu4IlDsOKnK8KbEhRvzCWe+e5 8QAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=v1IH2fY7UeuaJ360fMY24t1ILDhlFl+99oNH8N+7nPg=; b=V0oWctzND2AroqbXef5V+YCzFiAh3FDKm4Pugq0BNciZrZDpTpjC/EWK4ojDmrqrtF GP4Jqf61ppIKEsMQbMIB4zwzT/TBugdKkTVTcQ3iSo166KluwFYVbwV5u33sMnhavflT rAKG02wIJQLHAVp23rYvHdqL9HLnJl0LbcWiDx0eDfDCL/mrraNsJu3Pb+8thoQ5FNCf nqiRVSWRVxJdrcEcNVZy/U6HzY0+doK2XfdETKNWTdwCJd8YdmU2krw4zGVHSemmhhle jyN16LqDZEVeWtlM5o3T1QTPIKR/ooYLsPN1byIc8FXfydcZ2mLRJ8rXdr6IVmquhQqy Ln2g== X-Gm-Message-State: ANoB5pkSTkvNprw2JGi0AtYAfwfO8umOdPh4Ocsur0sGnzqQZ9IamwjB 7BLo2kytR9imTkuITk/QlpY= X-Google-Smtp-Source: AA0mqf5UcY8/JszTJGLAZ/4VG0ukEfLR18c9GvIXV95XcGh7WYJ1YsNAv6MDOEW0yAJIz0GLgP6mJA== X-Received: by 2002:ac2:5f9b:0:b0:4a2:5163:f61b with SMTP id r27-20020ac25f9b000000b004a25163f61bmr15516042lfe.177.1669562366614; Sun, 27 Nov 2022 07:19:26 -0800 (PST) Original-Received: from [192.168.0.101] (nat-0-0.nsk.sibset.net. [5.44.169.188]) by smtp.googlemail.com with ESMTPSA id r7-20020ac24d07000000b0049aa20af00fsm1325692lfi.21.2022.11.27.07.19.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 27 Nov 2022 07:19:26 -0800 (PST) X-Google-Original-From: Maxim Nikulin Content-Language: en-US In-Reply-To: <83mt8cpjbd.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:249225 Archived-At: On 27/11/2022 21:23, Eli Zaretskii wrote: >> From: Maxim Nikulin Date: Sun, 27 Nov 2022 21:00:50 +0700 >> >> Concerning Org, my point is that caseless sorting should be uniform. > > You need to work hard to get that. Just using 'downcase' is not enough, and > neither is using 'string-collate-equalp'. I do not like that in some functions `string-collate-lessp' with IGNORE-CASE argument is used while strings are passed through `downcase' in other places. When proper locales implementation is available, I believe, it is better to consistently use IGNORE-CASE. I assume that text is presented to users, not serialized to be saved or sent as data. When `string-collate-lessp' disregards IGNORE-CASE, I consider it acceptable to use `downcase' (`upcase' may be worse since Org currently uses `downcase'). It provides reasonable balance of invested efforts and obtained result. >> Does not composed/decomposed representation affect comparison result? > > They are different texts, so yes, they do, and they should. > If you want to treat such strings as equivalent, you need to work even > harder, since Emacs currently doesn't have enough infrastructure to do it > right in all cases. `("semana" "señor" ,(ucs-normalize-NFD-string "señor") "sepia") (sort lst #'string-lessp) => ("semana" "señor" "sepia" "señor") (sort lst #'string-collate-lessp) => ("semana" "señor" "señor" "sepia") `string-collate-lessp' is able to handle at least some cases, it is another argument to use it. >> https://stackoverflow.com/questions/319426/how-do-i-do-a-case-insensitive-string-comparison > > This is about Python, no? The value of this link is a collection of examples that are not obvious for everybody. They are applicable to behavior `string-lessp' vs. `string-collate-lessp' as well. >> From my point of view e.g. case transformation rule for Turkish I is a >> minor issue > > Why, Org doesn't want to support Turkish users? From my point of view it is a minor issue in comparison to (string-collate-lessp "a" "B" "C" t) ; => nil that breaks comparison not only for accented letters. You almost manged to convince Ihor to use `string-lessp' instead of `string-collate-lessp'. I do not think it would improve quality of support of Turkish language. My suggestion is to fall back to `downcase' and `string-lessp' only if `string-collate-lessp' is unable to provide case insensitive comparison. >> My argument against `downcase' in `string-collate-lessp' is that it may >> add noticeable performance penalty. > > I'd worry about correctness before performance. `downcase' with `string-lessp' handles more cases than just `string-lessp' (leaving aside buffer-local conversion tables), so form my point of view the former is more correct. Even `downcase' with fixed "C" locale may give result more consistent with user expectations. My impression that users may be familiar with wide spread problems with sorting.