GNU bug report logs - #46884
27.1; Cannot run find-dired with -maxdepth

Previous Next

Package: emacs;

Reported by: Allen Li <darkfeline <at> felesatra.moe>

Date: Wed, 3 Mar 2021 01:13:02 UTC

Severity: normal

Tags: moreinfo

Found in version 27.1

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.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 46884 in the body.
You can then email your comments to 46884 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#46884; Package emacs. (Wed, 03 Mar 2021 01:13:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Allen Li <darkfeline <at> felesatra.moe>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 03 Mar 2021 01:13:02 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; Cannot run find-dired with -maxdepth
Date: Tue, 02 Mar 2021 17:12:42 -0800
Due to how find-dired handles is args, it is not possible to pass
-maxdepth to the find command.  For reference, find-dired runs the find
command liks this:

    find . \( ARGS \) -ls

-maxdepth must be used like this:

    find . -maxdepth 3 \( ARGS \) -ls

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.17.3)
 of 2020-08-28 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
System Description: Arch Linux




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 01:22:02 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: 46884 <at> debbugs.gnu.org
Subject: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Wed, 3 Mar 2021 01:20:45 +0000
[Message part 1 (text/plain, inline)]
Some additional context: I'm not asking for find-dired to support -maxdepth
necessarily, but the way find-dired is structured makes it impossible to
reuse any of the code to write a command that could support -maxdepth.

I attached a patch pulling most of the find-dired logic into a
find-dired-unescaped function so that it can be readily reused.
[Message part 2 (text/html, inline)]
[0001-find-dired-Split-out-find-dired-unescaped.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 01:35:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Allen Li <darkfeline <at> felesatra.moe>, "46884 <at> debbugs.gnu.org"
 <46884 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#46884: 27.1; Cannot run find-dired with -maxdepth
Date: Wed, 3 Mar 2021 01:34:07 +0000
> Due to how find-dired handles is args, it is not
> possible to pass -maxdepth to the find command.

I'm not sure this is germane, but FWIW, my mini-library
`find-dired+.el' enhances `find-dired' by providing
optional args, and two of those specify the min and max
depth limits.

If this is relevant, and corresponds to the requested
feature, Emacs could be improved similarly.

Maybe give it a try, and see if it offers what you
request.

https://www.emacswiki.org/emacs/download/find-dired%2b.el

Here's the doc string;

,----
| find-dired is an interactive compiled Lisp function in
| 'find-dired+.el'.
| 
| (find-dired DIR ARGS &optional DEPTH-LIMITS EXCLUDED-PATHS)
| 
| Run `find' and put its output in a buffer in Dired Mode.
| Then run `find-dired-hook' and `dired-after-readin-hook'.
| The `find' command run (after changing into DIR) is essentially this,
| where LS-SWITCHES is `(car find-ls-option)':
| 
|   find . \( ARGS \) LS-SWITCHES
| 
| Optional args:
| 
| * DEPTH-LIMITS:   Minimum and maximum depths: (MIN-DEPTH MAX-DEPTH).
| * EXCLUDED-PATHS: Strings matching paths to be excluded.
|                   Uses `find' switch `-path'.
| 
| When both optional args are non-nil, the `find' command run is this:
| 
|   find . -mindepth MIN-DEPTH -maxdepth MAX-DEPTH
|          \( -path EXCLUDE1 -o -path EXCLUDE2 ... \)
|          -prune -o \( ARGS \) LS-SWITCHES
| 
| where EXCLUDE1, EXCLUDE2... are the EXCLUDED-PATHS, but shell-quoted.
`----





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 03:40:02 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: 46884 <at> debbugs.gnu.org
Subject: Re: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Wed, 3 Mar 2021 03:38:49 +0000
[Message part 1 (text/plain, inline)]
On Wed, Mar 3, 2021 at 1:20 AM Allen Li <darkfeline <at> felesatra.moe> wrote:
>
> Some additional context: I'm not asking for find-dired to support
-maxdepth necessarily, but the way find-dired is structured makes it
impossible to reuse any of the code to write a command that could support
-maxdepth.
>
> I attached a patch pulling most of the find-dired logic into a
find-dired-unescaped function so that it can be readily reused.

I made a mistake in my initial analysis. find (at least the version I have)
allows one to pass global options such as -maxdepth like so:

    find . \( -maxdepth 3 ARGS \) -ls

However, find will print a warning message as this usage is not recommended.

Also, I realized that my previous patch, while functional, is awkward since
it exists solely to allow users to specify global options
(based on the discussion on #27456, I believe all other find functionality
should be possible with find-dired).
I have made a new patch adding an optional parameter to find-dired for
passing such global options to find.

Aside: there is a discussion at #32668 about adding a similar command line
editing feature like rgrep
I'm not fond of that as it is impossible to use programmatically and
interacts poorly (read: not at all)
with `repeat-complex-command'

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27456
[Message part 2 (text/html, inline)]
[0001-find-dired-Add-global-args-to-find-dired.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 06:16:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Wed, 03 Mar 2021 08:15:12 +0200
> From: Allen Li <darkfeline <at> felesatra.moe>
> Date: Wed, 3 Mar 2021 01:20:45 +0000
> 
> I attached a patch pulling most of the find-dired logic into a find-dired-unescaped function so that it can be
> readily reused.

Thanks, but I think a better way for adding such a feature to
find-dired would be to introduce an additional defcustom, by default
nil, that will specify 'find' options to be inserted into the 'find'
command line between "." and "\( ARGS \)".  This would allow users to
specify any switch, not just -maxdepth.

Bonus points for arranging for prompting the user to supply those
options to 'find' when find-dired is invoked with a prefix argument,
so that one-off uses of such options could be easier and more
lightweight.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 06:29:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Wed, 03 Mar 2021 08:28:36 +0200
> From: Allen Li <darkfeline <at> felesatra.moe>
> Date: Wed, 3 Mar 2021 03:38:49 +0000
> 
> -(defun find-dired (dir args)
> +(defun find-dired (dir args &optional global-args)
>    "Run `find' and go into Dired mode on a buffer of the output.
>  The command run (after changing into DIR) is essentially
>  
> -    find . \\( ARGS \\) -ls
> +    find . GLOBAL-ARGS \\( ARGS \\) -ls
>  
>  except that the car of the variable `find-ls-option' specifies what to
> -use in place of \"-ls\" as the final argument.
> +use in place of \"-ls\" as the final argument.  GLOBAL-ARGS is empty
> +when called interactively.

This is okay, IMO, but it would be better to allow the user to specify
GLOBAL-ARGS interactively if the user invokes the command with a
prefix argument.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 08:23:02 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Wed, 3 Mar 2021 08:22:23 +0000
[Message part 1 (text/plain, inline)]
On Wed, Mar 3, 2021 at 6:28 AM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Allen Li <darkfeline <at> felesatra.moe>
> > Date: Wed, 3 Mar 2021 03:38:49 +0000
> >
> > -(defun find-dired (dir args)
> > +(defun find-dired (dir args &optional global-args)
> >    "Run `find' and go into Dired mode on a buffer of the output.
> >  The command run (after changing into DIR) is essentially
> >
> > -    find . \\( ARGS \\) -ls
> > +    find . GLOBAL-ARGS \\( ARGS \\) -ls
> >
> >  except that the car of the variable `find-ls-option' specifies what to
> > -use in place of \"-ls\" as the final argument.
> > +use in place of \"-ls\" as the final argument.  GLOBAL-ARGS is empty
> > +when called interactively.
>
> This is okay, IMO, but it would be better to allow the user to specify
> GLOBAL-ARGS interactively if the user invokes the command with a
> prefix argument.
>

 How would that interact with find-args-history?  I could create a separate
history variable, but then it's annoying how the two histories are
separate, as args and global-args together form one query.  I decided to
punt on that issue until someone actually has a use case for providing
global-args interactively.  I would use global-args infrequently enough
that I would rather call find-dired via M-x and iterate on getting the
command right that way, than try to call find-dired interactively
repeatedly with a universal prefix arg and navigating the history for both
the completing-reads for args and global-args separately.  Or I would add
the -maxdepth flag to the args and tolerate the warning in the output.
Actually, my current use case is calling find-dired from Emacs Lisp code
(not interactively) where I want to avoid the warning.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 08:56:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Wed, 03 Mar 2021 10:55:03 +0200
> From: Allen Li <darkfeline <at> felesatra.moe>
> Date: Wed, 3 Mar 2021 08:22:23 +0000
> Cc: 46884 <at> debbugs.gnu.org
> 
>  This is okay, IMO, but it would be better to allow the user to specify
>  GLOBAL-ARGS interactively if the user invokes the command with a
>  prefix argument.
> 
>  How would that interact with find-args-history?

Sorry, I don't understand the question.  What does prefix arg have to
do with history?  Maybe I'm missing something.

> Actually, my current use case is calling find-dired from
> Emacs Lisp code (not interactively) where I want to avoid the warning.

I understand, but my hope is we could come up with something slightly
more general than just your use case.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 09:30:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Wed, 03 Mar 2021 11:03:27 +0200
>     This is okay, IMO, but it would be better to allow the user to specify
>     GLOBAL-ARGS interactively if the user invokes the command with a
>     prefix argument.
>
>  How would that interact with find-args-history?

It could interact the same way as 'C-u rgrep' interacts with grep-find-history.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 15:44:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Allen Li <darkfeline <at> felesatra.moe>, Eli Zaretskii <eliz <at> gnu.org>
Cc: "46884 <at> debbugs.gnu.org" <46884 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#46884: [PATCH] 27.1; Cannot run find-dired with
 -maxdepth
Date: Wed, 3 Mar 2021 15:42:59 +0000
>> This is okay, IMO, but it would be better to allow
>> the user to specify GLOBAL-ARGS interactively if
>> the user invokes the command with a prefix argument.
>
> ... I would rather call find-dired via M-x and iterate
> on getting the command right that way, than try to call
> find-dired interactively repeatedly with a universal
> prefix arg...

I guess no one has bothered to try the code I provided...

I agree with Allen about not providing special
interactive support for things like max-depth.

`find-dired' has the property that what you specify
is available as default for the next time you use it.
That helps with this question of interactive support,
I think.

Remember that `find' pretty much has its own language.
Users of `find' generally need to be familiar with
that language, more or less.  Emacs can provide some
convenience, however.

The code I pointed to already does what this bug
requests, I think - does it not?  And it does so for
`find-dired', `find-name-dired', `find-grep-dired',
and a new command, `find-time-dired'.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Wed, 03 Mar 2021 16:21:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 46884 <at> debbugs.gnu.org, darkfeline <at> felesatra.moe
Subject: Re: [External] : bug#46884: [PATCH] 27.1; Cannot run find-dired with
 -maxdepth
Date: Wed, 03 Mar 2021 18:20:08 +0200
> From: Drew Adams <drew.adams <at> oracle.com>
> CC: "46884 <at> debbugs.gnu.org" <46884 <at> debbugs.gnu.org>
> Date: Wed, 3 Mar 2021 15:42:59 +0000
> 
> I agree with Allen about not providing special
> interactive support for things like max-depth.

There was never such a suggestion.  It's a misunderstanding if you
think such a proposal was on the table.

> `find-dired' has the property that what you specify
> is available as default for the next time you use it.
> That helps with this question of interactive support,
> I think.

Assuming the user invokes the command several times in the same
session.  But that isn't a given, not at all.  For one-off
invocations, having to set a variable is a nuisance.  Compare with
"C-x d", for example.

> Remember that `find' pretty much has its own language.
> Users of `find' generally need to be familiar with
> that language, more or less.

I _am_ familiar with that language.  So for me and others like me,
being able to specify command-line options in one-off invocations is a
boon.

Of course, if I'm the only one interested in such a feature, so be it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Thu, 04 Mar 2021 04:51:02 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Wed, 03 Mar 2021 20:50:23 -0800
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Allen Li <darkfeline <at> felesatra.moe>
>> 
>>  This is okay, IMO, but it would be better to allow the user to specify
>>  GLOBAL-ARGS interactively if the user invokes the command with a
>>  prefix argument.
>> 
>>  How would that interact with find-args-history?
>
> Sorry, I don't understand the question.  What does prefix arg have to
> do with history?  Maybe I'm missing something.

Currently, `find-dired' stores the `completing-read' history for `args' in
`find-args-history'.  It also stores the value for `args' in `find-args'
to use as the default for the next `find-dired' interactive call.

If we were to make `global-args' accessible interactively, how would the
history for it be stored?  The obvious solution would be to add a
completing-read for `global-args' and create `find-global-args-history'
and `find-global-args' variables to be treated similarly to
`find-args-history' and `find-args' are now.

There are two issues with this.

First, consider what the user would do if they want to repeat a
`find-dired' with `global-args' three calls in the past:

C-u M-x find-dired RET
some/directory RET
M-p M-p M-p RET ; going back three items in the history for args
M-p M-p M-p RET ; going back three items in the history for global-args

This is a poor user experience.

Second, if the user mistakenly omits the C-u, then they might run a
previous command without the global-args that were supplied.

Consider if the user runs find-dired like so:

C-u M-x find-dired RET
some/dir RET
-some -query RET
-maxdepth 3 RET

Then the user wants to repeat the query for another directory:

M-x find-dired RET
other/dir RET
M-p RET ; get previous input, M-p can be omitted since there's a default

Because the user didn't supply the C-u, the "-maxdepth 3" is omitted.
Even though it was the user's intent to repeat the last query, the user
is now running a fundamentally different query.  Again, this is a poor
user experience.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Thu, 04 Mar 2021 10:17:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Thu, 04 Mar 2021 11:35:18 +0200
> Second, if the user mistakenly omits the C-u, then they might run a
> previous command without the global-args that were supplied.
>
> Consider if the user runs find-dired like so:
>
> C-u M-x find-dired RET
> some/dir RET
> -some -query RET
> -maxdepth 3 RET
>
> Then the user wants to repeat the query for another directory:
>
> M-x find-dired RET
> other/dir RET
> M-p RET ; get previous input, M-p can be omitted since there's a default
>
> Because the user didn't supply the C-u, the "-maxdepth 3" is omitted.
> Even though it was the user's intent to repeat the last query, the user
> is now running a fundamentally different query.  Again, this is a poor
> user experience.

Shouldn't it be compatible with 'rgrep', so 'C-u M-x find-dired' will read
the whole constructed command line where the user can add more args,
and 'C-u C-u M-x find-dired' will rerun the same command in another directory.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Thu, 04 Mar 2021 13:55:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Thu, 04 Mar 2021 15:53:50 +0200
> From: Allen Li <darkfeline <at> felesatra.moe>
> Cc: 46884 <at> debbugs.gnu.org
> Date: Wed, 03 Mar 2021 20:50:23 -0800
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> >> From: Allen Li <darkfeline <at> felesatra.moe>
> >> 
> >>  This is okay, IMO, but it would be better to allow the user to specify
> >>  GLOBAL-ARGS interactively if the user invokes the command with a
> >>  prefix argument.
> >> 
> >>  How would that interact with find-args-history?
> >
> > Sorry, I don't understand the question.  What does prefix arg have to
> > do with history?  Maybe I'm missing something.
> 
> Currently, `find-dired' stores the `completing-read' history for `args' in
> `find-args-history'.  It also stores the value for `args' in `find-args'
> to use as the default for the next `find-dired' interactive call.
> 
> If we were to make `global-args' accessible interactively, how would the
> history for it be stored?

Just take what the user types for global-args and add it to the
history, I'd say.  I think this would solve all the problems you
mention.  Or what am I missing?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Fri, 05 Mar 2021 03:22:01 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Thu, 04 Mar 2021 19:21:39 -0800
Juri Linkov <juri <at> linkov.net> writes:
> Shouldn't it be compatible with 'rgrep', so 'C-u M-x find-dired' will read
> the whole constructed command line where the user can add more args,
> and 'C-u C-u M-x find-dired' will rerun the same command in another directory.

The way rgrep works right now is very different from how find-dired
works right now:

(rgrep REGEXP &optional FILES DIR CONFIRM)

"When called programmatically and FILES is nil, REGEXP is expected
to specify a command to run."

For comparison:

(find-dired DIR ARGS)

I guess we could make ARGS optional and overload DIR to take a command?
What do you think, Eli?

The new signature would look like:

(find-dired DIR &optional ARGS CONFIRM)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Fri, 05 Mar 2021 07:28:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: 46884 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Fri, 05 Mar 2021 09:27:14 +0200
> From: Allen Li <darkfeline <at> felesatra.moe>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  46884 <at> debbugs.gnu.org
> Date: Thu, 04 Mar 2021 19:21:39 -0800
> 
> For comparison:
> 
> (find-dired DIR ARGS)
> 
> I guess we could make ARGS optional and overload DIR to take a command?
> What do you think, Eli?
> 
> The new signature would look like:
> 
> (find-dired DIR &optional ARGS CONFIRM)

Sounds fine, I think, but could you post a more detailed proposal, or
show a patch to that effect?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Fri, 12 Mar 2021 08:10:02 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 46884 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Fri, 12 Mar 2021 08:08:55 +0000
[Message part 1 (text/plain, inline)]
Attached patch, does this approach look good?

On Fri, Mar 5, 2021 at 7:27 AM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Allen Li <darkfeline <at> felesatra.moe>
> > Cc: Eli Zaretskii <eliz <at> gnu.org>,  46884 <at> debbugs.gnu.org
> > Date: Thu, 04 Mar 2021 19:21:39 -0800
> >
> > For comparison:
> >
> > (find-dired DIR ARGS)
> >
> > I guess we could make ARGS optional and overload DIR to take a command?
> > What do you think, Eli?
> >
> > The new signature would look like:
> >
> > (find-dired DIR &optional ARGS CONFIRM)
>
> Sounds fine, I think, but could you post a more detailed proposal, or
> show a patch to that effect?
>
> Thanks.
>
[Message part 2 (text/html, inline)]
[0001-find-dired-Add-global-args-to-find-dired.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Fri, 12 Mar 2021 15:50:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Allen Li <darkfeline <at> felesatra.moe>, Eli Zaretskii <eliz <at> gnu.org>
Cc: "46884 <at> debbugs.gnu.org" <46884 <at> debbugs.gnu.org>,
 Juri Linkov <juri <at> linkov.net>
Subject: RE: [External] : bug#46884: [PATCH] 27.1; Cannot run find-dired with
 -maxdepth
Date: Fri, 12 Mar 2021 15:49:04 +0000
> Attached patch, does this approach look good?

What did you find wrong or missing with the
code I cited?  It accepts DEPTH-LIMITS and
EXCLUDED-PATHS as optional args. 

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Sat, 13 Mar 2021 00:43:01 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, Eli Zaretskii <eliz <at> gnu.org>,
 "46884 <at> debbugs.gnu.org" <46884 <at> debbugs.gnu.org>, Juri Linkov <juri <at> linkov.net>
Subject: Re: [External] : bug#46884: [PATCH] 27.1; Cannot run find-dired
 with -maxdepth
Date: Fri, 12 Mar 2021 16:42:18 -0800
Drew Adams <drew.adams <at> oracle.com> writes:

>> Attached patch, does this approach look good?
>
> What did you find wrong or missing with the
> code I cited?  It accepts DEPTH-LIMITS and
> EXCLUDED-PATHS as optional args.

Personally, I find it weirdly specialized and incomplete.  There are
many global options beside -mindepth and -maxdepth; your version
supports none of those options.  There is also no need to support
EXCLUDED-PATHS separately; that can already be accomplished with the
current find-dired API.  I prefer a more flexible, general API, which is
the current rgrep approach proposed by Juri and Phil on another bug [1].

There's also another bug open which can be closed if we adopt the rgrep
approach [2].

[1]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27456

[2]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32668




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Sat, 13 Mar 2021 01:10:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, Eli Zaretskii <eliz <at> gnu.org>,
 "46884 <at> debbugs.gnu.org" <46884 <at> debbugs.gnu.org>, Juri Linkov <juri <at> linkov.net>
Subject: RE: [External] : bug#46884: [PATCH] 27.1; Cannot run find-dired with
 -maxdepth
Date: Sat, 13 Mar 2021 01:09:35 +0000
> > What did you find wrong or missing with the
> > code I cited?  It accepts DEPTH-LIMITS and
> > EXCLUDED-PATHS as optional args.
> 
> Personally, I find it weirdly specialized and incomplete.

I see.  It has the merit, at least, of having
actually been requested by users (of find-dired+).





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Sat, 13 Mar 2021 09:47:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: 46884 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Sat, 13 Mar 2021 11:46:38 +0200
> From: Allen Li <darkfeline <at> felesatra.moe>
> Date: Fri, 12 Mar 2021 08:08:55 +0000
> Cc: Juri Linkov <juri <at> linkov.net>, 46884 <at> debbugs.gnu.org
> 
> Attached patch, does this approach look good?

I guess my suggestion to additionally allow specification of
GLOBAL-ARGS interactively (via prefix arg) got voted down?

> +---
> +*** Optional 'global-args' parameter added to 'find-dired'.
> +This allows passing find global options like -maxdepth.

"find" should be in quotes: 'find'

> @@ -202,6 +203,7 @@ find-dired
>      (setq default-directory dir
>  	  find-args args	      ; save for next interactive call
>  	  args (concat find-program " . "
> +                       (if global-args global-args "")

'concat' knows how to handle nil arguments, so you don't need the
empty string alternative here.  Just (if global-args global-args)
should do.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Sat, 13 Mar 2021 09:59:02 GMT) Full text and rfc822 format available.

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

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: juri <at> linkov.net, 46884 <at> debbugs.gnu.org, Allen Li <darkfeline <at> felesatra.moe>
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Sat, 13 Mar 2021 10:58:45 +0100
On Mär 13 2021, Eli Zaretskii wrote:

>> +---
>> +*** Optional 'global-args' parameter added to 'find-dired'.
>> +This allows passing find global options like -maxdepth.
>
> "find" should be in quotes: 'find'
>
>> @@ -202,6 +203,7 @@ find-dired
>>      (setq default-directory dir
>>  	  find-args args	      ; save for next interactive call
>>  	  args (concat find-program " . "
>> +                       (if global-args global-args "")
>
> 'concat' knows how to handle nil arguments, so you don't need the
> empty string alternative here.  Just (if global-args global-args)
> should do.

aka (or global-args) aka global-args

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Sat, 13 Mar 2021 21:39:03 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 46884 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Sat, 13 Mar 2021 21:38:11 +0000
[Message part 1 (text/plain, inline)]
Sorry, I attached the wrong patch, here's the one for the rgrep approach.

On Sat, Mar 13, 2021 at 9:46 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: Allen Li <darkfeline <at> felesatra.moe>
> > Date: Fri, 12 Mar 2021 08:08:55 +0000
> > Cc: Juri Linkov <juri <at> linkov.net>, 46884 <at> debbugs.gnu.org
> >
> > Attached patch, does this approach look good?
>
> I guess my suggestion to additionally allow specification of
> GLOBAL-ARGS interactively (via prefix arg) got voted down?
>
> > +---
> > +*** Optional 'global-args' parameter added to 'find-dired'.
> > +This allows passing find global options like -maxdepth.
>
> "find" should be in quotes: 'find'
>
> > @@ -202,6 +203,7 @@ find-dired
> >      (setq default-directory dir
> >         find-args args              ; save for next interactive call
> >         args (concat find-program " . "
> > +                       (if global-args global-args "")
>
> 'concat' knows how to handle nil arguments, so you don't need the
> empty string alternative here.  Just (if global-args global-args)
> should do.
[0001-find-dired-Add-command-editing-like-rgrep.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Sat, 13 Mar 2021 21:55:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Sat, 13 Mar 2021 23:53:13 +0200
> Sorry, I attached the wrong patch, here's the one for the rgrep approach.

Thanks, I tried it, but for some reason 'C-u C-u find-dired RET'
doesn't work.  Maybe because it uses 'grep-find-command' that is nil?

> +With two \\[universal-argument] prefixes, directly edit and run `grep-find-command'.
> ...
> +    ((and grep-find-command (equal current-prefix-arg '(16)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Sun, 14 Mar 2021 00:41:01 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Sun, 14 Mar 2021 00:40:36 +0000
[Message part 1 (text/plain, inline)]
On Sat, Mar 13, 2021 at 9:53 PM Juri Linkov <juri <at> linkov.net> wrote:
>
> > Sorry, I attached the wrong patch, here's the one for the rgrep approach.
>
> Thanks, I tried it, but for some reason 'C-u C-u find-dired RET'
> doesn't work.  Maybe because it uses 'grep-find-command' that is nil?

First patch was to outline intent to Eli; I didn't test it which was
an oversight on my part.

Here's a second patch which I've tested by running once each for zero,
one, and two prefix args.
If the approach looks good, I will test more, cleanup, update the
NEWS, docs, etc.

>
> > +With two \\[universal-argument] prefixes, directly edit and run `grep-find-command'.
> > ...
> > +    ((and grep-find-command (equal current-prefix-arg '(16)))
[0001-find-dired-Add-command-editing-like-rgrep.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Thu, 18 Mar 2021 19:02:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 46884 <at> debbugs.gnu.org
Subject: Re: bug#46884: [PATCH] 27.1; Cannot run find-dired with -maxdepth
Date: Thu, 18 Mar 2021 20:52:59 +0200
> First patch was to outline intent to Eli; I didn't test it which was
> an oversight on my part.
>
> Here's a second patch which I've tested by running once each for zero,
> one, and two prefix args.
> If the approach looks good, I will test more, cleanup, update the
> NEWS, docs, etc.

Thanks, I've tested the second patch, and see no problems with it.
Only noticed that the docstring of `find-dired' mentions `grep-find-command'
instead of `find-dired'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Sun, 19 Jun 2022 23:56:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 46884 <at> debbugs.gnu.org,
 Allen Li <darkfeline <at> felesatra.moe>
Subject: Re: bug#46884: 27.1; Cannot run find-dired with -maxdepth
Date: Mon, 20 Jun 2022 01:55:27 +0200
Juri Linkov <juri <at> linkov.net> writes:

>> Here's a second patch which I've tested by running once each for zero,
>> one, and two prefix args.
>> If the approach looks good, I will test more, cleanup, update the
>> NEWS, docs, etc.
>
> Thanks, I've tested the second patch, and see no problems with it.
> Only noticed that the docstring of `find-dired' mentions `grep-find-command'
> instead of `find-dired'.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Allen, do you have an updated version of the patch?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 19 Jun 2022 23:56:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Sun, 26 Jun 2022 03:56:02 GMT) Full text and rfc822 format available.

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

From: Allen Li <darkfeline <at> felesatra.moe>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 46884 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#46884: 27.1; Cannot run find-dired with -maxdepth
Date: Sat, 25 Jun 2022 20:54:40 -0700
[Message part 1 (text/plain, inline)]
I don't, but I rewrote it from scratch with a different approach.

In short, introduce a command that allows running an arbitrary find
command, and rewrite the existing find-dired on top of said command.

This hopefully sidesteps any bikeshedding.  If anyone wants any particular
command API, they can write their own command on top.  For one-off usage,
the user can build their command manually.

On Sun, Jun 19, 2022 at 4:55 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Juri Linkov <juri <at> linkov.net> writes:
>
> >> Here's a second patch which I've tested by running once each for zero,
> >> one, and two prefix args.
> >> If the approach looks good, I will test more, cleanup, update the
> >> NEWS, docs, etc.
> >
> > Thanks, I've tested the second patch, and see no problems with it.
> > Only noticed that the docstring of `find-dired' mentions
> `grep-find-command'
> > instead of `find-dired'.
>
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
>
> Allen, do you have an updated version of the patch?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>
[Message part 2 (text/html, inline)]
[0001-find-dired-Factor-out-find-dired-escaped-ls-option.patch (text/x-patch, attachment)]
[0002-find-dired-Add-find-dired-with-command.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46884; Package emacs. (Mon, 27 Jun 2022 07:48:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Allen Li <darkfeline <at> felesatra.moe>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 46884 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#46884: 27.1; Cannot run find-dired with -maxdepth
Date: Mon, 27 Jun 2022 09:46:49 +0200
Allen Li <darkfeline <at> felesatra.moe> writes:

> I don't, but I rewrote it from scratch with a different approach.
>
> In short, introduce a command that allows running an arbitrary find command, and
> rewrite the existing find-dired on top of said command.
>
> This hopefully sidesteps any bikeshedding.  If anyone wants any particular command
> API, they can write their own command on top.  For one-off usage, the user can build
> their command manually.

Thanks; pushed to Emacs 29 (with some whitespace changes).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 46884 <at> debbugs.gnu.org and Allen Li <darkfeline <at> felesatra.moe> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 27 Jun 2022 07: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, 25 Jul 2022 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 247 days ago.

Previous Next


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