[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Search nodes in Emacs manual
From: |
Juri Linkov |
Subject: |
Re: Search nodes in Emacs manual |
Date: |
Mon, 21 Jun 2004 19:38:18 +0300 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
David Kastrup <address@hidden> writes:
> Juri Linkov <address@hidden> writes:
>> BTW, `replace-regexp' currently doesn't support evaluation of the
>> replacement string as `query-replace-regexp' now does, but I think
>> it should.
>
> It already does in my current code, but as I said, I am currently
> trying to get a grip about how to deal with the replacement history
> properly.
I also noticed that the command `map-query-replace-regexp' can be
rewritten using the feature of replacement string evaluation
with a very simple replacement expression like:
(nth (mod (/ \# 2) 3) '("ab" "cd" "ef"))
where 2 means how many times to use each replacement string before
rotating to the next (this is the third arg of `map-query-replace-regexp'),
and 3 is the length of the word list.
Perhaps, 33 lines of `map-query-replace-regexp' and 12 lines of
`replace-loop-through-replacements' should be simplified with a few
lines using the evaluation feature. Below is an example how
`map-query-replace-regexp' could basically look: (the first line of
variables below are just sample values, they will be replaced with
input values if such a rewrite of `map-query-replace-regexp' is ok).
(let* ((regexp "[a-z]+") (to-string "ab cd df") (n 2) start end
(to-strings (split-string to-string " " t))
(replacements `(nth (mod (/ replace-count ,n) ,(length to-strings))
',to-strings)))
(perform-replace regexp
(cons 'replace-eval-replacement replacements)
t t nil nil nil start end))
--
Juri Linkov
http://www.jurta.org/emacs/