From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: File System Traversal Map/Collect Date: Sun, 1 Jun 2008 11:57:01 -0700 Message-ID: <003101c8c419$46fe8150$0200a8c0@us.oracle.com> References: <3f98cb6c-74c5-48de-b3cc-e944caf72b45@25g2000hsx.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1212346711 22422 80.91.229.12 (1 Jun 2008 18:58:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 1 Jun 2008 18:58:31 +0000 (UTC) To: "'harven'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 01 20:59:12 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K2slr-0005N0-Ks for geh-help-gnu-emacs@m.gmane.org; Sun, 01 Jun 2008 20:59:11 +0200 Original-Received: from localhost ([127.0.0.1]:33175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K2sl5-0000JF-Mm for geh-help-gnu-emacs@m.gmane.org; Sun, 01 Jun 2008 14:58:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K2skm-0000Im-Md for help-gnu-emacs@gnu.org; Sun, 01 Jun 2008 14:58:04 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K2skl-0000II-N0 for help-gnu-emacs@gnu.org; Sun, 01 Jun 2008 14:58:04 -0400 Original-Received: from [199.232.76.173] (port=56045 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K2skl-0000IA-Cs for help-gnu-emacs@gnu.org; Sun, 01 Jun 2008 14:58:03 -0400 Original-Received: from agminet01.oracle.com ([141.146.126.228]:41959) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K2skl-0002w1-0v for help-gnu-emacs@gnu.org; Sun, 01 Jun 2008 14:58:03 -0400 Original-Received: from agmgw2.us.oracle.com (agmgw2.us.oracle.com [152.68.180.213]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id m51IvwpR007573; Sun, 1 Jun 2008 13:57:58 -0500 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by agmgw2.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id m51Hh9oY003851; Sun, 1 Jun 2008 12:57:58 -0600 Original-Received: from inet-141-146-46-1.oracle.com by acsmt351.oracle.com with ESMTP id 3685432771212346608; Sun, 01 Jun 2008 11:56:48 -0700 Original-Received: from dradamslap1 (/24.5.171.3) by bhmail.oracle.com (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 01 Jun 2008 11:56:47 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: AcjEDwSNe5uhIZwSSFGgsOKddECHfwAAlLeQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:54413 Archived-At: > On 1 juin, 01:03, Nordl=F6w wrote: > > I am trying to construct a general file system traversal function > > which operates (map/collect) on each file using a function as > > argument. Such a function could be query-replace-regexp()=20 > > specializing it to the functions found in findr.el. >=20 > M-x find-name-dired > then the M and Q command in the resulting Dired buffer allows to make > a query replacement on a bunch of files. The command find-name-dired > makes use of the unix find command though, so it is perhaps not so > useful with respect to what you want to achieve. >=20 > There is also an extension called icicles which > seems to be able to do what you want -- apply > a function to a bunch of files, without relying on > some unix find command. Have a look at the wiki. Hi Per, Dunno whether you wanted to do this by program or interactively. The code defining command `icicle-locate-file' shows you how to get all accessible files under some directory (which could be `/', for all = files). You can then of course map any function over the list. If you want, you can use `icicle-locate-file' interactively and save the = files as a list (either to a variable or to a file). If you want to interactively map a function over only some of the files, = which you choose on the fly by matching an input pattern (or by selecting individually), then you can use command `icicle-map' to do that. You can do it all interactively, if you want. `icicle-map' expects an = alist, however, whereas when you save the `icicle-locate-file' completion = candidates you get a plain list of file names. So you would do this: 1. `M-x icicle-locate-file' and `C-M-}' to save the completion candidates in a variable, say `foo'. 2. M-: (setq foo (mapcar 'list foo)), to convert to an alist. 3. `C-u M-x icicle-map', entering `foo' as the variable. You can specify a pattern for file names to match in either step 1 or = step 3, or both. As you change your input, the set of matching files is updated incrementally. In step 3, you can use Icicles action keys (e.g. `C-mouse-2', `C-RET', = to act on specific file names, or `C-!' to act on all matching file names). If you wanted to act often on the same general set of files (e.g. files = of a certain type in a certain set of directories), then you would use steps = 1 & 2 to define that set only once, and then retrieve the set using step 3 any = time you want.=20 You can save the set persistently, if you like: just use `C-}' instead = of `C-M-}'. The file names used by `icicle-locate-file' are absolute, so = there is no problem retrieving the set later, whatever the context. When you act on that set (step 3), you can use an on-the-fly pattern = (e.g. regexp) to specify a subset of the files you are interested in. You can = then use `C-!' to act on all of the files in that subset. Some doc about this - `icicle-locate-file': http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_File-Name_Input Saving completion candidates: http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Candidate_Sets Persistent sets of completion candidates: http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Persistent_Completions `icicle-map': http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Complex_Completions