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

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

Re: Why looking-at-p works?


From: Nick Dokos
Subject: Re: Why looking-at-p works?
Date: Tue, 06 Mar 2018 18:17:13 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Marcin Borkowski <mbork@mbork.pl> writes:

> On 2018-03-06, at 19:53, John Mastro <john.b.mastro@gmail.com> wrote:
>
>> Marcin Borkowski <mbork@mbork.pl> wrote:
>>> Hi all,
>>>
>>> (defsubst looking-at-p (regexp)
>>>   "\
>>> Same as `looking-at' except this function does not change the match data."
>>>   (let ((inhibit-changing-match-data t))
>>>     (looking-at regexp)))
>>>
>>> What happens is that if I make looking-at in the above code fail (e.g.,
>>> by saying (looking-at-p 123)), inhibit-changing-match-data remains nil,
>>> even though there is no unwind-protect here.  Why does it work like
>>> this?
>>
>> If I understand your question correctly, it's nothing specific to
>> looking-at-p. Let-bindings are protected by a sort of implicit
>> unwind-protect so that they're always "un-done" upon exiting the scope,
>> even in case of non-local exits like an error. Otherwise errors could
>> leave global variables in unpredictable states.
>
> Thanks, I suspected something like that.
>
> Where is it documented?  I could find it neither in the Elisp Reference
> nor in let's docstring.
>

(info "(elisp)Local variables")

-- 
Nick






reply via email to

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