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

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

Re: "C-a" the first character in each line?


From: weber
Subject: Re: "C-a" the first character in each line?
Date: Sun, 24 Jun 2007 13:59:37 -0000
User-agent: G2/1.0

On Jun 24, 10:20 am, Nikos Apostolakis <nikos...@gmail.com> wrote:
> Hello group,
>
> in the scratch buffer I did
>
> -----------------
> (while (search-forward-regexp "^\\(.\\)" nil t)
>   (replace-match "\% \1"))
>
> laa
> moo
> nii
> -----------------
>
> I expected
>
> %
> % laa
> % moo
> % nii
>
> but isnstead I get
>
> % ^A
> % ^Aaa
> % ^Aoo
> % ^Aii
>
> where ^A stands for the character "C-a".
>
> What am I missing?
>
> TIA,
> Nikos

Dunno why, but \\1 instead of \1 solves it.
Or alternatively:
(while (search-forward-regexp "^\\(.\\)" nil t)
  (replace-match (concat "% "(match-string 1))))
which looks better to me...

HTH,
weber



reply via email to

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