Mercurial > emacs
annotate lisp/play/life.el @ 75519:b271481fb8d2
(url-get-authentication): Fix typo in docstring.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Mon, 29 Jan 2007 16:58:37 +0000 |
parents | e3694f1cb928 |
children | 527f752989fc 95d0cdf160ea |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; life.el --- John Horton Conway's `Life' game for GNU Emacs |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1988, 2001, 2002, 2003, 2004, |
75347 | 4 ;; 2005, 2006, 2007 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
5 |
17976 | 6 ;; Author: Kyle Jones <kyleuunet.uu.net> |
58252
a22adc2b72fb
Maintainer is now FSF.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
7 ;; Maintainer: FSF |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
923
diff
changeset
|
8 ;; Keywords: games |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
9 |
53 | 10 ;; This file is part of GNU Emacs. |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
53 | 15 ;; any later version. |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
53 | 26 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
27 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
28 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
29 ;; A demonstrator for John Horton Conway's "Life" cellular automaton |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
30 ;; in Emacs Lisp. Picks a random one of a set of interesting Life |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2571
diff
changeset
|
31 ;; patterns and evolves it according to the familiar rules. |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
32 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
33 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
34 |
58252
a22adc2b72fb
Maintainer is now FSF.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
35 (defvar life-patterns |
53 | 36 [("@@@" " @@" "@@@") |
37 ("@@@ @@@" "@@ @@ " "@@@ @@@") | |
38 ("@@@ @@@" "@@ @@" "@@@ @@@") | |
39 ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") | |
40 ("@@@@@@@@@@") | |
41 (" @@@@@@@@@@ " | |
42 " @@@@@@@@@@ " | |
43 " @@@@@@@@@@ " | |
44 "@@@@@@@@@@ " | |
45 "@@@@@@@@@@ ") | |
46 ("@" "@" "@" "@" "@" "@" "@" "@" "@" "@" "@" "@" "@" "@" "@") | |
47 ("@ @" "@ @" "@ @" | |
48 "@ @" "@ @" "@ @" | |
49 "@ @" "@ @" "@ @" | |
50 "@ @" "@ @" "@ @" | |
51 "@ @" "@ @" "@ @") | |
52 ("@@ " " @@ " " @@ " | |
53 " @@ " " @@ " " @@ " | |
54 " @@ " " @@ " " @@ " | |
55 " @@ " " @@ " " @@ " | |
56 " @@ " " @@ " " @@ " | |
57 " @@") | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
36750
diff
changeset
|
58 ("@@@@@@@@@" "@ @ @" "@ @@@@@ @" "@ @ @ @" "@@@ @@@" |
72884
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
59 "@ @ @ @" "@ @@@@@ @" "@ @ @" "@@@@@@@@@") |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
60 (" @ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
61 " @ @ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
62 " @@ @@ @@" |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
63 " @ @ @@ @@" |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
64 "@@ @ @ @@ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
65 "@@ @ @ @@ @ @ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
66 " @ @ @ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
67 " @ @ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
68 " @@ ") |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
69 (" @ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
70 " @ @@" |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
71 " @ @ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
72 " @ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
73 " @ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
74 "@ @ ") |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
75 ("@@@ @" |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
76 "@ " |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
77 " @@" |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
78 " @@ @" |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
79 "@ @ @") |
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
80 ("@@@@@@@@ @@@@@ @@@ @@@@@@@ @@@@@")] |
53 | 81 "Vector of rectangles containing some Life startup patterns.") |
82 | |
83 ;; Macros are used macros for manifest constants instead of variables | |
84 ;; because the compiler will convert them to constants, which should | |
85 ;; eval faster than symbols. | |
86 ;; | |
87 ;; Don't change any of the life-* macro constants unless you thoroughly | |
88 ;; understand the `life-grim-reaper' function. | |
923 | 89 |
90 (defmacro life-life-char () ?@) | |
91 (defmacro life-death-char () (1+ (life-life-char))) | |
92 (defmacro life-birth-char () 3) | |
93 (defmacro life-void-char () ?\ ) | |
53 | 94 |
923 | 95 (defmacro life-life-string () (char-to-string (life-life-char))) |
96 (defmacro life-death-string () (char-to-string (life-death-char))) | |
97 (defmacro life-birth-string () (char-to-string (life-birth-char))) | |
98 (defmacro life-void-string () (char-to-string (life-void-char))) | |
99 (defmacro life-not-void-regexp () (concat "[^" (life-void-string) "\n]")) | |
53 | 100 |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
101 (defmacro life-increment (variable) (list 'setq variable (list '1+ variable))) |
923 | 102 |
53 | 103 |
104 ;; list of numbers that tell how many characters to move to get to | |
105 ;; each of a cell's eight neighbors. | |
58252
a22adc2b72fb
Maintainer is now FSF.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
106 (defvar life-neighbor-deltas nil) |
53 | 107 |
108 ;; window display always starts here. Easier to deal with than | |
109 ;; (scroll-up) and (scroll-down) when trying to center the display. | |
58252
a22adc2b72fb
Maintainer is now FSF.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
110 (defvar life-window-start nil) |
53 | 111 |
112 ;; For mode line | |
58252
a22adc2b72fb
Maintainer is now FSF.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
113 (defvar life-current-generation nil) |
53 | 114 ;; Sadly, mode-line-format won't display numbers. |
58252
a22adc2b72fb
Maintainer is now FSF.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
115 (defvar life-generation-string nil) |
53 | 116 |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
117 (defvar life-initialized nil |
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
118 "Non-nil if `life' has been run at least once.") |
53 | 119 |
923 | 120 ;;;###autoload |
53 | 121 (defun life (&optional sleeptime) |
122 "Run Conway's Life simulation. | |
215 | 123 The starting pattern is randomly selected. Prefix arg (optional first |
124 arg non-nil from a program) is the number of seconds to sleep between | |
53 | 125 generations (this defaults to 1)." |
126 (interactive "p") | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
127 (or life-initialized |
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
128 (random t)) |
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
129 (setq life-initialized t) |
53 | 130 (or sleeptime (setq sleeptime 1)) |
131 (life-setup) | |
923 | 132 (catch 'life-exit |
133 (while t | |
134 (let ((inhibit-quit t)) | |
36750
83e8e419d94d
(life): Rearrange code so that all calls to
Gerd Moellmann <gerd@gnu.org>
parents:
21166
diff
changeset
|
135 (life-display-generation sleeptime) |
923 | 136 (life-grim-reaper) |
137 (life-expand-plane-if-needed) | |
36750
83e8e419d94d
(life): Rearrange code so that all calls to
Gerd Moellmann <gerd@gnu.org>
parents:
21166
diff
changeset
|
138 (life-increment-generation))))) |
53 | 139 |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
140 (defalias 'life-mode 'life) |
53 | 141 (put 'life-mode 'mode-class 'special) |
142 | |
143 (defun life-setup () | |
144 (let (n) | |
145 (switch-to-buffer (get-buffer-create "*Life*") t) | |
146 (erase-buffer) | |
147 (kill-all-local-variables) | |
148 (setq case-fold-search nil | |
149 mode-name "Life" | |
150 major-mode 'life-mode | |
151 truncate-lines t | |
72884
9578474ca036
(life-patterns): Add a few more interesting patterns.
Juanma Barranquero <lekktu@gmail.com>
parents:
72749
diff
changeset
|
152 show-trailing-whitespace nil |
53 | 153 life-current-generation 0 |
154 life-generation-string "0" | |
155 mode-line-buffer-identification '("Life: generation " | |
156 life-generation-string) | |
157 fill-column (1- (window-width)) | |
158 life-window-start 1) | |
159 (buffer-disable-undo (current-buffer)) | |
160 ;; stuff in the random pattern | |
161 (life-insert-random-pattern) | |
162 ;; make sure (life-life-char) is used throughout | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
163 (goto-char (point-min)) |
53 | 164 (while (re-search-forward (life-not-void-regexp) nil t) |
165 (replace-match (life-life-string) t t)) | |
166 ;; center the pattern horizontally | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
167 (goto-char (point-min)) |
53 | 168 (setq n (/ (- fill-column (save-excursion (end-of-line) (point))) 2)) |
169 (while (not (eobp)) | |
170 (indent-to n) | |
171 (forward-line)) | |
172 ;; center the pattern vertically | |
173 (setq n (/ (- (1- (window-height)) | |
174 (count-lines (point-min) (point-max))) | |
175 2)) | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
176 (goto-char (point-min)) |
53 | 177 (newline n) |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
178 (goto-char (point-max)) |
53 | 179 (newline n) |
180 ;; pad lines out to fill-column | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
181 (goto-char (point-min)) |
53 | 182 (while (not (eobp)) |
183 (end-of-line) | |
184 (indent-to fill-column) | |
185 (move-to-column fill-column) | |
186 (delete-region (point) (progn (end-of-line) (point))) | |
187 (forward-line)) | |
188 ;; expand tabs to spaces | |
189 (untabify (point-min) (point-max)) | |
190 ;; before starting be sure the automaton has room to grow | |
191 (life-expand-plane-if-needed) | |
192 ;; compute initial neighbor deltas | |
193 (life-compute-neighbor-deltas))) | |
194 | |
195 (defun life-compute-neighbor-deltas () | |
196 (setq life-neighbor-deltas | |
197 (list -1 (- fill-column) | |
198 (- (1+ fill-column)) (- (+ 2 fill-column)) | |
199 1 fill-column (1+ fill-column) | |
200 (+ 2 fill-column)))) | |
201 | |
202 (defun life-insert-random-pattern () | |
203 (insert-rectangle | |
4401
c5e18576d5f1
(life-insert-random-pattern): Simplify (% (abs (random)) N)
Paul Eggert <eggert@twinsun.com>
parents:
3591
diff
changeset
|
204 (elt life-patterns (random (length life-patterns)))) |
53 | 205 (insert ?\n)) |
206 | |
207 (defun life-increment-generation () | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
208 (life-increment life-current-generation) |
53 | 209 (setq life-generation-string (int-to-string life-current-generation))) |
210 | |
211 (defun life-grim-reaper () | |
212 ;; Clear the match information. Later we check to see if it | |
213 ;; is still clear, if so then all the cells have died. | |
21166
acffd9b0ac6d
(life-grim-reaper): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
214 (set-match-data nil) |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
215 (goto-char (point-min)) |
53 | 216 ;; For speed declare all local variable outside the loop. |
217 (let (point char pivot living-neighbors list) | |
218 (while (search-forward (life-life-string) nil t) | |
219 (setq list life-neighbor-deltas | |
220 living-neighbors 0 | |
221 pivot (1- (point))) | |
222 (while list | |
223 (setq point (+ pivot (car list)) | |
224 char (char-after point)) | |
225 (cond ((eq char (life-void-char)) | |
226 (subst-char-in-region point (1+ point) | |
227 (life-void-char) 1 t)) | |
228 ((< char 3) | |
229 (subst-char-in-region point (1+ point) char (1+ char) t)) | |
230 ((< char 9) | |
231 (subst-char-in-region point (1+ point) char 9 t)) | |
232 ((>= char (life-life-char)) | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
233 (life-increment living-neighbors))) |
53 | 234 (setq list (cdr list))) |
235 (if (memq living-neighbors '(2 3)) | |
236 () | |
237 (subst-char-in-region pivot (1+ pivot) | |
238 (life-life-char) (life-death-char) t)))) | |
239 (if (null (match-beginning 0)) | |
240 (life-extinct-quit)) | |
241 (subst-char-in-region 1 (point-max) 9 (life-void-char) t) | |
242 (subst-char-in-region 1 (point-max) 1 (life-void-char) t) | |
243 (subst-char-in-region 1 (point-max) 2 (life-void-char) t) | |
244 (subst-char-in-region 1 (point-max) (life-birth-char) (life-life-char) t) | |
245 (subst-char-in-region 1 (point-max) (life-death-char) (life-void-char) t)) | |
246 | |
247 (defun life-expand-plane-if-needed () | |
248 (catch 'done | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
249 (goto-char (point-min)) |
53 | 250 (while (not (eobp)) |
251 ;; check for life at beginning or end of line. If found at | |
252 ;; either end, expand at both ends, | |
253 (cond ((or (eq (following-char) (life-life-char)) | |
254 (eq (progn (end-of-line) (preceding-char)) (life-life-char))) | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
255 (goto-char (point-min)) |
53 | 256 (while (not (eobp)) |
257 (insert (life-void-char)) | |
258 (end-of-line) | |
259 (insert (life-void-char)) | |
260 (forward-char)) | |
261 (setq fill-column (+ 2 fill-column)) | |
262 (scroll-left 1) | |
263 (life-compute-neighbor-deltas) | |
264 (throw 'done t))) | |
265 (forward-line))) | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
266 (goto-char (point-min)) |
53 | 267 ;; check for life within the first two lines of the buffer. |
268 ;; If present insert two lifeless lines at the beginning.. | |
269 (cond ((search-forward (life-life-string) | |
270 (+ (point) fill-column fill-column 2) t) | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
271 (goto-char (point-min)) |
53 | 272 (insert-char (life-void-char) fill-column) |
273 (insert ?\n) | |
274 (insert-char (life-void-char) fill-column) | |
275 (insert ?\n) | |
276 (setq life-window-start (+ life-window-start fill-column 1)))) | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
277 (goto-char (point-max)) |
53 | 278 ;; check for life within the last two lines of the buffer. |
279 ;; If present insert two lifeless lines at the end. | |
280 (cond ((search-backward (life-life-string) | |
281 (- (point) fill-column fill-column 2) t) | |
12948
052c1dfa4efa
(abs): Function definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
4401
diff
changeset
|
282 (goto-char (point-max)) |
53 | 283 (insert-char (life-void-char) fill-column) |
284 (insert ?\n) | |
285 (insert-char (life-void-char) fill-column) | |
286 (insert ?\n) | |
287 (setq life-window-start (+ life-window-start fill-column 1))))) | |
288 | |
289 (defun life-display-generation (sleeptime) | |
290 (goto-char life-window-start) | |
291 (recenter 0) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
36750
diff
changeset
|
292 |
923 | 293 ;; Redisplay; if the user has hit a key, exit the loop. |
72749
e9e2ce3817ce
(life-display-generation): Test for input manually if `sleeptime' is negative
Eli Zaretskii <eliz@gnu.org>
parents:
68634
diff
changeset
|
294 (or (and (sit-for sleeptime) (< 0 sleeptime)) |
e9e2ce3817ce
(life-display-generation): Test for input manually if `sleeptime' is negative
Eli Zaretskii <eliz@gnu.org>
parents:
68634
diff
changeset
|
295 (not (input-pending-p)) |
923 | 296 (throw 'life-exit nil))) |
53 | 297 |
298 (defun life-extinct-quit () | |
299 (life-display-generation 0) | |
300 (signal 'life-extinct nil)) | |
301 | |
302 (put 'life-extinct 'error-conditions '(life-extinct quit)) | |
303 (put 'life-extinct 'error-message "All life has perished") | |
584 | 304 |
305 (provide 'life) | |
306 | |
52401 | 307 ;;; arch-tag: e9373544-755e-42f5-a9a1-4d4c422bb97a |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
308 ;;; life.el ends here |