replace-all-pairs - Replace string pairs in a list of files
n replace-all-pairs "files"
replace-all-pairs uses the current buffer to extract "from" and "to" pairs and then replaces all occurrences of "from" to "to" in the given list of files without prompting the user. The format of the current buffer must be:
/from1/to1/ Xfrom2Xto2X ?from3?to3? . . /fromN/toN/
For each pair 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) between each replace pair, it is called with an argument of 0 to ensure that any changed buffers are automatically saved.
Each occurrence of "from" is jumped to using get-next-line(2) and the string is replaced by the call:
-1 replace-string "from" "to"
This 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 replace-string.
The given argument n is a bit based flag which changes the default behavior described above. The bits have the following effect:-
0x01
replace-all-pairs 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 several pair strings with each changed buffer being saved between pairs undo(2) cannot be used to undo the changes. Neither can the backups be relied on as a buffer may be saved more than once in this process, therefore it is strongly recommend that a backup of the files is made before commencing with this command.
replace-all-string(3),
replace-string(2),
save-some-buffers(2),
grep(3),
get-next-line(2),
undo(2),
query-replace-all-string(3),
search-forward(2).
Regular Expressions
(c) Copyright JASSPA 1999
Last Modified: 1999/06/24
Generated On: 1999/12/01