help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (goto-char ...) error


From: ken
Subject: Re: (goto-char ...) error
Date: Tue, 22 Feb 2011 13:24:21 -0500
User-agent: Thunderbird 2.0.0.24 (X11/20101213)

On 02/22/2011 12:31 PM Deniz Dogan wrote:
> 2011/2/22 ken <address@hidden>:
>> 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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]