help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: replace deprecated function ?


From: Emanuel Berg
Subject: Re: replace deprecated function ?
Date: Tue, 13 Feb 2018 20:27:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

B. T. Raven wrote:

> But I notice that query-replace-regexp-eval is
> no longer considered kosher. How should this be
> rewritten for Emacs ver. 25? Especially I would
> like a function that is more immediately
> understandable than what I have now.

In general, you do this with a while loop: in
the condition, you search, and in the body, you
replace.

Note: `search-forward-regexp'/`replace-match'
is recommended but I don't see (right now) why
you can't do it with `re-search-forward' just
as well.

So an example would be, to replace all REGEXP
matches with REPLACE:

(defun replace-regexp-buffer (regexp replace)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward regexp nil t)
      (replace-match replace) )))

For your situation,

1) Do the simplest possibly such
   loop-and-replace (like my example)

2) Do a function that keeps a list, just as you
   have, and then iterates the list and feed it
   to the function from step 1.

-- 
underground experts united
http://user.it.uu.se/~embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]