Function: format-replace-strings
format-replace-strings is a byte-compiled function defined in
format.el.gz.
Signature
(format-replace-strings ALIST &optional REVERSE BEG END)
Documentation
Do multiple replacements on the buffer.
ALIST is a list of (FROM . TO) pairs, which should be proper arguments to
search-forward and replace-match, respectively.
Optional second arg REVERSE, if non-nil, means the pairs are (TO . FROM),
so that you can use the same list in both directions if it contains only
literal strings.
Optional args BEG and END specify a region of the buffer on which to operate.
Source Code
;; Defined in /usr/src/emacs/lisp/format.el.gz
;;;
;;; Below are some functions that may be useful in writing encoding and
;;; decoding functions for use in format-alist.
;;;
(defun format-replace-strings (alist &optional reverse beg end)
"Do multiple replacements on the buffer.
ALIST is a list of (FROM . TO) pairs, which should be proper arguments to
`search-forward' and `replace-match', respectively.
Optional second arg REVERSE, if non-nil, means the pairs are (TO . FROM),
so that you can use the same list in both directions if it contains only
literal strings.
Optional args BEG and END specify a region of the buffer on which to operate."
(save-excursion
(save-restriction
(or beg (setq beg (point-min)))
(if end (narrow-to-region (point-min) end))
(while alist
(let ((from (if reverse (cdr (car alist)) (car (car alist))))
(to (if reverse (car (car alist)) (cdr (car alist)))))
(goto-char beg)
(while (search-forward from nil t)
(goto-char (match-beginning 0))
(insert to)
(set-text-properties (- (point) (length to)) (point)
(text-properties-at (point)))
(delete-region (point) (+ (point) (- (match-end 0)
(match-beginning 0)))))
(setq alist (cdr alist)))))))