all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.