From: Ke Lu <lu@luxdo.jp>
To: help-gnu-emacs@gnu.org
Subject: Re: Interative batch query-replace question
Date: Sun, 02 Dec 2007 11:26:08 +0900 [thread overview]
Message-ID: <m37ijx7ry7.fsf@www.luxdo.jp> (raw)
In-Reply-To: mailman.4401.1196530793.18990.help-gnu-emacs@gnu.org
Thank you very much.
It is true,we needs two task.
> 1 - find the list of files
I do it by find-dired and mark it because
find-dired using os command "find" to find file and is powerful.
> 2 - operate on them
I do it by my-proc-one-query-replace-regexp.
(defun my-proc-one-query-replace-regexp (files from to)
(dolist (cur-file files)
(find-file cur-file)
(goto-char 0)
(query-replace-regexp from to))
)
(defun my-batch-query-replace-regexp()
"Muti-pattern query-replace-regrex on a dozen of files.
It must be called in dired buffer.
Mark some files then you can call this function."
(interactive)
(let ((files (dired-get-marked-files nil nil (lambda (file) (not (file-directory-p file)))))
(patterns '(("ejb" . "ejb2")
("java" . "java2")
("sun2" . "sun3")
;; Add any other patterns
)))
(when files
(while patterns
(let ((pattern (car patterns)))
(my-proc-one-query-replace-regexp files (car pattern) (cdr pattern))
(setq patterns (cdr patterns))))
)))
Andreas Röhler <andreas.roehler@online.de> writes:
> Am Samstag, 1. Dezember 2007 10:11 schrieb Ke Lu:
>> Perhaps my explain is not quite enough.
>>
>> I want to query-replace some files.(not filename)
> ...
>
>
> So we have basically two tasks
>
> 1 - find the list of files
> 2 - operate on them
>
> Dired probably isn't TRT here, because it's for
> manually operation.
>
> Maybe run this at your dir to have some impression how
> it may start:
>
> (defun my-list-of-files ()
> " "
> (interactive)
> (let ((my-endings-list '(".co$" ".java$")))
> (dolist (el my-endings-list)
> (let ((files (directory-files default-directory t el)))
> (while files
> (let ((file (car files)))
> (when (file-exists-p file)
> (when (y-or-n-p (concat "You agree to change \""file"\" later")))
> (message "Later we will change name and contents of %s " file))
> (setq files (cdr files))))))))
>
>
> Andreas Röhler
next prev parent reply other threads:[~2007-12-02 2:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 3:08 Interative batch query-replace question Ke Lu
2007-11-29 5:56 ` Ke Lu
2007-11-29 7:37 ` Andreas Röhler
[not found] ` <mailman.4291.1196321879.18990.help-gnu-emacs@gnu.org>
2007-11-29 9:15 ` Ke Lu
2007-11-29 10:18 ` Ke Lu
2007-11-29 20:55 ` Andreas Röhler
[not found] ` <mailman.4324.1196369791.18990.help-gnu-emacs@gnu.org>
2007-11-29 21:16 ` Joel J. Adamson
2007-11-30 1:58 ` Ke Lu
2007-11-30 8:08 ` Andreas Röhler
[not found] ` <mailman.4336.1196410171.18990.help-gnu-emacs@gnu.org>
2007-11-30 9:25 ` Ke Lu
2007-11-30 14:25 ` Joel J. Adamson
2007-11-30 19:33 ` Andreas Röhler
[not found] ` <mailman.4365.1196451256.18990.help-gnu-emacs@gnu.org>
2007-12-01 1:00 ` Ke Lu
2007-12-01 8:19 ` Andreas Röhler
[not found] ` <mailman.4382.1196497198.18990.help-gnu-emacs@gnu.org>
2007-12-01 9:11 ` Ke Lu
2007-12-01 15:19 ` Xah Lee
2007-12-02 2:16 ` Ke Lu
2007-12-03 15:27 ` Joel J. Adamson
2007-12-01 17:39 ` Andreas Röhler
[not found] ` <mailman.4401.1196530793.18990.help-gnu-emacs@gnu.org>
2007-12-02 2:26 ` Ke Lu [this message]
2007-12-03 15:32 ` jedit.el (was: Interative batch query-replace question) Joel J. Adamson
2007-11-29 6:54 ` Interative batch query-replace question Andreas Röhler
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m37ijx7ry7.fsf@www.luxdo.jp \
--to=lu@luxdo.jp \
--cc=help-gnu-emacs@gnu.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).