From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken Raeburn To: guile-emacs@sourceware.cygnus.com Subject: Re: interrupting the Scheme process Date: Fri, 05 May 2000 12:08:00 -0000 Message-id: References: <20000503205439E.satoru-t@is.aist-nara.ac.jp> X-SW-Source: 2000-q2/msg00029.html Keisuke Nishida writes: > I have no idea of how this can be done right now. Emacs checks for > quit in some loops such as eval. When the process is in the Scheme > interpreter, we can't use the same way; instead, we have to generate > a user interrupt. I guess it is possible for Guile Emacs to bind C-g > to generate an interrupt before calling the Scheme evaluator, but I'm > not sure about this part. Ken, do you have any idea? Guile has some hooks for recording that an interrupt has occurred and, at certain times, throwing an exception of some sort. If we could set that flag at C-g time, if Scheme code is currently running, might that do the trick? Then Scheme can trap the exception if it wants, but otherwise we throw back to the containing Lisp call. Propagating the unwind through possibly multiple lisp<->scheme interfaces could be hairy though; I haven't looked very closely at that stuff. > Also, once we come to support multi-thread programming with Emacs, > things become more complicated. Probably we have to maintain threads > in the same way as shells; that is, Emacs will have a "current thread" > and "background threads", and the user may quit only the current thread > by typing C-g, whereas background threads must be killed by a special > command like M-x kill-thread. Hm...that might be a way to do it. I also wonder if we might have cases where we want to send the interrupt to multiple threads -- i.e., if the "foreground" thread is sitting around waiting for N tasks to finish (e.g., get new news from news.mycompany.com, get email from pop.mycompany.com, get new news from news.redhat.com, etc), might we want to interrupt all of them and unwind the main thread only after they've died off? I suppose we could have a "spawn and wait for multiple threads" function which implements all of this on top of the scheme^Wplan you describe, by trapping the interrupt... Ken