GNU bug report logs - #29513
sorting find-dired

Previous Next

Package: emacs;

Reported by: "Roland Winkler" <winkler <at> gnu.org>

Date: Fri, 1 Dec 2017 00:51:01 UTC

Severity: wishlist

Merged with 36110, 36123

Found in version 25.2

Fixed in version 27.1

Done: "Roland Winkler" <winkler <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29513 in the body.
You can then email your comments to 29513 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 00:51:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Roland Winkler" <winkler <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 01 Dec 2017 00:51:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Roland Winkler" <winkler <at> gnu.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.2; find-dired-centinel
Date: Thu, 30 Nov 2017 18:50:22 -0600
Following a discussion on help-gnu-emacs

https://lists.gnu.org/archive/html/help-gnu-emacs/2017-11/msg00415.html

I request to replace the function find-dired-sentinel by something
like the following that will sort the output of find
lexicographically.  I have tested that the function below works for me.
Yet there might be corner cases I do not know about where it might fail.

(defun find-dired-sentinel (proc state)
  "Sentinel for \\[find-dired] processes."
  (let ((buf (process-buffer proc)))
    (if (buffer-name buf)
	(with-current-buffer buf
	  (let ((inhibit-read-only t))
	    (save-excursion
              (save-restriction
                (widen)
                ;; `find-dired-filter' puts two whitespace characters
                ;; at the beginning of every line.
                (narrow-to-region (point) (- (point-max) 2))
                ;; Sort file names lexicographically.
                (sort-subr nil 'forward-line 'end-of-line
                           (lambda ()
                             (buffer-substring-no-properties
                              (next-single-property-change
                               (point) 'dired-filename)
                              (line-end-position))))
                (widen)
                (let ((point (point-max)))
                  (goto-char point)
                  (insert "\n  find "
                          (substring state 0 -1) ; omit \n at end of STATE.
                          " at " (substring (current-time-string) 0 19))
                  (dired-insert-set-properties point (point))))
              (setq mode-line-process
		    (format ":%s" (process-status proc)))
	      ;; Since the buffer and mode line will show that the
	      ;; process is dead, we can delete it now.  Otherwise it
	      ;; will stay around until M-x `list-processes'.
	      (delete-process proc)
	      (force-mode-line-update))))
	  (message "find-dired %s finished." buf))))




In GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.18.9)
 of 2017-03-03 built on regnitz
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:	Ubuntu 16.04.3 LTS

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF
GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT
LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: 
  locale-coding-system: utf-8-unix

Major mode: Dired




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 07:49:01 GMT) Full text and rfc822 format available.

Message #8 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Roland Winkler" <winkler <at> gnu.org>
Cc: 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Fri, 01 Dec 2017 09:48:16 +0200
> Date: Thu, 30 Nov 2017 18:50:22 -0600
> From: "Roland Winkler" <winkler <at> gnu.org>
> 
> Following a discussion on help-gnu-emacs
> 
> https://lists.gnu.org/archive/html/help-gnu-emacs/2017-11/msg00415.html
> 
> I request to replace the function find-dired-sentinel by something
> like the following that will sort the output of find
> lexicographically.

Thanks.

IMO, if this is deemed a useful feature, it should be optional, as it
will cause files to move on display during the time the shell commands
is running, something that users might find annoying (I certainly
would).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 08:10:02 GMT) Full text and rfc822 format available.

Message #11 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Roland Winkler <winkler <at> gnu.org>
Cc: 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Fri, 01 Dec 2017 09:09:46 +0100
"Roland Winkler" <winkler <at> gnu.org> writes:

> Following a discussion on help-gnu-emacs
>
> https://lists.gnu.org/archive/html/help-gnu-emacs/2017-11/msg00415.html
>
> I request to replace the function find-dired-sentinel by something
> like the following that will sort the output of find
> lexicographically.

If we do this - wouldn't supporting other sort predicates also make
sense (e.g. sort by last change time)?


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 15:27:01 GMT) Full text and rfc822 format available.

Message #14 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Michael Heerdegen <michael_heerdegen <at> web.de>, Roland Winkler
 <winkler <at> gnu.org>
Cc: 29513 <at> debbugs.gnu.org
Subject: RE: bug#29513: 25.2; find-dired-centinel
Date: Fri, 1 Dec 2017 07:26:12 -0800 (PST)
> If we do this - wouldn't supporting other sort predicates also make
> sense (e.g. sort by last change time)?

My thought exactly.  Pretty much anywhere we sort stuff
it makes sense to ask ourselves whether it might be
good to let users specify the sort predicate/order.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 16:29:02 GMT) Full text and rfc822 format available.

Message #17 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: "Roland Winkler" <winkler <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Fri, 1 Dec 2017 10:28:02 -0600
On Fri Dec 1 2017 Eli Zaretskii wrote:
> IMO, if this is deemed a useful feature, it should be optional, as it
> will cause files to move on display during the time the shell commands
> is running, something that users might find annoying (I certainly
> would).

In my code, nothing happens while the shell command is running.  The
sorting happens only once when find has finished its job.  But it
would certainly be fine with me to have a user option such as
find-dired-sort for enabling / disabling this feature.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 17:49:02 GMT) Full text and rfc822 format available.

Message #20 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: "Roland Winkler" <winkler <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 29513 <at> debbugs.gnu.org
Subject: RE: bug#29513: 25.2; find-dired-centinel
Date: Fri, 1 Dec 2017 11:48:34 -0600
On Fri Dec 1 2017 Drew Adams wrote:
> > If we do this - wouldn't supporting other sort predicates also make
> > sense (e.g. sort by last change time)?
> 
> My thought exactly.  Pretty much anywhere we sort stuff
> it makes sense to ask ourselves whether it might be
> good to let users specify the sort predicate/order.

Fine with me, I'd be happy to be able to use such a feature.
The only question is how to achieve that.  The point is that (as far
as I understand these things) something like dired-sort-toggle-or-edit
ultimately relies on the shell command ls to sort its output.

Sorting the output of find by predicates such as last change time
requires to parse its output more carefully.  I believe that
currently dired's parsing capabilities are restricted to identifying
the file name, and my patch for find-dired-sentinel relies on that.

In other words, other predicates require somewhat more work than my
patch.

(All this reminds me of when I wrote proced.el years ago.  Initially
this code relied on the shell command ps that comes with zillions of
flavors on different OSs, which made the code rather fragile.
Things got much cleaner when Eli wrote the built-ins
list-system-processes and process-attributes (thank you Eli!!).  But
I expect that we do not want to re-invent the shell command find for
Emacs.  -- Phrased differently: I do not know how many flavors of
find we may have to cover to sort its output by predicates such as
last change time.)




Changed bug title to 'sorting find-dired' from '25.2; find-dired-centinel' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 01 Dec 2017 18:50:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 19:39:01 GMT) Full text and rfc822 format available.

Message #25 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Roland Winkler" <winkler <at> gnu.org>
Cc: 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Fri, 01 Dec 2017 21:38:18 +0200
> Date: Fri, 1 Dec 2017 10:28:02 -0600
> From: "Roland Winkler" <winkler <at> gnu.org>
> Cc: 29513 <at> debbugs.gnu.org
> 
> On Fri Dec 1 2017 Eli Zaretskii wrote:
> > IMO, if this is deemed a useful feature, it should be optional, as it
> > will cause files to move on display during the time the shell commands
> > is running, something that users might find annoying (I certainly
> > would).
> 
> In my code, nothing happens while the shell command is running.  The
> sorting happens only once when find has finished its job.  But it
> would certainly be fine with me to have a user option such as
> find-dired-sort for enabling / disabling this feature.

Maybe we should simply provide a defcustom, which is a function called
by the sentinel.  Then users could customize what happens after the
files are all collected, be it sort the results or anything else.  The
advantage will be that we won't need to support every possible tweak
of post-processing in core.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 20:06:02 GMT) Full text and rfc822 format available.

Message #28 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Roland Winkler" <winkler <at> gnu.org>
Cc: michael_heerdegen <at> web.de, drew.adams <at> oracle.com, 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Fri, 01 Dec 2017 22:04:31 +0200
> Date: Fri, 1 Dec 2017 11:48:34 -0600
> From: "Roland Winkler" <winkler <at> gnu.org>
> Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 29513 <at> debbugs.gnu.org
> 
> I expect that we do not want to re-invent the shell command find for
> Emacs.

We already have, actually: see find-lisp.el.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 20:07:01 GMT) Full text and rfc822 format available.

Message #31 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: "Roland Winkler" <winkler <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Fri, 1 Dec 2017 14:05:53 -0600
On Fri Dec 1 2017 Eli Zaretskii wrote:
> Maybe we should simply provide a defcustom, which is a function called
> by the sentinel.  Then users could customize what happens after the
> files are all collected, be it sort the results or anything else.  The
> advantage will be that we won't need to support every possible tweak
> of post-processing in core.

Again: fine with me.  This could be done such that the *Find* buffer
is narrowed to the portion containing the output of the shell
command (as in my patch).  Also, as a further option (or default
value of the defcustom) we could provide a function that sorts by
file name (thus providing a real-world example of how this new
defcustom can be used).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 20:17:02 GMT) Full text and rfc822 format available.

Message #34 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: "Roland Winkler" <winkler <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: michael_heerdegen <at> web.de, drew.adams <at> oracle.com, 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Fri, 1 Dec 2017 14:16:09 -0600
> > I expect that we do not want to re-invent the shell command find for
> > Emacs.
> 
> We already have, actually: see find-lisp.el.

Interesting, I did not know that.  It seems, though, that the
statement in find-lisp.el

  This is a very generalized form of find.

is not quite accurate.  The power of the shell command find (at
least: the GNU version, which is the only one I know) lies in its
many bells and whistles, whereas find-lisp provides only a subset of
these features.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Fri, 01 Dec 2017 20:28:02 GMT) Full text and rfc822 format available.

Message #37 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Roland Winkler" <winkler <at> gnu.org>
Cc: michael_heerdegen <at> web.de, drew.adams <at> oracle.com, 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Fri, 01 Dec 2017 22:27:01 +0200
> Date: Fri, 1 Dec 2017 14:16:09 -0600
> From: "Roland Winkler" <winkler <at> gnu.org>
> Cc: drew.adams <at> oracle.com,
>     michael_heerdegen <at> web.de,
>     29513 <at> debbugs.gnu.org
> 
> The power of the shell command find (at least: the GNU version,
> which is the only one I know) lies in its many bells and whistles,
> whereas find-lisp provides only a subset of these features.

I'm sure patches to extend its functionality will be most welcome.




Merged 29513 36110. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 05 Jun 2019 23:53:02 GMT) Full text and rfc822 format available.

Reply sent to "Roland Winkler" <winkler <at> gnu.org>:
You have taken responsibility. (Tue, 11 Jun 2019 21:17:02 GMT) Full text and rfc822 format available.

Notification sent to "Roland Winkler" <winkler <at> gnu.org>:
bug acknowledged by developer. (Tue, 11 Jun 2019 21:17:03 GMT) Full text and rfc822 format available.

Message #44 received at 29513-done <at> debbugs.gnu.org (full text, mbox):

From: "Roland Winkler" <winkler <at> gnu.org>
To: 29513-done <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Tue, 11 Jun 2019 16:15:44 -0500
On Fri Dec 1 2017 Roland Winkler wrote:
> On Fri Dec 1 2017 Eli Zaretskii wrote:
> > Maybe we should simply provide a defcustom, which is a function called
> > by the sentinel.  Then users could customize what happens after the
> > files are all collected, be it sort the results or anything else.  The
> > advantage will be that we won't need to support every possible tweak
> > of post-processing in core.
> 
> Again: fine with me.  This could be done such that the *Find* buffer
> is narrowed to the portion containing the output of the shell
> command (as in my patch).  Also, as a further option (or default
> value of the defcustom) we could provide a function that sorts by
> file name (thus providing a real-world example of how this new
> defcustom can be used).

See commit 249902d5ad5d3ae3e25323c23a2f442913729ceb.




Reply sent to "Roland Winkler" <winkler <at> gnu.org>:
You have taken responsibility. (Tue, 11 Jun 2019 21:17:03 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Tue, 11 Jun 2019 21:17:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Tue, 11 Jun 2019 22:22:02 GMT) Full text and rfc822 format available.

Message #52 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: "Roland Winkler" <winkler <at> gnu.org>,  29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Tue, 11 Jun 2019 18:21:07 -0400
> See commit 249902d5ad5d3ae3e25323c23a2f442913729ceb.

> +(defcustom find-dired-refine-function #'find-dired-sort-by-filename
> +  "If non-nil, a function for refining the *Find* buffer of `find-dired'.

> +                (when (boundp 'find-dired-refine-function)

I think you meant just

    (when find-dired-refine-function

(boundp 'find-dired-refine-function) is always going to be true.

Although you could just drop the "If non-nil" and conditional
altogether: the feature can already be disabled by setting to #'ignore.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Wed, 12 Jun 2019 03:26:02 GMT) Full text and rfc822 format available.

Message #55 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: "Roland Winkler" <winkler <at> gnu.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Tue, 11 Jun 2019 22:25:31 -0500
On Tue Jun 11 2019 Noam Postavsky wrote:
> > +(defcustom find-dired-refine-function #'find-dired-sort-by-filename
> > +  "If non-nil, a function for refining the *Find* buffer of `find-dired'.
> 
> I think you meant just
> 
>     (when find-dired-refine-function

Sure, thanks, I should read my doc string.

> Although you could just drop the "If non-nil" and conditional
> altogether: the feature can already be disabled by setting to #'ignore.

Does it make a difference?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29513; Package emacs. (Wed, 12 Jun 2019 10:36:02 GMT) Full text and rfc822 format available.

Message #58 received at 29513 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: "Roland Winkler" <winkler <at> gnu.org>
Cc: 29513 <at> debbugs.gnu.org
Subject: Re: bug#29513: 25.2; find-dired-centinel
Date: Wed, 12 Jun 2019 06:35:15 -0400
"Roland Winkler" <winkler <at> gnu.org> writes:

>> Although you could just drop the "If non-nil" and conditional
>> altogether: the feature can already be disabled by setting to #'ignore.
>
> Does it make a difference?

It makes things just a tiny bit simpler.  Plus, if you really want to
allow nil, you also need to update the defcustom :type field.





bug Marked as fixed in versions 27.1. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 13 Jun 2019 23:43:02 GMT) Full text and rfc822 format available.

Forcibly Merged 29513 36110 36123. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 14 Jun 2019 02:48:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 15 Jul 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 287 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.