[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: replace-regexp in lisp function
From: |
Pascal J. Bourguignon |
Subject: |
Re: replace-regexp in lisp function |
Date: |
Mon, 18 Jan 2010 14:11:17 +0100 |
User-agent: |
Gnus/5.101 (Gnus v5.10.10) Emacs/22.3 (gnu/linux) |
Sven Garbade <sfgarbade@googlemail.com> writes:
> Hallo List,
>
> I frequently use the following regular-regexp:
>
> M-x replace-regexp <RET> \(<<\) <RET> \1cn\,(+ (line-number-at-pos) \#)
>
> to replace "<<" with "<<cn=line number". I tried to write a function
>
> ;; add chunk number
> (defun add-chunk-number ()
> (interactive)
> (query-replace-regexp "\(<<\)" "\1cn\,(+ (line-number-at-pos) \#)")
> )
>
> to save typing, but this does not work. What did I wrong?
You don't understand the syntax of strings.
How many characters are there in "\(" ?
How many characters are there in "\n" ?
How many characters are there in "\\(" ?
How many characters are there in "\\n" ?
--
__Pascal Bourguignon__ http://www.informatimago.com/