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

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

Re: replace-regexp


From: Stefan Monnier
Subject: Re: replace-regexp
Date: Sat, 08 May 2021 17:10:47 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> There are indeed 2 "standard" solutions:
>> 1- start your loop at the end, moving towards the beginning.
>
> You mean like this?
>
> (defun md-latex-back (beg end)
>   (interactive "r")
>   (save-excursion
>     (goto-char end)
>     (while (re-search-backward "_\\(.*\\)_" beg t)
>       (replace-match "\\\\textit{\\1}") )))

Yup.

> Also works.  Maybe better than the `copy-marker' stuff?

My comment wasn't just for regexp-replacement but more generally for
operating on a region.  So better or not will depend on the
specific case.  In many cases either way is about as good.


        Stefan




reply via email to

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