|
From: | Emanuel Berg |
Subject: | Re: replace deprecated function ? |
Date: | Fri, 16 Feb 2018 17:57:45 +0100 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
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 -- underground experts united http://user.it.uu.se/~embe8573
[Prev in Thread] | Current Thread | [Next in Thread] |