From: Christopher Dimech <dimech@gmx.com>
To: tomas@tuxteam.de
Cc: help-gnu-emacs@gnu.org
Subject: Re: Adding String to Beginning of Lines
Date: Wed, 11 Nov 2020 15:49:24 +0100 [thread overview]
Message-ID: <trinity-b41720b5-280d-4d83-8fb8-3763c99a593a-1605106164127@3c-app-mailcom-bs05> (raw)
In-Reply-To: <20201111140732.GA14577@tuxteam.de>
> Sent: Wednesday, November 11, 2020 at 3:07 PM
> From: tomas@tuxteam.de
> To: help-gnu-emacs@gnu.org
> Subject: Re: Adding String to Beginning of Lines
>
> 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.
Correct. Always at beginning of line
> 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
>
next prev parent reply other threads:[~2020-11-11 14:49 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 10:43 Adding String to Beginning of Lines Christopher Dimech
2020-11-10 11:10 ` tomas
2020-11-10 11:19 ` Christopher Dimech
2020-11-10 11:29 ` Christopher Dimech
2020-11-10 11:54 ` Michael Heerdegen
2020-11-10 11:58 ` Christopher Dimech
2020-11-10 12:07 ` Michael Heerdegen
2020-11-10 12:03 ` Christopher Dimech
2020-11-10 12:16 ` Michael Heerdegen
2020-11-10 13:40 ` Christopher Dimech
2020-11-10 14:06 ` Jean Louis
2020-11-10 14:29 ` Michael Heerdegen
2020-11-10 19:12 ` Jean Louis
2020-11-10 19:42 ` Michael Heerdegen
2020-11-10 21:22 ` Jean Louis
2020-11-11 10:59 ` Michael Heerdegen
2020-11-17 16:06 ` Jean Louis
2020-11-17 16:28 ` Michael Heerdegen
2020-11-10 22:31 ` Stefan Monnier
2020-11-10 23:00 ` Drew Adams
2020-11-11 21:37 ` Michael Heerdegen
2020-11-10 14:16 ` Michael Heerdegen
2020-11-10 14:38 ` Christopher Dimech
2020-11-10 14:49 ` Michael Heerdegen
2020-11-10 17:52 ` Christopher Dimech
2020-11-10 18:03 ` Michael Heerdegen
2020-11-10 18:25 ` Christopher Dimech
2020-11-10 18:49 ` Michael Heerdegen
2020-11-10 18:56 ` Christopher Dimech
2020-11-10 19:02 ` Michael Heerdegen
2020-11-10 19:29 ` Christopher Dimech
2020-11-10 20:07 ` Michael Heerdegen
2020-11-10 22:45 ` tomas
2020-11-11 11:16 ` Michael Heerdegen
2020-11-11 13:22 ` Christopher Dimech
2020-11-11 13:56 ` Michael Heerdegen
2020-11-11 14:07 ` tomas
2020-11-11 14:49 ` Christopher Dimech [this message]
2020-11-11 17:20 ` Christopher Dimech
2020-11-11 18:12 ` Michael Heerdegen
2020-11-11 18:25 ` Stefan Monnier
2020-11-11 18:35 ` Christopher Dimech
2020-11-10 14:03 ` Jean Louis
2020-11-10 11:42 ` Michael Heerdegen
2020-11-10 18:47 ` H. Dieter Wilhelm
2020-11-12 19:01 ` Dante Catalfamo
2020-11-14 22:09 ` Jamie Beardslee
2020-11-14 23:17 ` Stefan Monnier
2020-11-14 23:39 ` Jamie Beardslee
2020-11-15 9:12 ` tomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=trinity-b41720b5-280d-4d83-8fb8-3763c99a593a-1605106164127@3c-app-mailcom-bs05 \
--to=dimech@gmx.com \
--cc=help-gnu-emacs@gnu.org \
--cc=tomas@tuxteam.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).