* replace-match: end of the replacement text for strings
@ 2002-09-14 22:15 Roland Winkler
2002-09-16 13:43 ` Stefan Monnier <foo@acm.com>
0 siblings, 1 reply; 6+ messages in thread
From: Roland Winkler @ 2002-09-14 22:15 UTC (permalink / raw)
Hi
When I use replace-match to operate on a string, is there an easy
way to find out the end of the replacement text in the string that
is returned by replace-match (like point in a buffer)? I have in
mind the situation when the optional arg LITERAL is nil, i.e., the
replacement text is `derived' from the string that is passed to
replace-match.
Thanks a lot,
Roland
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: replace-match: end of the replacement text for strings
2002-09-14 22:15 replace-match: end of the replacement text for strings Roland Winkler
@ 2002-09-16 13:43 ` Stefan Monnier <foo@acm.com>
2002-09-16 17:47 ` Roland Winkler
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2002-09-16 13:43 UTC (permalink / raw)
>>>>> "Roland" == Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
> When I use replace-match to operate on a string, is there an easy
> way to find out the end of the replacement text in the string that
> is returned by replace-match (like point in a buffer)? I have in
> mind the situation when the optional arg LITERAL is nil, i.e., the
> replacement text is `derived' from the string that is passed to
> replace-match.
You should be able to get it by looking at the size of the string
before and after replacement as well as the size of the replaced text.
It's a bit round-about, but I can't think of any other way.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: replace-match: end of the replacement text for strings
2002-09-16 13:43 ` Stefan Monnier <foo@acm.com>
@ 2002-09-16 17:47 ` Roland Winkler
2002-09-16 19:00 ` Stefan Monnier <foo@acm.com>
2002-09-16 19:51 ` Kai Großjohann
0 siblings, 2 replies; 6+ messages in thread
From: Roland Winkler @ 2002-09-16 17:47 UTC (permalink / raw)
"Stefan Monnier <foo@acm.com>" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:
> >>>>> "Roland" == Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
> > When I use replace-match to operate on a string, is there an easy
> > way to find out the end of the replacement text in the string that
> > is returned by replace-match (like point in a buffer)? I have in
> > mind the situation when the optional arg LITERAL is nil, i.e., the
> > replacement text is `derived' from the string that is passed to
> > replace-match.
>
> You should be able to get it by looking at the size of the string
> before and after replacement as well as the size of the replaced
> text. It's a bit round-about, but I can't think of any other way.
In general, doesn't this work only when I know the replacement text
-- which I don't know when I have LITERAL set to nil and I am using
something like "\1" in the replacement?
Would it make sense to have something similar to match-data, i.e., a
lisp variable where the end of the replacement text is stored? Or is
the above situation too rare to justify such a thing? When
replace-match is operating on a buffer, it leaves point at the end
of the replacement text. So I guess that the function `knows' the
end of the replacement text anyway, even when operating on strings.
Roland
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: replace-match: end of the replacement text for strings
2002-09-16 17:47 ` Roland Winkler
@ 2002-09-16 19:00 ` Stefan Monnier <foo@acm.com>
2002-09-16 19:51 ` Kai Großjohann
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2002-09-16 19:00 UTC (permalink / raw)
>> You should be able to get it by looking at the size of the string
>> before and after replacement as well as the size of the replaced
>> text. It's a bit round-about, but I can't think of any other way.
> In general, doesn't this work only when I know the replacement text
> -- which I don't know when I have LITERAL set to nil and I am using
> something like "\1" in the replacement?
Reread what I wrote: I said "replaced" not "replacement".
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: replace-match: end of the replacement text for strings
2002-09-16 17:47 ` Roland Winkler
2002-09-16 19:00 ` Stefan Monnier <foo@acm.com>
@ 2002-09-16 19:51 ` Kai Großjohann
2002-09-16 20:09 ` Roland Winkler
1 sibling, 1 reply; 6+ messages in thread
From: Kai Großjohann @ 2002-09-16 19:51 UTC (permalink / raw)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
> "Stefan Monnier <foo@acm.com>" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:
>
>> >>>>> "Roland" == Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
>> > When I use replace-match to operate on a string, is there an easy
>> > way to find out the end of the replacement text in the string that
>> > is returned by replace-match (like point in a buffer)? I have in
>> > mind the situation when the optional arg LITERAL is nil, i.e., the
>> > replacement text is `derived' from the string that is passed to
>> > replace-match.
>>
>> You should be able to get it by looking at the size of the string
>> before and after replacement as well as the size of the replaced
>> text. It's a bit round-about, but I can't think of any other way.
>
> In general, doesn't this work only when I know the replacement text
> -- which I don't know when I have LITERAL set to nil and I am using
> something like "\1" in the replacement?
You need to do some arithmetic to find out the value you want.
length of replaced text = new length of string
- old length of string
+ length of text to be replaced
kai
--
~/.signature is: umop 3p!sdn (Frank Nobis)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: replace-match: end of the replacement text for strings
2002-09-16 19:51 ` Kai Großjohann
@ 2002-09-16 20:09 ` Roland Winkler
0 siblings, 0 replies; 6+ messages in thread
From: Roland Winkler @ 2002-09-16 20:09 UTC (permalink / raw)
Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:
> You need to do some arithmetic to find out the value you want.
>
> length of replaced text = new length of string
> - old length of string
> + length of text to be replaced
got you.
Thanks a lot,
Roland
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-09-16 20:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-14 22:15 replace-match: end of the replacement text for strings Roland Winkler
2002-09-16 13:43 ` Stefan Monnier <foo@acm.com>
2002-09-16 17:47 ` Roland Winkler
2002-09-16 19:00 ` Stefan Monnier <foo@acm.com>
2002-09-16 19:51 ` Kai Großjohann
2002-09-16 20:09 ` Roland Winkler
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.