From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: Human-readable file sorting Date: Sat, 20 Feb 2016 10:25:50 -0800 (PST) Message-ID: <7652fd6b-aa2e-4ffc-a594-1256f467da5d@default> References: <87povs41xg.fsf@gnus.org> <87bn7c3yms.fsf@gnus.org> <87r3g7exb2.fsf@gnus.org> <87oabbe1by.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1455992785 8292 80.91.229.3 (20 Feb 2016 18:26:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Feb 2016 18:26:25 +0000 (UTC) To: Michael Heerdegen , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 20 19:26:13 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aXCEM-0003rQ-MH for ged-emacs-devel@m.gmane.org; Sat, 20 Feb 2016 19:26:10 +0100 Original-Received: from localhost ([::1]:34777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXCEM-00078Q-7C for ged-emacs-devel@m.gmane.org; Sat, 20 Feb 2016 13:26:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXCE9-000767-9r for emacs-devel@gnu.org; Sat, 20 Feb 2016 13:25:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXCE6-0004EQ-4G for emacs-devel@gnu.org; Sat, 20 Feb 2016 13:25:57 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:39163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXCE5-0004EK-Sp for emacs-devel@gnu.org; Sat, 20 Feb 2016 13:25:54 -0500 Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u1KIPq5E018251 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 20 Feb 2016 18:25:53 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u1KIPqYT002513 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 20 Feb 2016 18:25:52 GMT Original-Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u1KIPppK011251; Sat, 20 Feb 2016 18:25:52 GMT In-Reply-To: <87oabbe1by.fsf@web.de> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:200332 Archived-At: > > (defun file-string-lessp (s1 s2) > > (pcase file-sorting-method > > (,unicode > > (string-lessp s1 s2)) > > (,human > > (human-string-lessp s1 s2))) > > ..) > > > > (Hey! Did I get the pcase syntax right? Bonus points!) >=20 > These patterns are invalid. I think the patterns you want are > 'unicode and 'human. `eql' tests of the value of a symbol are exactly what Common Lisp `case' is for (`cl-case' in Elisp). (cl-case file-sorting-method (unicode (string-lessp s1 s2)) (human (human-string-lessp s1 s2)) (otherwise (my-default-string-less-p s1 s2))) Use `pcase' when you need to do something fancier - that makes the fancy need clear to a human reader. If Lars's "..)" requires fancy stuff then `pcase' can make sense here. Otherwise, it is overkill. ---- FWIW: That should be `human-string-less-p', not `human-string-lessp'. `string-lessp' (and `smie-rule-bolp') are (AFAICT) the only exceptions (found in the Emacs manuals, at least) to the rule stated in (elisp) `Coding Conventions' that a predicate name that uses multiple words should end in `-p' (not just `p'): If the purpose of a function is to tell you whether a certain condition is true or false, give the function a name that ends in 'p' (which stands for "predicate"). If the name is one word, add just 'p'; if the name is multiple words, add '-p'. Examples are ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 'framep' and 'frame-live-p'. Both of the names `string-lessp' and `smie-rule-bolp' could claim to reuse well known names `lessp' and `bolp', but that claim is lame. `time-less-p' is correct; `string-lessp' not so much. =20 `string-lessp' was perhaps named before the naming rule was adopted. `smie-rule-bolp' presumably has no such excuse. (And `string-lessp' at least has an alias: `string<'.)