From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: Re: regexp hell Date: Fri, 28 Dec 2012 11:33:10 -0600 Organization: NewsGuy - Unlimited Usenet $23.95 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1356716115 13023 80.91.229.3 (28 Dec 2012 17:35:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Dec 2012 17:35:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 28 18:35:31 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 1TodqC-0006kH-1D for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Dec 2012 18:35:28 +0100 Original-Received: from localhost ([::1]:48699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Todpx-0008E6-Ds for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Dec 2012 12:35:13 -0500 Original-Path: usenet.stanford.edu!news.glorb.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!spln!extra.newsguy.com!newsp.newsguy.com!news3 Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-NNTP-Posting-Host: p1ae56f4195ea15b869497d11a99fc157032502d1152da6d3.newsdawg.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 In-Reply-To: X-Received-Bytes: 2155 Original-Xref: usenet.stanford.edu gnu.emacs.help:196024 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:88337 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. Thanks, Filipp. That's what I needed. Now the .emacs byte-compiles without issuing a warning. > > 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). >