all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Catch arbitrary signal and throw it later in C
@ 2023-04-13  7:24 Yuan Fu
  2023-04-13  7:33 ` Ruijie Yu via Emacs development discussions.
  0 siblings, 1 reply; 8+ messages in thread
From: Yuan Fu @ 2023-04-13  7:24 UTC (permalink / raw)
  To: emacs-devel

Say I have an arbitrary Lisp function func, and need to evaluate it in C. But after evaluating the function, I need to do some clean up (freeing something). Would be be possible to catch any signal thrown by evaluating the function func, and throw it after cleaning up?

I’m aware of safe_call and internal_condition_case_n. In particular, what I described can probably be implemented with internal_condition_case_n with a handler. But I wonder if there are better/existing ways to do this?

The real scenarios is this: treesit-search-forward and friends takes a PRED argument, which can be either a regexp string or a predicate function. In the meantime, treesit-search-forward and friends need to clean up a tree-sitter cursor object before they return. So if this predicate function signals in the middle of treesit-search-forward, the tree-sitter cursor would be leaked. I can slap on a safe_call when evaluating the predicate function, but I think throwing the signal would be more user-friendly. (Plus safe_call will say “An error occurred during redisplay”, which isn’t necessarily true)

Yuan





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-04-13 23:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-13  7:24 Catch arbitrary signal and throw it later in C Yuan Fu
2023-04-13  7:33 ` Ruijie Yu via Emacs development discussions.
2023-04-13  8:12   ` Yuan Fu
2023-04-13  8:20     ` Eli Zaretskii
2023-04-13  8:22     ` Po Lu
2023-04-13 22:18       ` Yuan Fu
2023-04-13 23:48         ` Po Lu
2023-04-13  8:24     ` Andreas Schwab

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.