[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Interrupting computations using signals
From: |
Daniel Mendler |
Subject: |
Re: Interrupting computations using signals |
Date: |
Mon, 24 May 2021 17:12:20 +0200 |
On 5/24/21 4:37 PM, Eli Zaretskii wrote:
> See the documentation of debug-on-event to understand the effect of
> SIGUSR2.
Thank you Eli! `debug-on-event`was exactly what I was looking for. This
way I can define an `interruptible` macro, which is only effective
around interruptible sections of code.
Daniel
~~~
;; Disable debugger
(setq debug-on-event nil)
(advice-add #'debug :around #'ignore)
;; Interruptible sections
(defmacro interruptible (&rest body)
`(condition-case err
(let ((debug-on-event 'sigusr2)) ,@body)
(quit nil)))
;; Example
(while t
(interruptible
(message "COMPUTE")
(sleep-for 1)
(message "COMPUTE-END")))
~~~