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 14:22:58 -0500
User-agent: Thunderbird 2.0.0.24 (X11/20101213)

On 02/22/2011 01:45 PM Deniz Dogan wrote:
> 2011/2/22 ken <address@hidden>:
>> On 02/22/2011 12:31 PM Deniz Dogan wrote:
>>> 2011/2/22 ken <address@hidden>:
>>>> ....
>>>
>> 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))
>>
>>
> 
> You have one pair of parentheses too many.
> 
> Change:
> 
> ((goto-char (- ptname 1))
> 
> to:
> 
> (goto-char (- ptname 1))
> 
> The error is telling you that "(goto-char (- ptname 1))" is an invalid
> function, which could potentially be confusing, but it really makes
> sense.  You call a function named `foo' like (foo ...), but if you do
> "((foo ...))" you're trying to call a function named "(foo ...)" which
> is not a valid function.
> 
> From the documentation of `if':
> 
> (if COND THEN ELSE...)
> If COND yields non-nil, do THEN, else do ELSE...
> 
> This means that your THEN clause must be a single expression.
> Everything starting with the third argument to `if' is considered part
> of the ELSE clause.
> 
> If you want to multiple expressions in the THEN clause, use `progn' as
> such:
> 
> (if (= x y)
>     (progn
>       (message "They're equal")
>       (message "Hooray!"))
>   (message "They're not equal.")
>   (message "Too bad, bro."))
> 
> I hope that helps!

Yeah, I think it should.  Thanks.

Just to be clear about one more thing I'll be addressing subsequently,
i.e., another "if" nested inside the first:

(if (= x y)
   (progn
     (message "They're equal")
     (message "Hooray!")
     (if (= x z)
          (progn
            (message "The next one's equal too.")
            (message "Hooray++!")))) ; enuf )s to match up to 1st progn
 (message "They're not equal.")
 (message "Too bad, bro."))


elisp is weird.
Thanks again!



reply via email to

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