From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ken Newsgroups: gmane.emacs.help Subject: Re: (goto-char ...) error Date: Tue, 22 Feb 2011 13:24:21 -0500 Message-ID: <4D63FF55.5030901@mousecar.com> References: <4D63E896.5010503@mousecar.com> Reply-To: gebser@mousecar.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1298399134 27918 80.91.229.12 (22 Feb 2011 18:25:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 22 Feb 2011 18:25:34 +0000 (UTC) To: GNU Emacs List Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 22 19:25:30 2011 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.69) (envelope-from ) id 1PrwvP-0005Vn-I4 for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Feb 2011 19:25:30 +0100 Original-Received: from localhost ([127.0.0.1]:59908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrwvI-0005M6-C8 for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Feb 2011 13:25:20 -0500 Original-Received: from [140.186.70.92] (port=56181 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrwuR-0005KB-7b for help-gnu-emacs@gnu.org; Tue, 22 Feb 2011 13:24:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrwuP-0007CE-80 for help-gnu-emacs@gnu.org; Tue, 22 Feb 2011 13:24:26 -0500 Original-Received: from mout.perfora.net ([74.208.4.195]:65100) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PrwuP-0007C8-2V for help-gnu-emacs@gnu.org; Tue, 22 Feb 2011 13:24:25 -0500 Original-Received: from dellap.mousecar.net (dsl093-011-016.cle1.dsl.speakeasy.net [66.93.11.16]) by mrelay.perfora.net (node=mrus3) with ESMTP (Nemesis) id 0LpsUx-1QVeyH2vup-00fK2r; Tue, 22 Feb 2011 13:24:24 -0500 User-Agent: Thunderbird 2.0.0.24 (X11/20101213) In-Reply-To: X-Enigmail-Version: 0.96.0 OpenPGP: id=5AD091E7 X-Provags-ID: V02:K0:URMKNqOCUvadi2uuTR/iq3xjfo0pSk/0bd36mXwBWM2 oIe6rRlLKxOTzJ66kPCLDqSlv9aKcoNqB73BefI4PjSDSyi1OF cEtNsVa+zcTgxwfDI16qX+aNqUkeV4EVu1P4e7dNCRqwjBAxXA SgbzVscNqykjx/Oo7PBEnCp3RvYLEhy8UEgdr2N8qkYVGWwLZD MAJX7xv7AhePkeMMBU7lXsWMiSCYq9cNg5DjUD/8Pc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.208.4.195 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:79344 Archived-At: On 02/22/2011 12:31 PM Deniz Dogan wrote: > 2011/2/22 ken : >> Performing one search, I save the result with >> >> (setq ptname (re-search-forward ...)) >> >> Then I want to back up one character and perform another search, so I do >> >> (goto-char (- ptname 1)) >> >> But this pukes an error. What's unkosher here? >> > > It's much easier if you tell us what the error is. > > I tried to reproduce the problem using this code: > > ;; search for "a" > (let ((ptname (re-search-forward "a" nil t))) > (when ptname > (goto-char (- ptname 1)))) > > It all depends on how you use re-search-forward. As you can see in my > example, I pass t as the third argument meaning "don't error if you > can't find it, just return nil". I then make sure that ptname is > non-nil before I try to act on it using `-', otherwise we would be > doing (- nil 1) which makes no sense. > My understanding is that the 4th arg to re-search-forward is to repeat the search, so I set that to nil. I get the same error whether the 3rd arg is t or nil (!?): (setq ptname (re-search-forward "REGEXP" endpt t nil)) (if ptname ((goto-char (- ptname 1)) .... The error line in *Messages* says: if: Invalid function: (goto-char (- begin-name-value 1))