# HG changeset patch # User Thien-Thi Nguyen # Date 1103216914 0 # Node ID dd8c66d7733c8ffb97863e077f2b1ee8692aa51c # Parent f7098e12436d3e5f71316cb71c9c866810af8bd4 (zone): Fix omission bug: Use a self-disabling one-shot thunk for uniform (error, quit, normal) recovery. (zone-pgm-random-life): Fix bug: Recognize empty initial field by lack of "@" chars. diff -r f7098e12436d -r dd8c66d7733c lisp/play/zone.el --- a/lisp/play/zone.el Thu Dec 16 15:26:39 2004 +0000 +++ b/lisp/play/zone.el Thu Dec 16 17:08:34 2004 +0000 @@ -152,8 +152,15 @@ (set-window-point (selected-window) wp) (sit-for 0 500) (let ((pgm (elt zone-programs (random (length zone-programs)))) - (ct (and f (frame-parameter f 'cursor-type)))) - (when ct (modify-frame-parameters f '((cursor-type . (bar . 0))))) + (ct (and f (frame-parameter f 'cursor-type))) + (restore (list '(kill-buffer outbuf)))) + (when ct + (modify-frame-parameters f '((cursor-type . (bar . 0)))) + (setq restore (cons '(modify-frame-parameters + f (list (cons 'cursor-type ct))) + restore))) + ;; Make `restore' a self-disabling one-shot thunk. + (setq restore `(lambda () ,@restore (setq restore nil))) (condition-case nil (progn (message "Zoning... (%s)" pgm) @@ -167,14 +174,17 @@ (zone-call pgm) (message "Zoning...sorry")) (error + (funcall restore) (while (not (input-pending-p)) (message (format "We were zoning when we wrote %s..." pgm)) (sit-for 3) (message "...here's hoping we didn't hose your buffer!") (sit-for 3))) - (quit (ding) (message "Zoning...sorry"))) - (when ct (modify-frame-parameters f (list (cons 'cursor-type ct))))) - (kill-buffer outbuf))) + (quit + (funcall restore) + (ding) + (message "Zoning...sorry"))) + (when restore (funcall restore))))) ;;;; Zone when idle, or not. @@ -659,7 +669,7 @@ (end-of-line 0) (forward-char -10)) (let ((life-patterns (vector - (if (and col (re-search-forward "[^ ]" max t)) + (if (and col (search-forward "@" max t)) (cons (make-string (length (car col)) 32) col) (list (mapconcat 'identity (make-list (/ (- rtc 11) 15)