From 8b000fc3b126bf3417b7daa109c08aa8e7bcd3b4 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 16 Dec 2004 17:11:15 +0000 Subject: [PATCH] (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. --- lisp/ChangeLog | 8 ++++++++ lisp/play/zone.el | 22 ++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5108650871d..1d9cc171e92 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2004-12-16 Thien-Thi Nguyen + + * play/zone.el (zone): Fix omission bug: Use a self-disabling + one-shot thunk for uniform (error, quit, normal) recovery. + Reported by John Paul Wallington. + (zone-pgm-random-life): Fix bug: + Recognize empty initial field by lack of "@" chars. + 2004-12-16 Juri Linkov * help.el (function-called-at-point): diff --git a/lisp/play/zone.el b/lisp/play/zone.el index b47a287701d..9338834d6da 100644 --- a/lisp/play/zone.el +++ b/lisp/play/zone.el @@ -152,8 +152,15 @@ If the element is a function or a list of a function and a number, (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 @@ If the element is a function or a list of a function and a number, (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 @@ If nil, `zone-pgm-random-life' chooses a value from 0-3 (inclusive).") (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) -- 2.39.2