help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A variant of match-end, but after replacement?


From: Marcin Borkowski
Subject: Re: A variant of match-end, but after replacement?
Date: Sun, 19 Jul 2015 21:58:32 +0200

On 2015-07-19, at 15:41, Pascal J. Bourguignon <pjb@informatimago.com> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>>>     (let ((old-end (prog1 (match-end 1)
>>>                      (replace-match "newtext" t t string 1)))) 
>>>        (do-something old-end))
>>
>> Still not there - I can't assume that "newtext" will have the same
>> length as the thing it replaced...
>
> Sorry, I misread what you wanted. 
>
>     (let ((new-end (+ (prog1 (match-beginning 1)
>                          (replace-match new-text t t string 1)))
>                       (length new-text)))
>        (do-somthing-from new-end))

Thanks!  That's easy, and indeed it will work, since the length of the
replacement is fixed in my use-case.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

[Prev in Thread] Current Thread [Next in Thread]