B. T. Raven wrote:
Thanks, Joost and Emanuel. See below.
Here is the best version [1] so far because
I got away with the redundant input data and
you then use the `query-replace' interface
(indeed the very function) which is better than
the crude `yes-or-no-p'.
(defun replace-list-ask-3 (dict)
(let ((re (string-join (mapcar #'car dict) "\\|")))
(save-excursion
(goto-char (point-min))
(while (re-search-forward re nil t)
(let*((match-string (match-string-no-properties 0))
(default (cdr (assoc match-string dict))) )
(when default
(query-replace match-string default nil
(match-beginning 0)
(match-end 0) )))))))
;; (replace-list-ask-3 '(("james" . "James") ("blish" . "Blish")))
[1] http://user.it.uu.se/~embe8573/emacs-init/replace-list.el