Mercurial > emacs
annotate lisp/play/zone.el @ 45936:00b587e45a1a
(find-file-read-args): Add new argument `mustmatch' and
pass it down to read-file-name.
(find-file, find-file-other-window, find-file-other-frame)
(find-file-read-only, find-file-read-only-other-window)
(find-file-read-only-other-frame): Use it and fix prompts.
author | Andreas Schwab <schwab@suse.de> |
---|---|
date | Fri, 21 Jun 2002 08:35:50 +0000 |
parents | a04951f92260 |
children | bcb77f40c06e |
rev | line source |
---|---|
30565 | 1 ;;; zone.el --- idle display hacks |
2 | |
38677
7177c6c2aaba
(zone-pgm-stress): Use unwind-protect to make sure
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
3 ;; Copyright (C) 2000, 2001 Free Software Foundation, Inc. |
30565 | 4 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
5 ;; Author: Victor Zandy <zandy@cs.wisc.edu> |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
6 ;; Maintainer: Thien-Thi Nguyen <ttn@gnu.org> |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
7 ;; Keywords: games |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
8 ;; Created: June 6, 1998 |
30565 | 9 |
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 | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
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 | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; Don't zone out in front of Emacs! Try M-x zone. | |
30 ;; If it eventually irritates you, try M-x zone-leave-me-alone. | |
31 | |
32 ;; Bored by the zone pyrotechnics? Write your own! Add it to | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
33 ;; `zone-programs'. See `zone-call' for higher-ordered zoning. |
30565 | 34 |
35 ;; WARNING: Not appropriate for Emacs sessions over modems or | |
36 ;; computers as slow as mine. | |
37 | |
38 ;; THANKS: Christopher Mayer, Scott Flinchbaugh, Rachel Kalmar, | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
39 ;; Max Froumentin. |
30565 | 40 |
41 ;;; Code: | |
42 | |
43 (require 'timer) | |
44 (require 'tabify) | |
45 (eval-when-compile (require 'cl)) | |
46 | |
47 (defvar zone-idle 20 | |
48 "*Seconds to idle before zoning out.") | |
49 | |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
50 (defvar zone-timer nil |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
51 "The timer we use to decide when to zone out, or nil if none.") |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
52 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
53 (defvar zone-timeout nil |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
54 "*Seconds to timeout the zoning. |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
55 If nil, don't interrupt for about 1^26 seconds.") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
56 |
30565 | 57 ;; Vector of functions that zone out. `zone' will execute one of |
58 ;; these functions, randomly chosen. The chosen function is invoked | |
59 ;; in the *zone* buffer, which contains the text of the selected | |
60 ;; window. If the function loops, it *must* periodically check and | |
61 ;; halt if `input-pending-p' is t (because quitting is disabled when | |
62 ;; Emacs idle timers are run). | |
63 (defvar zone-programs [ | |
64 zone-pgm-jitter | |
65 zone-pgm-putz-with-case | |
66 zone-pgm-dissolve | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
67 ;; zone-pgm-explode |
30565 | 68 zone-pgm-whack-chars |
69 zone-pgm-rotate | |
70 zone-pgm-rotate-LR-lockstep | |
71 zone-pgm-rotate-RL-lockstep | |
72 zone-pgm-rotate-LR-variable | |
73 zone-pgm-rotate-RL-variable | |
74 zone-pgm-drip | |
75 zone-pgm-drip-fretfully | |
76 zone-pgm-five-oclock-swan-dive | |
77 zone-pgm-martini-swan-dive | |
78 zone-pgm-paragraph-spaz | |
79 zone-pgm-stress | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
80 zone-pgm-stress-destress |
30565 | 81 ]) |
82 | |
83 (defmacro zone-orig (&rest body) | |
84 `(with-current-buffer (get 'zone 'orig-buffer) | |
85 ,@body)) | |
86 | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
87 (defmacro zone-hiding-modeline (&rest body) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
88 `(let (bg mode-line-fg mode-line-bg mode-line-box) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
89 (unwind-protect |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
90 (progn |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
91 (when (and (= 0 (get 'zone 'modeline-hidden-level)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
92 (display-color-p)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
93 (setq bg (face-background 'default) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
94 mode-line-box (face-attribute 'mode-line :box) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
95 mode-line-fg (face-attribute 'mode-line :foreground) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
96 mode-line-bg (face-attribute 'mode-line :background)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
97 (set-face-attribute 'mode-line nil |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
98 :foreground bg |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
99 :background bg |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
100 :box nil)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
101 (put 'zone 'modeline-hidden-level |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
102 (1+ (get 'zone 'modeline-hidden-level))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
103 ,@body) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
104 (put 'zone 'modeline-hidden-level |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
105 (1- (get 'zone 'modeline-hidden-level))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
106 (when (and (> 1 (get 'zone 'modeline-hidden-level)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
107 mode-line-fg) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
108 (set-face-attribute 'mode-line nil |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
109 :foreground mode-line-fg |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
110 :background mode-line-bg |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
111 :box mode-line-box))))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
112 |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
113 (defun zone-call (program &optional timeout) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
114 "Call PROGRAM in a zoned way. |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
115 If PROGRAM is a function, call it, interrupting after the amount |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
116 of time in seconds specified by optional arg TIMEOUT, or `zone-timeout' |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
117 if unspecified, q.v. |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
118 PROGRAM can also be a list of elements, which are interpreted like so: |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
119 If the element is a function or a list of a function and a number, |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
120 apply `zone-call' recursively." |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
121 (cond ((functionp program) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
122 (with-timeout ((or timeout zone-timeout (ash 1 26))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
123 (funcall program))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
124 ((listp program) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
125 (mapcar (lambda (elem) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
126 (cond ((functionp elem) (zone-call elem)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
127 ((and (listp elem) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
128 (functionp (car elem)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
129 (numberp (cadr elem))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
130 (apply 'zone-call elem)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
131 (t (error "bad `zone-call' elem:" elem)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
132 program)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
133 |
30565 | 134 ;;;###autoload |
135 (defun zone () | |
136 "Zone out, completely." | |
137 (interactive) | |
30592
fbdf4c1e1acf
(zone, zone-pgm-stress): Don't use window-system.
Eli Zaretskii <eliz@gnu.org>
parents:
30565
diff
changeset
|
138 (let ((f (selected-frame)) |
30565 | 139 (outbuf (get-buffer-create "*zone*")) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
140 (text (buffer-substring (window-start) (window-end))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
141 (wp (1+ (- (window-point (selected-window)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
142 (window-start))))) |
30565 | 143 (put 'zone 'orig-buffer (current-buffer)) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
144 (put 'zone 'modeline-hidden-level 0) |
30565 | 145 (set-buffer outbuf) |
146 (setq mode-name "Zone") | |
147 (erase-buffer) | |
148 (insert text) | |
149 (switch-to-buffer outbuf) | |
150 (setq buffer-undo-list t) | |
151 (untabify (point-min) (point-max)) | |
152 (set-window-start (selected-window) (point-min)) | |
153 (set-window-point (selected-window) wp) | |
154 (sit-for 0 500) | |
155 (let ((pgm (elt zone-programs (random (length zone-programs)))) | |
156 (ct (and f (frame-parameter f 'cursor-type)))) | |
157 (when ct (modify-frame-parameters f '((cursor-type . (bar . 0))))) | |
158 (condition-case nil | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
159 (progn |
30565 | 160 (message "Zoning... (%s)" pgm) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
161 (garbage-collect) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
162 ;; If some input is pending, zone says "sorry", which |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
163 ;; isn't nice; this might happen e.g. when they invoke the |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
164 ;; game by clicking the menu bar. So discard any pending |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
165 ;; input before zoning out. |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
166 (if (input-pending-p) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
167 (discard-input)) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
168 (zone-call pgm) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
169 (message "Zoning...sorry")) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
170 (error |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
171 (while (not (input-pending-p)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
172 (message (format "We were zoning when we wrote %s..." pgm)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
173 (sit-for 3) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
174 (message "...here's hoping we didn't hose your buffer!") |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
175 (sit-for 3))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
176 (quit (ding) (message "Zoning...sorry"))) |
30565 | 177 (when ct (modify-frame-parameters f (list (cons 'cursor-type ct))))) |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
178 (kill-buffer outbuf))) |
30565 | 179 |
180 ;;;; Zone when idle, or not. | |
181 | |
182 (defun zone-when-idle (secs) | |
183 "Zone out when Emacs has been idle for SECS seconds." | |
184 (interactive "nHow long before I start zoning (seconds): ") | |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
185 (if (timerp zone-timer) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
186 (cancel-timer zone-timer)) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
187 (setq zone-timer nil) |
30565 | 188 (or (<= secs 0) |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
189 (setq zone-timer (run-with-idle-timer secs t 'zone)))) |
30565 | 190 |
191 (defun zone-leave-me-alone () | |
192 "Don't zone out when Emacs is idle." | |
193 (interactive) | |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
194 (if (timerp zone-timer) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
195 (cancel-timer zone-timer)) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
196 (setq zone-timer nil) |
30565 | 197 (message "I won't zone out any more")) |
198 | |
199 | |
200 ;;;; zone-pgm-jitter | |
201 | |
202 (defun zone-shift-up () | |
203 (let* ((b (point)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
204 (e (progn |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
205 (end-of-line) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
206 (if (looking-at "\n") (1+ (point)) (point)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
207 (s (buffer-substring b e))) |
30565 | 208 (delete-region b e) |
209 (goto-char (point-max)) | |
210 (insert s))) | |
211 | |
212 (defun zone-shift-down () | |
213 (goto-char (point-max)) | |
214 (forward-line -1) | |
215 (beginning-of-line) | |
216 (let* ((b (point)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
217 (e (progn |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
218 (end-of-line) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
219 (if (looking-at "\n") (1+ (point)) (point)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
220 (s (buffer-substring b e))) |
30565 | 221 (delete-region b e) |
222 (goto-char (point-min)) | |
223 (insert s))) | |
224 | |
225 (defun zone-shift-left () | |
226 (while (not (eobp)) | |
227 (or (eolp) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
228 (let ((c (following-char))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
229 (delete-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
230 (end-of-line) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
231 (insert c))) |
30565 | 232 (forward-line 1))) |
233 | |
234 (defun zone-shift-right () | |
235 (while (not (eobp)) | |
236 (end-of-line) | |
237 (or (bolp) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
238 (let ((c (preceding-char))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
239 (delete-backward-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
240 (beginning-of-line) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
241 (insert c))) |
30565 | 242 (forward-line 1))) |
243 | |
244 (defun zone-pgm-jitter () | |
245 (let ((ops [ | |
246 zone-shift-left | |
247 zone-shift-left | |
248 zone-shift-left | |
249 zone-shift-left | |
250 zone-shift-right | |
251 zone-shift-down | |
252 zone-shift-down | |
253 zone-shift-down | |
254 zone-shift-down | |
255 zone-shift-down | |
256 zone-shift-up | |
257 ])) | |
258 (goto-char (point-min)) | |
259 (while (not (input-pending-p)) | |
260 (funcall (elt ops (random (length ops)))) | |
261 (goto-char (point-min)) | |
262 (sit-for 0 10)))) | |
263 | |
264 | |
265 ;;;; zone-pgm-whack-chars | |
266 | |
267 (defun zone-pgm-whack-chars () | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
268 (let ((tbl (copy-sequence (get 'zone-pgm-whack-chars 'wc-tbl)))) |
30565 | 269 (while (not (input-pending-p)) |
270 (let ((i 48)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
271 (while (< i 122) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
272 (aset tbl i (+ 48 (random (- 123 48)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
273 (setq i (1+ i))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
274 (translate-region (point-min) (point-max) tbl) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
275 (sit-for 0 2))))) |
30565 | 276 |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
277 (put 'zone-pgm-whack-chars 'wc-tbl |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
278 (let ((tbl (make-string 128 ?x)) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
279 (i 0)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
280 (while (< i 128) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
281 (aset tbl i i) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
282 (setq i (1+ i))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
283 tbl)) |
30565 | 284 |
285 ;;;; zone-pgm-dissolve | |
286 | |
287 (defun zone-remove-text () | |
288 (let ((working t)) | |
289 (while working | |
290 (setq working nil) | |
291 (save-excursion | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
292 (goto-char (point-min)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
293 (while (not (eobp)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
294 (if (looking-at "[^(){}\n\t ]") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
295 (let ((n (random 5))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
296 (if (not (= n 0)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
297 (progn |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
298 (setq working t) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
299 (forward-char 1)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
300 (delete-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
301 (insert " "))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
302 (forward-char 1)))) |
30565 | 303 (sit-for 0 2)))) |
304 | |
305 (defun zone-pgm-dissolve () | |
306 (zone-remove-text) | |
307 (zone-pgm-jitter)) | |
308 | |
309 | |
310 ;;;; zone-pgm-explode | |
311 | |
312 (defun zone-exploding-remove () | |
313 (let ((i 0)) | |
314 (while (< i 20) | |
315 (save-excursion | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
316 (goto-char (point-min)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
317 (while (not (eobp)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
318 (if (looking-at "[^*\n\t ]") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
319 (let ((n (random 5))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
320 (if (not (= n 0)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
321 (forward-char 1)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
322 (insert " "))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
323 (forward-char 1))) |
30565 | 324 (setq i (1+ i)) |
325 (sit-for 0 2))) | |
326 (zone-pgm-jitter)) | |
327 | |
328 (defun zone-pgm-explode () | |
329 (zone-exploding-remove) | |
330 (zone-pgm-jitter)) | |
331 | |
332 | |
333 ;;;; zone-pgm-putz-with-case | |
334 | |
335 ;; Faster than `zone-pgm-putz-with-case', but not as good: all | |
336 ;; instances of the same letter have the same case, which produces a | |
337 ;; less interesting effect than you might imagine. | |
338 (defun zone-pgm-2nd-putz-with-case () | |
339 (let ((tbl (make-string 128 ?x)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
340 (i 0)) |
30565 | 341 (while (< i 128) |
342 (aset tbl i i) | |
343 (setq i (1+ i))) | |
344 (while (not (input-pending-p)) | |
345 (setq i ?a) | |
346 (while (<= i ?z) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
347 (aset tbl i |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
348 (if (zerop (random 5)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
349 (upcase i) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
350 (downcase i))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
351 (setq i (+ i (1+ (random 5))))) |
30565 | 352 (setq i ?A) |
353 (while (<= i ?z) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
354 (aset tbl i |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
355 (if (zerop (random 5)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
356 (downcase i) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
357 (upcase i))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
358 (setq i (+ i (1+ (random 5))))) |
30565 | 359 (translate-region (point-min) (point-max) tbl) |
360 (sit-for 0 2)))) | |
361 | |
362 (defun zone-pgm-putz-with-case () | |
363 (goto-char (point-min)) | |
364 (while (not (input-pending-p)) | |
365 (let ((np (+ 2 (random 5))) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
366 (pm (point-max))) |
30565 | 367 (while (< np pm) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
368 (goto-char np) |
30565 | 369 (let ((prec (preceding-char)) |
370 (props (text-properties-at (1- (point))))) | |
371 (insert (if (zerop (random 2)) | |
372 (upcase prec) | |
373 (downcase prec))) | |
374 (set-text-properties (1- (point)) (point) props)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
375 (backward-char 2) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
376 (delete-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
377 (setq np (+ np (1+ (random 5)))))) |
30565 | 378 (goto-char (point-min)) |
379 (sit-for 0 2))) | |
380 | |
381 | |
382 ;;;; zone-pgm-rotate | |
383 | |
384 (defun zone-line-specs () | |
385 (let (ret) | |
386 (save-excursion | |
387 (goto-char (window-start)) | |
388 (while (< (point) (window-end)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
389 (when (looking-at "[\t ]*\\([^\n]+\\)") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
390 (setq ret (cons (cons (match-beginning 1) (match-end 1)) ret))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
391 (forward-line 1))) |
30565 | 392 ret)) |
393 | |
394 (defun zone-pgm-rotate (&optional random-style) | |
395 (let* ((specs (apply | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
396 'vector |
30565 | 397 (let (res) |
398 (mapcar (lambda (ent) | |
399 (let* ((beg (car ent)) | |
400 (end (cdr ent)) | |
401 (amt (if random-style | |
402 (funcall random-style) | |
403 (- (random 7) 3)))) | |
404 (when (< (- end (abs amt)) beg) | |
405 (setq amt (random (- end beg)))) | |
406 (unless (= 0 amt) | |
407 (setq res | |
408 (cons | |
409 (vector amt beg (- end (abs amt))) | |
410 res))))) | |
411 (zone-line-specs)) | |
412 res))) | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
413 (n (length specs)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
414 amt aamt cut paste txt i ent) |
30565 | 415 (while (not (input-pending-p)) |
416 (setq i 0) | |
417 (while (< i n) | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
418 (setq ent (aref specs i)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
419 (setq amt (aref ent 0) aamt (abs amt)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
420 (if (> 0 amt) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
421 (setq cut 1 paste 2) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
422 (setq cut 2 paste 1)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
423 (goto-char (aref ent cut)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
424 (setq txt (buffer-substring (point) (+ (point) aamt))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
425 (delete-char aamt) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
426 (goto-char (aref ent paste)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
427 (insert txt) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
428 (setq i (1+ i))) |
30565 | 429 (sit-for 0.04)))) |
430 | |
431 (defun zone-pgm-rotate-LR-lockstep () | |
432 (zone-pgm-rotate (lambda () 1))) | |
433 | |
434 (defun zone-pgm-rotate-RL-lockstep () | |
435 (zone-pgm-rotate (lambda () -1))) | |
436 | |
437 (defun zone-pgm-rotate-LR-variable () | |
438 (zone-pgm-rotate (lambda () (1+ (random 3))))) | |
439 | |
440 (defun zone-pgm-rotate-RL-variable () | |
441 (zone-pgm-rotate (lambda () (1- (- (random 3)))))) | |
442 | |
443 | |
444 ;;;; zone-pgm-drip | |
445 | |
446 (defun zone-cpos (pos) | |
447 (buffer-substring pos (1+ pos))) | |
448 | |
449 (defun zone-fret (pos) | |
450 (let* ((case-fold-search nil) | |
451 (c-string (zone-cpos pos)) | |
452 (hmm (cond | |
453 ((string-match "[a-z]" c-string) (upcase c-string)) | |
454 ((string-match "[A-Z]" c-string) (downcase c-string)) | |
455 (t " ")))) | |
456 (do ((i 0 (1+ i)) | |
457 (wait 0.5 (* wait 0.8))) | |
458 ((= i 20)) | |
459 (goto-char pos) | |
460 (delete-char 1) | |
461 (insert (if (= 0 (% i 2)) hmm c-string)) | |
462 (sit-for wait)) | |
463 (delete-char -1) (insert c-string))) | |
464 | |
465 (defun zone-fall-through-ws (c col wend) | |
466 (let ((fall-p nil) ; todo: move outward | |
467 (wait 0.15) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
468 (o (point)) ; for terminals w/o cursor hiding |
30565 | 469 (p (point))) |
470 (while (progn | |
471 (forward-line 1) | |
472 (move-to-column col) | |
473 (looking-at " ")) | |
474 (setq fall-p t) | |
475 (delete-char 1) | |
476 (insert (if (< (point) wend) c " ")) | |
477 (save-excursion | |
478 (goto-char p) | |
479 (delete-char 1) | |
480 (insert " ") | |
481 (goto-char o) | |
482 (sit-for (setq wait (* wait 0.8)))) | |
483 (setq p (1- (point)))) | |
484 fall-p)) | |
485 | |
486 (defun zone-pgm-drip (&optional fret-p pancake-p) | |
487 (let* ((ww (1- (window-width))) | |
488 (wh (window-height)) | |
489 (mc 0) ; miss count | |
490 (total (* ww wh)) | |
491 (fall-p nil)) | |
492 (goto-char (point-min)) | |
493 ;; fill out rectangular ws block | |
494 (while (not (eobp)) | |
495 (end-of-line) | |
496 (let ((cc (current-column))) | |
497 (if (< cc ww) | |
498 (insert (make-string (- ww cc) ? )) | |
499 (delete-char (- ww cc)))) | |
500 (unless (eobp) | |
501 (forward-char 1))) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
502 ;; pad ws past bottom of screen |
30565 | 503 (let ((nl (- wh (count-lines (point-min) (point))))) |
504 (when (> nl 0) | |
505 (let ((line (concat (make-string (1- ww) ? ) "\n"))) | |
506 (do ((i 0 (1+ i))) | |
507 ((= i nl)) | |
508 (insert line))))) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
509 (catch 'done |
30565 | 510 (while (not (input-pending-p)) |
511 (goto-char (point-min)) | |
512 (sit-for 0) | |
513 (let ((wbeg (window-start)) | |
514 (wend (window-end))) | |
515 (setq mc 0) | |
516 ;; select non-ws character, but don't miss too much | |
517 (goto-char (+ wbeg (random (- wend wbeg)))) | |
518 (while (looking-at "[ \n\f]") | |
519 (if (= total (setq mc (1+ mc))) | |
520 (throw 'done 'sel) | |
521 (goto-char (+ wbeg (random (- wend wbeg)))))) | |
522 ;; character animation sequence | |
523 (let ((p (point))) | |
524 (when fret-p (zone-fret p)) | |
525 (goto-char p) | |
526 (setq fall-p (zone-fall-through-ws | |
527 (zone-cpos p) (current-column) wend)))) | |
528 ;; assuming current-column has not changed... | |
529 (when (and pancake-p | |
530 fall-p | |
531 (< (count-lines (point-min) (point)) | |
532 wh)) | |
533 (previous-line 1) | |
534 (forward-char 1) | |
535 (sit-for 0.137) | |
536 (delete-char -1) | |
537 (insert "@") | |
538 (sit-for 0.137) | |
539 (delete-char -1) | |
540 (insert "*") | |
541 (sit-for 0.137) | |
542 (delete-char -1) | |
543 (insert "_")))))) | |
544 | |
545 (defun zone-pgm-drip-fretfully () | |
546 (zone-pgm-drip t)) | |
547 | |
548 (defun zone-pgm-five-oclock-swan-dive () | |
549 (zone-pgm-drip nil t)) | |
550 | |
551 (defun zone-pgm-martini-swan-dive () | |
552 (zone-pgm-drip t t)) | |
553 | |
554 | |
555 ;;;; zone-pgm-paragraph-spaz | |
556 | |
557 (defun zone-pgm-paragraph-spaz () | |
558 (if (memq (zone-orig major-mode) '(text-mode fundamental-mode)) | |
559 (let ((fill-column fill-column) | |
560 (fc-min fill-column) | |
561 (fc-max fill-column) | |
562 (max-fc (1- (frame-width)))) | |
563 (while (sit-for 0.1) | |
564 (fill-paragraph 1) | |
565 (setq fill-column (+ fill-column (- (random 5) 2))) | |
566 (when (< fill-column fc-min) | |
567 (setq fc-min fill-column)) | |
568 (when (> fill-column max-fc) | |
569 (setq fill-column max-fc)) | |
570 (when (> fill-column fc-max) | |
571 (setq fc-max fill-column)))) | |
572 (message "Zoning... (zone-pgm-rotate)") | |
573 (zone-pgm-rotate))) | |
574 | |
575 | |
576 ;;;; zone-pgm-stress | |
577 | |
578 (defun zone-pgm-stress () | |
579 (goto-char (point-min)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
580 (let (lines) |
30565 | 581 (while (< (point) (point-max)) |
582 (let ((p (point))) | |
583 (forward-line 1) | |
584 (setq lines (cons (buffer-substring p (point)) lines)))) | |
585 (sit-for 5) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
586 (zone-hiding-modeline |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
587 (let ((msg "Zoning... (zone-pgm-stress)")) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
588 (while (not (string= msg "")) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
589 (message (setq msg (substring msg 1))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
590 (sit-for 0.05))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
591 (while (not (input-pending-p)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
592 (when (< 50 (random 100)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
593 (goto-char (point-max)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
594 (forward-line -1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
595 (let ((kill-whole-line t)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
596 (kill-line)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
597 (goto-char (point-min)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
598 (insert (nth (random (length lines)) lines))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
599 (message (concat (make-string (random (- (frame-width) 5)) ? ) "grrr")) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
600 (sit-for 0.1))))) |
38677
7177c6c2aaba
(zone-pgm-stress): Use unwind-protect to make sure
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
601 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
602 |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
603 ;;;; zone-pgm-stress-destress |
38677
7177c6c2aaba
(zone-pgm-stress): Use unwind-protect to make sure
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
604 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
605 (defun zone-pgm-stress-destress () |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
606 (zone-call 'zone-pgm-stress 25) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
607 (zone-hiding-modeline |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
608 (sit-for 3) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
609 (erase-buffer) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
610 (sit-for 3) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
611 (insert-buffer "*Messages*") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
612 (message "") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
613 (goto-char (point-max)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
614 (recenter -1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
615 (sit-for 3) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
616 (delete-region (point-min) (window-start)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
617 (message "hey why stress out anyway?") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
618 (zone-call '((zone-pgm-rotate 30) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
619 (zone-pgm-whack-chars 10) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
620 zone-pgm-drip)))) |
30565 | 621 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
622 |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
623 ;;;;;;;;;;;;;;; |
30565 | 624 (provide 'zone) |
625 | |
626 ;;; zone.el ends here |