From: Pascal Bourguignon <spam@mouse-potato.com>
Subject: Re: Where to start with recursive file operations
Date: 31 Oct 2004 03:55:22 +0100 [thread overview]
Message-ID: <87y8hnppet.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: 41843022@news.nnrp.ca
Andrei Stebkov <stebakov@tht.net> writes:
> Hi!
>
> I would like to write a function that finds files recursively starting from
> the current directory, opens files based on given extension and does some
> operations on them. For instance, checks out the file (from CVS or
> Perforce), selects the whole buffer, indents the contents and save it.
> Also I'd like to have same kind of function that would search and replace in
> multiple files.
> As all the problems that I listed here stem from the same root (recursive
> search) I need a few pointers about the basic built-in emacs functions of
> this domain. The function of this nature must be already written, I just
> couldn't find them.
There's a couple of little know commands in emacs that you should learn:
M-x apropos RET <pattern> RET
and:
C-h f TAB
For example, searching for "file" with:
M-x apropos RET file RET
or for "directory" with:
M-x apropos RET directory RET
you'd get a list of interesting functions, like directory-files or
file-expand-wildcards.
(defun map-files (function directory &optional full)
(dolist (item (file-expand-wildcards (concat directory "/*") full))
(if (file-directory-p item)
(map-files function item full)
(funcall function item))))
(map-files (function print) "/tmp" t)
--
__Pascal Bourguignon__ http://www.informatimago.com/
Voting Democrat or Republican is like choosing a cabin in the Titanic.
next prev parent reply other threads:[~2004-10-31 2:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-31 0:20 Where to start with recursive file operations Andrei Stebkov
2004-10-31 2:55 ` Pascal Bourguignon [this message]
2004-11-01 17:22 ` Kevin Rodgers
2004-11-02 7:32 ` Friedrich Dominicus
2004-11-06 6:47 ` Oliver Scholz
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=87y8hnppet.fsf@thalassa.informatimago.com \
--to=spam@mouse-potato.com \
/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.