emacs-devel
[Top][All Lists]
Advanced

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

Re: Calling Lisp in C functions


From: Yuan Fu
Subject: Re: Calling Lisp in C functions
Date: Fri, 24 Sep 2021 10:55:00 -0700


> On Sep 22, 2021, at 11:59 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Wed, 22 Sep 2021 20:59:00 -0700
>> Cc: Emacs developers <emacs-devel@gnu.org>
>> 
>> I tried to write
>> 
>> ptrdiff_t count = SPECPDL_INDEX ();
>> record_unwind_protect_ptr (ts_delete_cursor, cursor);
>> ...
>> return unbind_to (count, xxx);
>> 
>> But it give a type error, because ts_delete_cursor doesn’t take a void*. I 
>> guess I need to define a wrapper function to avoid that error?
> 
> Yes, see for example directory_files_internal_unwind and its usage in
> dired.c.
> 
>> Can I use record_unwind_protect_ptr more than once?
> 
> Yes.
> 
>> What does that count mean?
> 
> It tells unbind_to how much of the unwind-protect stack to unwind.
> See the definition of unbind_to in eval.c.
> 
>> What is specpdl?
> 
> It's an array used for manually managed stack for tracking unwinds and
> other stuff by the Emacs Lisp machine.  See the comments for 'union
> specbinding', starting at line 3135 of lisp.h.

Thanks, I think I know how it works now.

Yuan




reply via email to

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