On Tue, Feb 01, 2022 at 02:54:51PM +0100, Manuel Giraud wrote: > tomas@tuxteam.de writes: > > [...] > > > Nice. Many ways to go about that. > > And do you think I could avoid having those defvar? How about hiding stuff in a closure? You'll need to have lexical environments for that: (defun make-sentinel-factory () (let (sentinels (list)) (lambda (tag) (setq sentinels (push tag sentinels)) ; FIXME: fail if already there! (lambda (process event) (when (equal "finished" event) (setq sentinels (delq tag sentinels)) (message "%S is done; still left: %S" tag sentinels) (when (null sentinels) (message "All sentinels done"))))))) (setq make-sentinel (make-sentinel-factory)) (setq s1 (funcall make-sentinel 's1)) (setq s2 (funcall make-sentinel 's2)) (setq s3 (funcall make-sentinel 's3)) (funcall s2 "process" "finished") (funcall s3 "process" "finished") (funcall s1 "process" "finished") Catching errors is left as an exercise to ... Cheers -- t