From: Allen Li <vianchielfaura@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 27456@debbugs.gnu.org
Subject: bug#27456: 25.2; Not possible to use -prune with find-dired
Date: Wed, 12 Jul 2017 23:56:23 -0700 [thread overview]
Message-ID: <CAJr1M6dmW_ZYDhYdVDy19aAx5uzxm4EueeP+SLbGJhVr-rNswQ@mail.gmail.com> (raw)
In-Reply-To: <874luhxx3r.fsf@drachen>
On Wed, Jul 12, 2017 at 12:40 PM, Michael Heerdegen
<michael_heerdegen@web.de> wrote:
> Hi Allen,
>
>> It is not possible to effectively use the -prune action with
>> find-dired.
>
> I think I can use it successfully.
>
>> With plain find, -prune would be used like:
>>
>> find . -name "foo*" -prune -o -name "*.el" -ls
>>
>> However, find-dired wraps everything:
>>
>> (find-dired "." "-name \\"foo*\\" -prune -o -name \\"*.el\\" -ls")
>
> I get an error when I try to eval this. I think the backslashes should
> not be doubled.
You're right, I copied the string from a context that required them to
be escaped twice.
>
>> results in the equivalent call:
>>
>> find . \( -name "foo*" -prune -o -name "*.el" -ls \) -ls
>>
>> Notably, this will list files matching foo*
>
> Can't you just leave out the explicit -ls in the arguments?
Nope, find-dired adds it automatically.
Try evaluating: (find-dired "~/.emacs.d" "-name \"elpa\" -prune -o
-name \"*.el\" -ls")
This translates into: find . \( -name "elpa" -prune -o -name "*.el" -ls \) -ls
This includes the elpa directory, which is not desired (this also
prints all .el files twice due to the doubled -ls, see below).
Next try running in a shell: find . -name "elpa" -prune -o -name "*.el" -ls
Notice how the former includes the elpa directory and the latter does not.
PS Upon closer reading, it sounds like you're suggesting to do
(find-dired "~/.emacs.d" "-name \"elpa\" -prune -o -name \"*.el\" ")
This translates into: find . \( -name "elpa" -prune -o -name "*.el" \) -ls
This still includes the elpa directory which is undesired.
>
> Also, AFAIK "-prune" is about descending into directories, not about
> file names.
Directories are files; in particular, they also have file names.
Sorry, I'm not sure what you're trying to say
PPS In a sudden flash of insight, I thought of using (find-dired
"~/.emacs.d" "-name \"elpa\" -prune -false -o -name \"*.el\"")
This works for my example use case.
Since I have found a workaround for my use case, I am okay with this
being closed now, but I feel like there may be more complex find
commands that I may want to do in the future where this either does
not work or introduces a lot more complexity, in which case I (or
someone else) will have to reopen this bug or create a new one. I
think it would be valuable for someone experienced with find to chime
in, but I think that perhaps find-dired shouldn't always construct a
command like "find \( <args> \) -ls"
>
>
> Michael.
next prev parent reply other threads:[~2017-07-13 6:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-23 6:00 bug#27456: 25.2; Not possible to use -prune with find-dired Allen Li
2017-07-12 19:40 ` Michael Heerdegen
2017-07-13 6:56 ` Allen Li [this message]
2017-07-19 0:21 ` Michael Heerdegen
2017-07-13 7:32 ` Andreas Schwab
2018-09-09 0:35 ` Allen Li
2018-09-09 2:39 ` Michael Heerdegen
2018-09-09 5:22 ` Phil Sainty
2018-09-09 5:32 ` Michael Heerdegen
2018-09-09 9:38 ` Phil Sainty
2018-09-09 11:49 ` Phil Sainty
2018-09-09 14:04 ` bug#32668: " Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJr1M6dmW_ZYDhYdVDy19aAx5uzxm4EueeP+SLbGJhVr-rNswQ@mail.gmail.com \
--to=vianchielfaura@gmail.com \
--cc=27456@debbugs.gnu.org \
--cc=michael_heerdegen@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.