From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: bolega Newsgroups: gmane.emacs.help Subject: Re: TERRIBLE ERROR :: Invalid search bound - wrong side of point Date: Thu, 2 Jul 2009 21:46:31 -0700 (PDT) Organization: http://groups.google.com Message-ID: <025dee7e-208b-49c7-b0d9-641a75023a33@r33g2000yqn.googlegroups.com> References: <30ad1c47-f7b3-4eaa-a374-47edff9a6831@26g2000yqk.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1246599708 1088 80.91.229.12 (3 Jul 2009 05:41:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 3 Jul 2009 05:41:48 +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 Jul 03 07:41:42 2009 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 1MMbWm-0000le-PH for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Jul 2009 07:41:41 +0200 Original-Received: from localhost ([127.0.0.1]:43557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MMbWm-0000wF-1i for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Jul 2009 01:41:40 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!r33g2000yqn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.lang.lisp,comp.lang.scheme,comp.unix.shell Original-Lines: 63 Original-NNTP-Posting-Host: 75.28.96.199 Original-X-Trace: posting.google.com 1246596391 12270 127.0.0.1 (3 Jul 2009 04:46:31 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 3 Jul 2009 04:46:31 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r33g2000yqn.googlegroups.com; posting-host=75.28.96.199; posting-account=REkl4woAAABFXaU7nL79XtGpnmNCQ415 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30),gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:170538 comp.lang.lisp:270404 comp.lang.scheme:81625 comp.unix.shell:228432 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor 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:65749 Archived-At: On Jul 2, 8:42=A0pm, Pillsy wrote: > On Jul 2, 7:16=A0pm, bolega wrote: > [...] > > > I only want to replace this on one line such as the current line. I > > could narrow to the line but is it really necessary ? Cant I just > > specify the limits in replace-regexp ? Either there is something > > seriously wrong with my understanding of emacs so I must pursue this > > for the sake of learning. > > You should probably try comp.emacs or gnu.help.emacs, too, since this > group focuses almost entirely on the Common Lisp dialect of Lisp. > Nonetheless, I'll take a stab at answering your question. > > > I tried several variants: > > (replace-regexp "$" "#" nil (line-beginning-position) (line-end- > > position nil) ) > > (replace-regexp "$" "#" nil (line-beginning-position) (+ (line-end- > > position nil) 1)) > > Well, one thing that works is to capture the text of the line as a > group, like so: > > (replace-regexp "^\\(.*\\)$" "\\1#" > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nil > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (line-beginning-position) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (line-end-position)) > > However, if you just want to stick a character onto the end of the > line, why not just move the point there and insert the character > instead of using regexps? > > (save-excursion (end-of-line) (insert "#")) > > HTH, > Pillsy There is something really crazy going on. When I try your first suggestion, (replace-regexp "^\\(.*\\)$" "\\1#" nil (line-beginning-position) (line-end-position)) I get this error: Debugger entered--Lisp error: (error "Invalid search bound (wrong side of point)") re-search-forward("^\\(.*\\)$" # t) perform-replace("^\\(.*\\)$" "\\1#" nil t nil nil nil 109703 109803) replace-regexp("^\\(.*\\)$" "\\1#" nil 109703 109803) eval((replace-regexp "^\\(.*\\)$" "\\1#" nil (line-beginning- position) (line-end-position))) eval-last-sexp-1(nil) eval-last-sexp(nil) * call-interactively(eval-last-sexp) I want to understand what is going on so I learn to trace and debug an error than be doing endless work-arounds. Predictive programming is desired - which works the first time !!!