[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding String to Beginning of Lines
From: |
tomas |
Subject: |
Re: Adding String to Beginning of Lines |
Date: |
Wed, 11 Nov 2020 15:07:32 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Nov 11, 2020 at 02:22:44PM +0100, Christopher Dimech wrote:
>
> > Sent: Wednesday, November 11, 2020 at 12:16 PM
> > From: "Michael Heerdegen" <michael_heerdegen@web.de>
> > To: help-gnu-emacs@gnu.org
> > Subject: Re: Adding String to Beginning of Lines
> >
> > <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
>
> That's what I started doing at the beginning. Should we revert to this
> or continue with replace-regexp. Have now removed the confusingly called
> `regex' and it is currently called nwltok.
If it's always the beginning of line you're inserting at, your first
approach seems to make more sense.
Something like
(beginning-of-line) ; if you aren't already there, see below
(insert "foo")
should do what you're after.
The beginning-of-line isn't necessary if your advance function
puts you already there. Note that (beginning-of-line 2) will
put you at the beginning of the /next/ line.
Cheers
- t
signature.asc
Description: Digital signature
- Re: Adding String to Beginning of Lines, (continued)
- Re: Adding String to Beginning of Lines, Stefan Monnier, 2020/11/10
- RE: Adding String to Beginning of Lines, Drew Adams, 2020/11/10
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/11
- Re: Adding String to Beginning of Lines, tomas, 2020/11/10
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/11
- Re: Adding String to Beginning of Lines, Christopher Dimech, 2020/11/11
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/11
- Re: Adding String to Beginning of Lines,
tomas <=
- Re: Adding String to Beginning of Lines, Christopher Dimech, 2020/11/11
- Re: Adding String to Beginning of Lines, Christopher Dimech, 2020/11/11
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/11
- Re: Adding String to Beginning of Lines, Stefan Monnier, 2020/11/11
- Re: Adding String to Beginning of Lines, Christopher Dimech, 2020/11/11
- Re: Adding String to Beginning of Lines, Jean Louis, 2020/11/10
Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/10
Re: Adding String to Beginning of Lines, Dante Catalfamo, 2020/11/12