From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#36110: find-dired not sorted on any field nor provides a way Date: Fri, 14 Jun 2019 22:09:10 +0300 Organization: LINKOV.NET Message-ID: <878su40ysp.fsf@mail.linkov.net> References: <875zpjipe7.8.fsf@jidanni.org> <87y32efp01.fsf@mail.linkov.net> <87tvd2p7gi.5.fsf@jidanni.org> <87r27xglua.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="242119"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 36110@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jun 14 21:23:07 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hbrmz-0010lI-Vy for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Jun 2019 21:23:06 +0200 Original-Received: from localhost ([::1]:54652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrmy-0006pN-Ma for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Jun 2019 15:23:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39290) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbri9-0003Xh-6o for bug-gnu-emacs@gnu.org; Fri, 14 Jun 2019 15:18:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbri7-0002GW-17 for bug-gnu-emacs@gnu.org; Fri, 14 Jun 2019 15:18:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52518) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbri6-0002GN-Sc for bug-gnu-emacs@gnu.org; Fri, 14 Jun 2019 15:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hbri6-0006vu-LI for bug-gnu-emacs@gnu.org; Fri, 14 Jun 2019 15:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Jun 2019 19:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36110 X-GNU-PR-Package: emacs Original-Received: via spool by 36110-submit@debbugs.gnu.org id=B36110.156053984926557 (code B ref 36110); Fri, 14 Jun 2019 19:18:02 +0000 Original-Received: (at 36110) by debbugs.gnu.org; 14 Jun 2019 19:17:29 +0000 Original-Received: from localhost ([127.0.0.1]:37816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hbrhT-0006u4-9y for submit@debbugs.gnu.org; Fri, 14 Jun 2019 15:17:29 -0400 Original-Received: from bumble.birch.relay.mailchannels.net ([23.83.209.25]:6749) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hbrhQ-0006tv-Lx for 36110@debbugs.gnu.org; Fri, 14 Jun 2019 15:17:21 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A439E8C1BBF; Fri, 14 Jun 2019 19:17:19 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com (100-96-89-88.trex.outbound.svc.cluster.local [100.96.89.88]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id F34708C1BA5; Fri, 14 Jun 2019 19:17:18 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.2); Fri, 14 Jun 2019 19:17:19 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Whispering-Vacuous: 22c7d3d704a95d07_1560539839401_1049704764 X-MC-Loop-Signature: 1560539839401:3684035814 X-MC-Ingress-Time: 1560539839400 Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a62.g.dreamhost.com (Postfix) with ESMTP id 644938059F; Fri, 14 Jun 2019 12:17:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=E65b5Cqaqr+M5Z5TLiU7XHtNGB0=; b= R3Egfrom5X9J+BhET6uv/ZDp0JzOmJx1iaKXmMHz+lPGbOyyDHX+U2h/J6PYB6am qzeORhivS/5AnR6YHa2ixw2YrQEHTeLkxUloLP8qgT7oWszLQK37AT5sRLWDuHxa DjXwek0So/MFbv86yRbeKjnknJNWegHRI9cYOVz9dvM= Original-Received: from mail.jurta.org (m91-129-109-209.cust.tele2.ee [91.129.109.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a62.g.dreamhost.com (Postfix) with ESMTPSA id AE93380594; Fri, 14 Jun 2019 12:17:11 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a62 In-Reply-To: (Glenn Morris's message of "Thu, 13 Jun 2019 20:12:14 -0400") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduuddrudeiuddgudefkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufhofhffjgfkfgggtgesmhdtreertdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdelrddvtdelnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtledrvddtledprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehrghhmsehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:160575 Archived-At: --=-=-= Content-Type: text/plain >>> +@code{'("-exec ls -ld @{@} +" . "-ld")} >> >> Oh, I see you've changed it to the "+" form. I've changed it to the same value as in `find-exec-terminator'. So instead of documenting a command with a terminator that depends on the value of `find-exec-terminator', better would be to provide different customizable options like in the patch below. >> It looks like this does give sorted output, but I find it surprising. >> Is it assured? > > I verified on a directory with a large number of files that the output > is not sorted. (I didn't see how it could be, given how find works.) > But it does appear as if individual "chunks" are sorted, which can give > the appearance of the whole output being sorted if you don't have a lot > of files. I tried to run different commands on all files in the Emacs source tree: 1. find . -ls It produces completely unsorted output. 2. find . -exec ls -ld {} + It splits the output into sizeable chunks and sorts files inside every chunk, so the boundary between chunks is clearly visible, e.g.: -rw-rw-r-- 1 juri juri 6191 May 1 23:49 ./test/src/timefns-tests.el -rw-r--r-- 1 juri juri 13623 Jan 2 22:43 ./test/src/undo-tests.el -rw-r--r-- 1 juri juri 2915 Jan 2 22:43 ./test/src/xml-tests.el drwxr-xr-x 2 juri juri 4096 Jun 11 00:09 ./autom4te.cache -rw-rw-r-- 1 juri juri 945417 Jun 11 00:09 ./autom4te.cache/output.0 -rw-r--r-- 1 juri juri 3431 Jun 11 00:09 ./autom4te.cache/requests 3. find . -print0 | sort -z | xargs -0 -e ls -ld It splits files into chinks, but maintains the sorting order among all files. Its only drawback is misaligned chunks, e.g.: -rw-rw-r-- 1 juri juri 62707 May 21 00:04 ./info/forms.info -rw-rw-r-- 1 juri juri 1476691 Jun 11 00:16 ./info/gnus.info -rw-rw-r-- 1 juri juri 74148 May 21 00:04 ./info/htmlfontify.info -rw-rw-r-- 1 juri juri 234730 May 21 00:04 ./info/idlwave.info -rw-rw-r-- 1 juri juri 51892 May 21 00:04 ./info/ido.info -rw-rw-r-- 1 juri juri 84948 May 21 00:04 ./info/info.info Since an output with more than 5000 files (an approx amount in each chuck in this experiment) is unmanageable by human users, any of the last 2 options is sufficiently good. So here is the patch that allows the user to choose among these options: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=find-ls-option-default.patch diff --git a/lisp/find-dired.el b/lisp/find-dired.el index 2c76179da0..c563ae533a 100644 --- a/lisp/find-dired.el +++ b/lisp/find-dired.el @@ -51,19 +51,23 @@ find-exec-terminator :group 'find-dired :type 'string) +(defvar find-ls-option-default-ls + (cons "-ls" (if (eq system-type 'berkeley-unix) "-gilsb" "-dilsb"))) + +(defvar find-ls-option-default-exec + (cons (format "-exec ls -ld {} %s" find-exec-terminator) "-ld")) + +(defvar find-ls-option-default-xargs + (cons "-print0 | sort -z | xargs -0 -e ls -ld" "-ld")) + ;; find's -ls corresponds to these switches. ;; Note -b, at least GNU find quotes spaces etc. in filenames (defcustom find-ls-option (if (eq 0 (ignore-errors (process-file find-program nil nil nil null-device "-ls"))) - (cons "-ls" - (if (eq system-type 'berkeley-unix) - "-gilsb" - "-dilsb")) - (cons - (format "-exec ls -ld {} %s" find-exec-terminator) - "-ld")) + find-ls-option-default-ls + find-ls-option-default-exec) "A pair of options to produce and parse an `ls -l'-type list from `find'. This is a cons of two strings (FIND-OPTION . LS-SWITCHES). FIND-OPTION is the option (or options) passed to `find' to produce @@ -78,9 +82,20 @@ find-ls-option (\"-ls\" . \"-dilsb\") since GNU find's output has the same format as using GNU ls with the options \"-dilsb\"." - :version "24.1" ; add tests for -ls and -exec + support - :type '(cons (string :tag "Find Option") - (string :tag "Ls Switches")) + :version "27.1" ; add choice of predefined set of options + :type `(choice + (cons :tag "find -ls" + (string ,(car find-ls-option-default-ls)) + (string ,(cdr find-ls-option-default-ls))) + (cons :tag "find -exec ls -ld" + (string ,(car find-ls-option-default-exec)) + (string ,(cdr find-ls-option-default-exec))) + (cons :tag "find -print | sort | xargs" + (string ,(car find-ls-option-default-xargs)) + (string ,(cdr find-ls-option-default-xargs))) + (cons :tag "Other values" + (string :tag "Find Option") + (string :tag "Ls Switches"))) :group 'find-dired) (defcustom find-ls-subdir-switches --=-=-=--