unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: Search nodes in Emacs manual
Date: Mon, 21 Jun 2004 19:38:18 +0300	[thread overview]
Message-ID: <874qp4kgsl.fsf@mail.jurta.org> (raw)
In-Reply-To: <x51xkc8rpn.fsf@lola.goethe.zz> (David Kastrup's message of "18 Jun 2004 23:46:28 +0200")

David Kastrup <dak@gnu.org> writes:
> Juri Linkov <juri@jurta.org> 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/

  parent reply	other threads:[~2004-06-21 16:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-18 19:35 Search nodes in Emacs manual Juri Linkov
2004-06-18 21:46 ` David Kastrup
2004-06-19 18:42   ` Juri Linkov
2004-06-19 18:52     ` David Kastrup
2004-06-19 21:22       ` Juri Linkov
2004-06-21 16:38   ` Juri Linkov [this message]
2004-06-19  3:19 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874qp4kgsl.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).