Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!samsung!uunet!zephyr.ens.tek.com!uw-beaver!fluke!intermec!dave From: dave@intermec.UUCP (David Karr x7324) Newsgroups: comp.emacs Subject: Re: Multi-file replace (unconditional) Message-ID: <1444@intermec.UUCP> Date: 18 Jan 91 16:47:30 GMT References: <3617@archive.BBN.COM> <1991Jan8.072529.18560@oracle.com> Reply-To: dave@cheetos (David Karr x7324) Organization: Intermec Corporation, Everett WA Lines: 40 In article <1991Jan8.072529.18560@oracle.com> wmesard@oracle.com (Wayne Mesard) writes: >nat%DRAO.NRC.CA@VM.TCS.TULANE.EDU (Natalie Prowse) writes: >>Hi, I am looking for a function to do an unconditional replace on >>every file/buffer that I have loaded in my current emacs session. >;; WMesard@Oracle.COM 1/7/90 >(defun replace-string-all-buffers (from-string to-string &optional delimited) >[code deleted] >............. >you: Are you sure this is what you want? Have you tried >tags-query-replace? Do you know that typing a bang ("!") during query >replace will silently replace all the remaining matches in that buffer? >That's always been powerful enough for me (and I like to change variable >and typedef names a lot). >-- >Wayne(); >WMesard@Oracle.COM My strategy is somewhat different for things like this. I tend to use the "grep" function along with macros to achieve the same "global-replace" feature. If you do a grep for the symbol you are trying to replace, you can then step through the grep buffer, going to every place where that symbol occurs. You can conceivably edit the grep buffer to delete duplicate entries from the same file. Then you can generate a macro on the fly which will: 1. Go to the next occurrence in the grep buffer. 2. Do a replace-string, then a "!" to do all the occurrences in the file. Then you give a huge number as a prefix argument to that macro, and you're done. It's faster than manually going through each buffer you have, and you don't have to write a new function to do it. If you REALLY wanted to write some code to support this, it would be straightforward to write a function which would remove duplicate file name entries from the grep buffer. -- ---------------------------------------- David Karr dave@intermec.COM or uunet!pilchuck!intermec!dave Intermec Corp., PO Box 4280, Everett, WA 98203 (206)348-2600 x7324 "The above statements do not necessarily reflect the opinions of my employer."