From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Allen Li Newsgroups: gmane.emacs.bugs Subject: bug#27456: 25.2; Not possible to use -prune with find-dired Date: Wed, 12 Jul 2017 23:56:23 -0700 Message-ID: References: <87k243qm3z.fsf@felesatra.moe> <874luhxx3r.fsf@drachen> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1499929046 17653 195.159.176.226 (13 Jul 2017 06:57:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 13 Jul 2017 06:57:26 +0000 (UTC) Cc: 27456@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 13 08:57:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dVY3e-0003aR-Ug for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Jul 2017 08:57:07 +0200 Original-Received: from localhost ([::1]:57521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVY3k-00074V-EX for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Jul 2017 02:57:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVY3e-00073s-Ha for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 02:57:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVY3a-00058u-J1 for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 02:57:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33473) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVY3a-00058e-GF for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 02:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dVY3a-00061D-0a for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 02:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Allen Li Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Jul 2017 06:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27456 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27456-submit@debbugs.gnu.org id=B27456.149992899123096 (code B ref 27456); Thu, 13 Jul 2017 06:57:01 +0000 Original-Received: (at 27456) by debbugs.gnu.org; 13 Jul 2017 06:56:31 +0000 Original-Received: from localhost ([127.0.0.1]:36150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dVY35-00060S-9F for submit@debbugs.gnu.org; Thu, 13 Jul 2017 02:56:31 -0400 Original-Received: from mail-qk0-f179.google.com ([209.85.220.179]:33565) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dVY33-00060F-ON for 27456@debbugs.gnu.org; Thu, 13 Jul 2017 02:56:29 -0400 Original-Received: by mail-qk0-f179.google.com with SMTP id a66so29353210qkb.0 for <27456@debbugs.gnu.org>; Wed, 12 Jul 2017 23:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=A/vUR1J+K6inrHkXn0ZWIZfD4jhKJb8LPebFem+JEAE=; b=fceJm5ScPITaWUCC+RxzYjYWlaLYvt2Zf6/VBh5QnD8O6FMwJl0z37VL43cNCCTqbt Pcr4PuvQLTydxq2EKeYFZh182t0cdsEXlSnmlzvj+6skED2TRJuSTgBOD8ZeKa9cROay HddjdNOQoj5Kzcib+4El+f3yWrs7MZLA+Ekjj5EYAc4wKjB8IkXsp8U1ec7Zquf2VwiT R6gjqXkxPObLSNvLjsicb6zqkTR4l7yQmzSHMeJkJPx6xt5vMgwM5xIOfZidMynr7+hA xnW7GIJ7NSW8cmJZGHNgV0ZGzz3ikg1V5lGY4UjcDnmkLtb4+fn5Jng/1+c5zyhi4qLR MqHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=A/vUR1J+K6inrHkXn0ZWIZfD4jhKJb8LPebFem+JEAE=; b=AHYqEMoIJcU+Ndge2OyHbI2GanxZe4hgioYW5AMgXON6Uk3VKqR2k5c6uL/HNPB8e7 XWUiaswPGr34uvn44aakGPN11HWpI1NIoii7Ugnw8pqW6Ak2vxr/CjENTsJL/+wZc0mI 497kXEwsx7jklqpehEJvsLg86dtgvBjX1z/u9maNTtkpByZS0xHbeKM1Vj1Ndr67o2it QZoZJrxl1hEx2JI2kKEZF3F0AlSvYQHMOMGylXIRpFJkeUljDkQFl6XDFIR98l7Ilc1l 7GT646Uq3wdIrdpF4BlNVp4/g+PLewTIMFEfH6+lMDd9n7ERnpt/SEBA4rbkRF+La57H yzbQ== X-Gm-Message-State: AIVw112RKIhXarQNncTrOTIE60gSlkwOEkv5uKdu7TTdbaK04ebKD3qd ksqThTrKAMJuZ9KCws+nhjly0vfMow== X-Received: by 10.55.86.5 with SMTP id k5mr2732669qkb.70.1499928984145; Wed, 12 Jul 2017 23:56:24 -0700 (PDT) Original-Received: by 10.12.142.67 with HTTP; Wed, 12 Jul 2017 23:56:23 -0700 (PDT) In-Reply-To: <874luhxx3r.fsf@drachen> 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: 208.118.235.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:134498 Archived-At: On Wed, Jul 12, 2017 at 12:40 PM, Michael Heerdegen 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 \( \) -ls" > > > Michael.