From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Filipp Gunbin Newsgroups: gmane.emacs.help Subject: Re: regexp hell Date: Fri, 28 Dec 2012 11:25:42 +0400 Message-ID: <8638yqy6x5.fsf@w2139spb.ru.yotateam.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1356679567 23632 80.91.229.3 (28 Dec 2012 07:26:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Dec 2012 07:26:07 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "B. T. Raven" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 28 08:26:22 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ToUKd-0006Em-Ef for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Dec 2012 08:26:15 +0100 Original-Received: from localhost ([::1]:56411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToUKO-00029l-Vu for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Dec 2012 02:26:00 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToUKC-00029L-9Z for help-gnu-emacs@gnu.org; Fri, 28 Dec 2012 02:25:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ToUKA-0006TZ-Uf for help-gnu-emacs@gnu.org; Fri, 28 Dec 2012 02:25:48 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:34262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToUKA-0006SY-QU for help-gnu-emacs@gnu.org; Fri, 28 Dec 2012 02:25:46 -0500 Original-Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 0A6C420675; Fri, 28 Dec 2012 02:25:45 -0500 (EST) Original-Received: from frontend1.nyi.mail.srv.osa ([10.202.2.160]) by compute3.internal (MEProxy); Fri, 28 Dec 2012 02:25:45 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=mesmtp; bh=OfnhRFwffbn5kvkWvUViIta GuoY=; b=oB5LA1nHD4SkRQixpKKfZM1bLLGwt6WWJvVfKK6cEysuw97N0L9Onm1 bZBfnFragb5ioXG8cD1EWMlU1d2evLSQKV5qAmfWCaIdQof8xHJGdbkXDmR5rXA6 QynBVv4l+6QtNXEtiYEhFbFcXXKicJ1rfqhoQ0ghCwNsqoKtnPII= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:references:date :in-reply-to:message-id:mime-version:content-type; s=smtpout; bh=OfnhRFwffbn5kvkWvUViItaGuoY=; b=RRs+1XIOBEHyB8qsXtiblb3KmolT bayM5kR77V2GPs1qU5WyOD1NZ1vCl3B6Z8up7pYjLvZmHUzMaa/mN01ywY8Cxn7V mXa3CwlmLntLsmDvvOx+bBMd2HDJL0K/0+HvAUPPsDNTseDUK126H+oD1j4pfB2h acR4Bmdr6+sVk2Y= X-Sasl-enc: dFtj0jYTReTOeMJ43TlkR+lmHmNWWQir6LDovC28QDVF 1356679544 Original-Received: from w2139spb.ru.yotateam.com (unknown [94.25.210.15]) by mail.messagingengine.com (Postfix) with ESMTPA id 560BC8E05B0; Fri, 28 Dec 2012 02:25:44 -0500 (EST) In-Reply-To: (B. T. Raven's message of "Fri, 28 Dec 2012 00:57:05 -0600") User-Agent: Gnus/5.1299999999999999 (Gnus v5.13) Emacs/24.2 (cygwin) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.111.4.28 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:88330 Archived-At: On 28/12/2012 10:57, B. T. Raven wrote: > I am trying to byte-compile my .emacs for the first time and I see the > complaint "replace-string is to be used interactively..." or something. > I am using the form: > > (replace-string "\\" "\\\\" nil (point-min) (point-max)) > > in a function and it seems to work but I can't make any equivalent re's > work in re-search-forward (the suggested equivalent to be used in a > lisp programm). I can't get past the "trailing backslash" error. Is > there something kosher for the above replace-string form? > > Thanks, > > Ed > You can use `search-forward' (which searches for string, not for regexp), as it is suggested in documentation for `replace-string': (while (search-forward FROM-STRING nil t) (replace-match TO-STRING nil t)) Then with the above strings it should replace one backslash with two. But if you still need to write a regexp, it seems that you need to double the amount of backslashes. To include a backslash in a regexp you need to prefix it with another backslash and each backslash should be prefixed with another one when written in a lisp program (so, 4 backslashes in a program for a single one in regexp). -- Filipp Gunbin