[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "C-a" the first character in each line?
From: |
Joost Kremers |
Subject: |
Re: "C-a" the first character in each line? |
Date: |
24 Jun 2007 14:17:32 GMT |
User-agent: |
slrn/0.9.8.1 (Linux) |
Nikos Apostolakis wrote:
> Hello group,
>
> in the scratch buffer I did
>
> -----------------
> (while (search-forward-regexp "^\\(.\\)" nil t)
> (replace-match "\% \1"))
[...]
> % ^A
> % ^Aaa
> % ^Aoo
> % ^Aii
>
> where ^A stands for the character "C-a".
>
> What am I missing?
it's actually what you're inserting: \1 *is* ^A:
(string-match "\1" "abc")
==> 3
so what you need to do is escape the backslash:
(replace-match "% \\1")
btw, you are aware of the function string-insert-rectangle?
--
Joost Kremers joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)