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

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

Re: Adding String to Beginning of Lines


From: Michael Heerdegen
Subject: Re: Adding String to Beginning of Lines
Date: Wed, 11 Nov 2020 12:16:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

<tomas@tuxteam.de> writes:

> But watch out: the replacement string (confusingly called `regex' here,
> others have already pointed that out) might contain special sequences
> (e.g. "\\&") which have a meaning in this context.

Indeed, an important objection.

I would suggest to avoid using any query-replace at all and rather use
something like

#+begin_src emacs-lisp
(save-excursion
  (while (and (<= (point) end)
              (not (eobp)))
    (insert my-string)
    (forward-line +1))
  (deactivate-mark))
#+end_src

> Cheers

Ebenso!


Regards,

Michael.




reply via email to

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