Wednesday, April 12, 2006

emacs still puzzles me much, especially for multiple buffer works

had some 200 html files to edit, for a simple cut&paste image url redirect.
some simple html editor like homesite had no problem handling it, when I had to use it at one of the previous work.

i know how to open up multiple buffers/windows in emacs, and i know how to do replace-string in a given buffer. the problem is i wanted to do it on all 200 files/buffers without having to go through all 200+ html files.

after a few meager attempts and fanatically looking up online references, I ended up relying on some 10-15lines of perl to slurp up file names from directory and do regex replace.

I've grown so used to using emacs, and yet sometimes it annoys me I can't seem to do a simple task like that.

too profound for me, yet, i guess.


At 6:52 AM, Blogger self said...

It all depends on how much elisp you know, really. I wrote this for you.

One of the great things about emacs is it's been around for a really long time (over twenty years), and lots of people have contributed pieces of code to it. You can generally find a function to do what you want, or enough bits of code to craft something to solve your problem. I'd be surprised if someone out there hasn't written something similar to my code (pretty much everyone wants to do this eventually). It might even be in some file that ships with emacs but isn't loaded by default — I didn't check.

Now that you have my code, if you stick it in your .emacs, you'll be able to do one more thing in emacs!

At 7:18 AM, Anonymous Trent Buck said...

In dired mode, use Q (M-x dired-do-query-replace-regexp) to perform replace-regexp on marked files.

At 1:40 PM, Blogger speattle said...

Thanks Guys.
Will definitely try them for next batch-mode edits.


Post a Comment

<< Home