From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Re: Proposal: ls-lisp.el handle --group-directories-first flag Date: Fri, 16 Jul 2021 15:20:58 +0200 Message-ID: References: <8335se5v40.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27419"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 16 15:38:37 2021 Return-path: Envelope-to: ged-emacs-devel@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 1m4O33-0006yR-7B for ged-emacs-devel@m.gmane-mx.org; Fri, 16 Jul 2021 15:38:37 +0200 Original-Received: from localhost ([::1]:40558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4O32-0001Tt-5w for ged-emacs-devel@m.gmane-mx.org; Fri, 16 Jul 2021 09:38:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4O0m-0004DV-Jf for emacs-devel@gnu.org; Fri, 16 Jul 2021 09:36:18 -0400 Original-Received: from mail-oln040092070060.outbound.protection.outlook.com ([40.92.70.60]:1150 helo=EUR03-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4Nm2-0002JI-S5; Fri, 16 Jul 2021 09:21:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XqSNheD6PBt9OG24b61WjLZ99uIfMHx3P2uCfGGQDfU+cOnlQFojRqDgkvQmcC+ApjjxbkMmAJrpVQeGPCyPoos4cY/8PIxDTuxtvC6qlBGg1cRwSiV98oeMjx8AvCCPM/gzdCsk1EfDz9s75G9lkB1j7jpbVcreyVhg37VJsFBwREj3W1XLxo3Ha1kHC2bwWqzsSeZqqxH8RnCyscCuOrf5sbG7RmMWz0OB+OFWgrHhM/Uyf1gm+40418XRaRrFjIhdmJTTJtsf2AYkW2GlbyAItW8W1nByGBdW0s8nQIQ1fVdTJPwKLVTmjE7WLP0agsPWdm0CZrSrpAsqXcNQUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2+36t39+cUOjIvKAmpLSSTd/+SigBbQM4H2jK/DvHdU=; b=XiM8InG+4B3xmB42aSl4B1u7csfFI4XVNVKO0tEO3XThxm5mlCnqmGMK8jtTHwlggLlnjZB2qpuYJ6MNtbaxtDTbkP49+QcU0LLI4hEAMo9gSadO7Xnvq8yFGBEOMmFZaY7SPmr3Wb9nXRUBJf26JoDLDjXefXsv+M9MxIYUSDx2LD3SclCeQ0wsBkOWYjZBkTW0C7RniUaeab87LYyWUNVV1H3bN0iWajTYnsnQaQCZ5YUuDOm4naeP1HzRJZ4UYTcT5QyfCCy9SpjNgETHyDNzARXmuQTrDPLMFLF71c+ZeDqEKltSnc6u7SEmMGZaxYXuiy4SDAE8p1Z8dgyGKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2+36t39+cUOjIvKAmpLSSTd/+SigBbQM4H2jK/DvHdU=; b=DS5Z3f3kKBiOjIm+lDtuN7x/hBiuSgOwtSO/incmxx8EjT2NZAj19bYb8dLrpwitdTYUg6rKJGghBIz57xB9fZbkSuYpsj5L8WgKEYMhwbnKvWxYSEkLFsV7ozUNtB8fVpEEhUzJgkV3YwDZAELa+ed65qhP6jA7aAfyiDwqNjvMG8TLeMene+XNeDCPbziCMmNqZf0W6Tk6osUUNySgszwio+jiC8WFmxg+WZoJSRirnCrWeqN7/6/CAYQ9IUmV7IGzB5mktXUq2xrkD6GTalgVoRDio7pRyp/omBLez/5QS94/oKrCnfsM+pkZz8lLXH8McRIywua1ew0iWkqH9w== Original-Received: from AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e08::4b) by AM5EUR03HT008.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e08::102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Fri, 16 Jul 2021 13:20:59 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2a01:111:e400:7e08::4a) by AM5EUR03FT047.mail.protection.outlook.com (2a01:111:e400:7e08::197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 13:20:59 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:87AC58A35C51C0353956690A7EAF3250DBB5E6D5B19A925E6783B53423F208E8; UpperCasedChecksum:06C1081C07A6D6F6D8F04BECE5E1990B50CADA420681177CAB81D13D4472A66D; SizeAsReceived:7499; Count:46 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::e47b:760e:fa35:f28b]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::e47b:760e:fa35:f28b%6]) with mapi id 15.20.4331.026; Fri, 16 Jul 2021 13:20:59 +0000 In-Reply-To: <8335se5v40.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 16 Jul 2021 14:57:51 +0300") X-TMN: [wHGlirmyVEFz1r/7RvegRSvJCnwoF8ZG] X-ClientProxiedBy: AS8PR04CA0089.eurprd04.prod.outlook.com (2603:10a6:20b:313::34) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87sg0egzt1.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by AS8PR04CA0089.eurprd04.prod.outlook.com (2603:10a6:20b:313::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 13:20:58 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 1e87a258-f66b-47a6-3b59-08d9485c8ccd X-MS-TrafficTypeDiagnostic: AM5EUR03HT008: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o4imENHk9GvfOVcMOzJacNwSANjQeDt7LJMyeoaDpMXh5f7K0L87ShcMC16DAS+yOmC/ufBKc9fvGeHFkF4G+Kivozqwra34gq5rCY5X7jiDy7SJdUgllnivhbzypPaCIHzrPtJuA6MfAkhGmtYRTahdBeLyI3pbtqFVjureoq0ez/RBSg7TkIbSQIXVenDtvLXMUJgb3R9NeLHgcjSwcSvcdc+wCJtq6riwiqtwT/BOzNOpuCG2QcVRLaCnhiSSIVAQkny6DB6NIjBnUJkGXTD/uNykqIGjd5WrEG2U2iccogkW8qDW6ZMtOAa85rx5rwStXN0IwEHWmbPiRe6A5hudKPkr2UIr7lbhnXB5gGpFFCny6EehU6CShW3ldCIdKbSriHewHpw+177Eq5VlWVZRpGvXY9u4w1sGB5cLqOcjQ/I7egq9VuoRiSGAXZZM X-MS-Exchange-AntiSpam-MessageData: UkjsKIE70c2c6DfXtlRlo/ZCLGsFtnNh2SfSQOVBMR+pTHqKK0E8FlQyTCd+0+XAD9V0Ut9KNLFT9zrG9c1G3VyhyCRInQrZuwrsZF/4qYb/1X/sFDY/QdGgyQIO42lSdQ+wjEEnowqJFWUt+V3Ahg== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e87a258-f66b-47a6-3b59-08d9485c8ccd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 13:20:59.1115 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5EUR03HT008 Received-SPF: pass client-ip=40.92.70.60; envelope-from=arthur.miller@live.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271301 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Arthur Miller >> Date: Thu, 15 Jul 2021 11:19:52 +0200 >> >> Just a minor 'out-of-the-box' quality of life improvement mostly for >> MS Windows users. ls-lisp.el is default on MS Windows, and some users >> might share their init configuration between their Gnu/Linux and MS >> Windows systems, it might be nice to have ls-lisp.el recognize >> `--group-directories-first' flag of Gnu ls program. >> >> I have just piggy-back on existing code here; I am not sure if I can >> actually set `ls-lisp-dirs-firs' var to `t' when >> `--group-directories-first' is found, so I am just converting this flag >> to `y' so we can per-use existing machinery. But I would happily skip >> `y' if it is acceptable to change users choice for `ls-lisp-dirs-first' >> variable when `--group-directories-first' is present. > > This is not future-proof: what if 'ls' in some future release will > have the -y option, and we'd want to support that in ls-lisp.el? Yes, I knowm I just thought that world does not directly see an explosion of 'ls' applications development. Yes, I had an idea you wouldn't like the hacky patch, it was nore of a joke. > Doesn't it work to let-bind ls-lisp-dirs-first? I don't know about that one. ls-lisp--insert-directory effectively ensures that switches are passed further the line as a string of chars. The flag is lost in the first step and can't be passed further on. I am not sure it's worth the trouble to modify that behaviour. Or maybe I don't know what you mean. Anyway, see if this is acceptable. It adds one extra variable, so it's still pretty cheap. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=ls-lisp.patch --- ../emacs/lisp/ls-lisp.el 2021-06-06 23:11:38.317648694 +0200 +++ ./ls-lisp.el 2021-07-16 15:00:29.000632720 +0200 @@ -253,6 +253,9 @@ "Format to display float file sizes.") (defvar ls-lisp-filesize-b-fmt " %.0f" "Format to display file sizes in blocks (for the -s switch).") +(defvar ls-lisp--really-dirs-first nil + "`t' if either ls-lisp-dirs-first is set to `t' or GNU ls flag + \"--group-directory-first\" is passed in switches to ls-lisp.") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -291,6 +294,9 @@ ;; Remove --dired switch (if (string-match "--dired " switches) (setq switches (replace-match "" nil nil switches))) + (setq ls-lisp--really-dirs-first + (or ls-lisp-dirs-first + (string-match "--group-directories-first" switches))) ;; Convert SWITCHES to a list of characters. (setq switches (delete ?\ (delete ?- (append switches nil)))) ;; Sometimes we get ".../foo*/" as FILE. While the shell and @@ -682,7 +688,7 @@ (ding) (sit-for 2)))) ; to show user the message! (if (memq ?F switches) ; classify switch (setq file-alist (mapcar 'ls-lisp-classify file-alist))) - (if ls-lisp-dirs-first + (if ls-lisp--really-dirs-first ;; Re-sort directories first, without otherwise changing the ;; ordering, and reverse whole list. cadr of each element of ;; `file-alist' is t for directory, string (name linked to) for --=-=-=--