unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Does replace-match needs a literal TO-STRING?
@ 2014-09-09 21:20 Thorsten Jolitz
  2014-09-09 21:26 ` Thorsten Jolitz
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Jolitz @ 2014-09-09 21:20 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

I try to use 
  
#+BEGIN_SRC emacs-lisp
(when (search-forward FROM-STRING nil t)
    (replace-match TO-STRING nil t))
#+END_SRC

in a temp-buffer, and it works when TO-STRING is literal like "foo", but
not when its a function that builds and then returns the string "foo". 

Is that a known restriction or am I doing something wrong?

-- 
cheers,
Thorsten





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Does replace-match needs a literal TO-STRING?
  2014-09-09 21:20 Does replace-match needs a literal TO-STRING? Thorsten Jolitz
@ 2014-09-09 21:26 ` Thorsten Jolitz
  0 siblings, 0 replies; 2+ messages in thread
From: Thorsten Jolitz @ 2014-09-09 21:26 UTC (permalink / raw)
  To: help-gnu-emacs

Thorsten Jolitz <tjolitz@gmail.com> writes:

> Hi List, 
>
> I try to use 
>   
> #+BEGIN_SRC emacs-lisp
> (when (search-forward FROM-STRING nil t)
>     (replace-match TO-STRING nil t))
> #+END_SRC
>
> in a temp-buffer, and it works when TO-STRING is literal like "foo", but
> not when its a function that builds and then returns the string "foo". 
>
> Is that a known restriction or am I doing something wrong?

Ok, got it, I have to save-match-data before calling the string building
function (that might regexp search itself), then it works. 
Sorry for the noise.

-- 
cheers,
Thorsten




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-09 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-09 21:20 Does replace-match needs a literal TO-STRING? Thorsten Jolitz
2014-09-09 21:26 ` Thorsten Jolitz

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).