From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: replace-regexp in lisp function Date: Mon, 18 Jan 2010 14:01:35 +0100 Organization: Organization?!? Message-ID: <87aawby3bk.fsf@lola.goethe.zz> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1263822182 32032 80.91.229.12 (18 Jan 2010 13:43:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Jan 2010 13:43:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 18 14:42:55 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NWrsc-0007Cv-5k for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Jan 2010 14:42:54 +0100 Original-Received: from localhost ([127.0.0.1]:45836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWrsd-0001aa-5i for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Jan 2010 08:42:55 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.glorb.com!news2.glorb.com!feeder.erje.net!newsfeed.freenet.de!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (gnu/linux) Cancel-Lock: sha1:4D/n/59xz3hwb788OVXdUaOr20s= Original-Lines: 26 Original-NNTP-Posting-Date: 18 Jan 2010 14:01:35 CET Original-NNTP-Posting-Host: f9280684.newsspool4.arcor-online.net Original-X-Trace: DXC=\fT:VF=NnTkm7>ihJR; B_c4IUK5MOK` List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71296 Archived-At: Sven Garbade writes: > Hallo List, > > I frequently use the following regular-regexp: > > M-x replace-regexp \(<<\) \1cn\,(+ (line-number-at-pos) \#) > > to replace "<<" with "< > ;; 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? Lisp string syntax needs additional quoting for regexps, and things like \, and \# are not supported outside of interactive use. I recommend that you first give your command interactively, then use C-x Esc Esc to get at the corresponding Lisp verbiage. -- David Kastrup