query-replace-all-string - Query replace string in a list of files
n query-replace-all-string "from" "to" "files" ["grep-from"]
query-replace-all-string, similar to query-replace-string(2), replaces all occurrences of "from" to "to" in the given list of files prompting the user before replacing each occurrence.
The command finds all occurrences of "from" by calling the command grep(3) to search for string "from" in files "files". Thus all relevant edited files must be saved or grep may return the wrong line numbers. This is achieved by a call to save-some-buffers(2) which prompts the user to save any changed buffers one at a time.
Each occurrence of "from" is jumped to using get-next-line(2) and the string is replaced by the call:
-1 query-replace-string "from" "to"
This query-replaces all occurrences of "from" to "to" on the current line only, hence the line numbers must be correct. This also means that the "from" search string must be correctly formatted for both grep and query-replace-string, unless bit 0x02 is set (see below).
The given argument n is a bit based flag which changes the default behavior described above. The bits have the following effect:-
0x01
0x02
query-replace-all-string is a macro defined in search.emf.
The grep command must be working before this command can function properly.
It is not recommended to use a "from" or "to" string which uses more that one line as the results may be unpredictable.
As the change is likely to be over several files a single call to undo(2) at the end of execution will not undo all the changes made. To undo all the changes made, use get-next-line(2) to loop through all the occurrences and call undo for each occurrence
query-replace-string(2),
save-some-buffers(2),
grep(3),
get-next-line(2),
undo(2),
replace-all-string(3),
search-forward(2).
Regular Expressions
(c) Copyright JASSPA 1999
Last Modified: 1999/06/24
Generated On: 1999/12/01