annotate lisp/play/zone.el @ 36988:c904b89720f8

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Mon, 26 Mar 2001 04:11:03 +0000
parents abc299ad3386
children 67b464da13ec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; zone.el --- idle display hacks
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 2000 Free Software Foundation, Inc.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;;; Author: Victor Zandy <zandy@cs.wisc.edu>
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;;; Maintainer: Thien-Thi Nguyen <ttn@gnu.org>
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;;; Keywords: games
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;;; Created: June 6, 1998
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; any later version.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; Don't zone out in front of Emacs! Try M-x zone.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; If it eventually irritates you, try M-x zone-leave-me-alone.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; Bored by the zone pyrotechnics? Write your own! Add it to
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; `zone-programs'.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; WARNING: Not appropriate for Emacs sessions over modems or
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; computers as slow as mine.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; THANKS: Christopher Mayer, Scott Flinchbaugh, Rachel Kalmar,
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; Max Froumentin.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;;; Code:
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 (require 'timer)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 (require 'tabify)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 (eval-when-compile (require 'cl))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 (defvar zone-idle 20
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 "*Seconds to idle before zoning out.")
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; Vector of functions that zone out. `zone' will execute one of
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;; these functions, randomly chosen. The chosen function is invoked
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; in the *zone* buffer, which contains the text of the selected
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;; window. If the function loops, it *must* periodically check and
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; halt if `input-pending-p' is t (because quitting is disabled when
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;; Emacs idle timers are run).
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 (defvar zone-programs [
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 zone-pgm-jitter
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 zone-pgm-putz-with-case
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 zone-pgm-dissolve
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ; zone-pgm-explode
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 zone-pgm-whack-chars
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 zone-pgm-rotate
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 zone-pgm-rotate-LR-lockstep
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 zone-pgm-rotate-RL-lockstep
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 zone-pgm-rotate-LR-variable
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 zone-pgm-rotate-RL-variable
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 zone-pgm-drip
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 zone-pgm-drip-fretfully
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 zone-pgm-five-oclock-swan-dive
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 zone-pgm-martini-swan-dive
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 zone-pgm-paragraph-spaz
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 zone-pgm-stress
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ])
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 (defmacro zone-orig (&rest body)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 `(with-current-buffer (get 'zone 'orig-buffer)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ,@body))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 ;;;###autoload
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (defun zone ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 "Zone out, completely."
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (interactive)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
83 (let ((timer (get 'zone 'timer)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
84 (and (timerp timer) (cancel-timer timer)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
85 (put 'zone 'timer nil)
30592
fbdf4c1e1acf (zone, zone-pgm-stress): Don't use window-system.
Eli Zaretskii <eliz@gnu.org>
parents: 30565
diff changeset
86 (let ((f (selected-frame))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 (outbuf (get-buffer-create "*zone*"))
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
88 (text (buffer-substring (window-start) (window-end)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
89 (wp (1+ (- (window-point (selected-window))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
90 (window-start)))))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (put 'zone 'orig-buffer (current-buffer))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 (set-buffer outbuf)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 (setq mode-name "Zone")
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 (erase-buffer)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 (insert text)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 (switch-to-buffer outbuf)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 (setq buffer-undo-list t)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 (untabify (point-min) (point-max))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 (set-window-start (selected-window) (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (set-window-point (selected-window) wp)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 (sit-for 0 500)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 (let ((pgm (elt zone-programs (random (length zone-programs))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 (ct (and f (frame-parameter f 'cursor-type))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (when ct (modify-frame-parameters f '((cursor-type . (bar . 0)))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (condition-case nil
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
106 (progn
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 (message "Zoning... (%s)" pgm)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
108 (garbage-collect)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
109 ;; 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
110 ;; 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
111 ;; 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
112 ;; input before zoning out.
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
113 (if (input-pending-p)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
114 (discard-input))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
115 (funcall pgm)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
116 (message "Zoning...sorry"))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
117 (error
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
118 (while (not (input-pending-p))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
119 (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
120 (sit-for 3)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
121 (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
122 (sit-for 3)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
123 (quit (ding) (message "Zoning...sorry")))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (when ct (modify-frame-parameters f (list (cons 'cursor-type ct)))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (kill-buffer outbuf)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 (zone-when-idle zone-idle)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 ;;;; Zone when idle, or not.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (defun zone-when-idle (secs)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 "Zone out when Emacs has been idle for SECS seconds."
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (interactive "nHow long before I start zoning (seconds): ")
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 (or (<= secs 0)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
134 (let ((timer (get 'zone 'timer)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
135 (or (eq timer t)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
136 (timerp timer)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
137 (put 'zone 'timer (run-with-idle-timer secs t 'zone))))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (defun zone-leave-me-alone ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 "Don't zone out when Emacs is idle."
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (interactive)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
142 (let ((timer (get 'zone 'timer)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
143 (and (timerp timer) (cancel-timer timer)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
144 (put 'zone 'timer t)
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (message "I won't zone out any more"))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 ;;;; zone-pgm-jitter
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (defun zone-shift-up ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (let* ((b (point))
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
152 (e (progn
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
153 (end-of-line)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
154 (if (looking-at "\n") (1+ (point)) (point))))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
155 (s (buffer-substring b e)))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 (delete-region b e)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (goto-char (point-max))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 (insert s)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (defun zone-shift-down ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 (goto-char (point-max))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 (forward-line -1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 (beginning-of-line)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 (let* ((b (point))
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
165 (e (progn
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
166 (end-of-line)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
167 (if (looking-at "\n") (1+ (point)) (point))))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
168 (s (buffer-substring b e)))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 (delete-region b e)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 (goto-char (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 (insert s)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (defun zone-shift-left ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 (while (not (eobp))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 (or (eolp)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
176 (let ((c (following-char)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
177 (delete-char 1)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
178 (end-of-line)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
179 (insert c)))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (forward-line 1)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 (defun zone-shift-right ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (while (not (eobp))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 (end-of-line)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 (or (bolp)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
186 (let ((c (preceding-char)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
187 (delete-backward-char 1)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
188 (beginning-of-line)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
189 (insert c)))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 (forward-line 1)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 (defun zone-pgm-jitter ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 (let ((ops [
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 zone-shift-left
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 zone-shift-left
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 zone-shift-left
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 zone-shift-left
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 zone-shift-right
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 zone-shift-down
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 zone-shift-down
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 zone-shift-down
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 zone-shift-down
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 zone-shift-down
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 zone-shift-up
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 ]))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 (goto-char (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 (while (not (input-pending-p))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (funcall (elt ops (random (length ops))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (goto-char (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 (sit-for 0 10))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 ;;;; zone-pgm-whack-chars
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 (defun zone-pgm-whack-chars ()
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
216 (let ((tbl (copy-sequence (get 'zone-pgm-whack-chars 'wc-tbl))))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 (while (not (input-pending-p))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 (let ((i 48))
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
219 (while (< i 122)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
220 (aset tbl i (+ 48 (random (- 123 48))))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
221 (setq i (1+ i)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
222 (translate-region (point-min) (point-max) tbl)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
223 (sit-for 0 2)))))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
225 (put 'zone-pgm-whack-chars 'wc-tbl
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
226 (let ((tbl (make-string 128 ?x))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
227 (i 0))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
228 (while (< i 128)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
229 (aset tbl i i)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
230 (setq i (1+ i)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
231 tbl))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 ;;;; zone-pgm-dissolve
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 (defun zone-remove-text ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 (let ((working t))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (while working
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 (setq working nil)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (save-excursion
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
240 (goto-char (point-min))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
241 (while (not (eobp))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
242 (if (looking-at "[^(){}\n\t ]")
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
243 (let ((n (random 5)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
244 (if (not (= n 0))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
245 (progn
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
246 (setq working t)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
247 (forward-char 1))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
248 (delete-char 1)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
249 (insert " ")))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
250 (forward-char 1))))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 (sit-for 0 2))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 (defun zone-pgm-dissolve ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (zone-remove-text)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (zone-pgm-jitter))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 ;;;; zone-pgm-explode
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (defun zone-exploding-remove ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 (let ((i 0))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (while (< i 20)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (save-excursion
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
264 (goto-char (point-min))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
265 (while (not (eobp))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
266 (if (looking-at "[^*\n\t ]")
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
267 (let ((n (random 5)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
268 (if (not (= n 0))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
269 (forward-char 1))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
270 (insert " ")))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
271 (forward-char 1)))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (setq i (1+ i))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (sit-for 0 2)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (zone-pgm-jitter))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 (defun zone-pgm-explode ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (zone-exploding-remove)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 (zone-pgm-jitter))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 ;;;; zone-pgm-putz-with-case
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 ;; Faster than `zone-pgm-putz-with-case', but not as good: all
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 ;; instances of the same letter have the same case, which produces a
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 ;; less interesting effect than you might imagine.
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (defun zone-pgm-2nd-putz-with-case ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (let ((tbl (make-string 128 ?x))
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
288 (i 0))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (while (< i 128)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (aset tbl i i)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (setq i (1+ i)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (while (not (input-pending-p))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (setq i ?a)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (while (<= i ?z)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
295 (aset tbl i
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
296 (if (zerop (random 5))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
297 (upcase i)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
298 (downcase i)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
299 (setq i (+ i (1+ (random 5)))))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (setq i ?A)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (while (<= i ?z)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
302 (aset tbl i
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
303 (if (zerop (random 5))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
304 (downcase i)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
305 (upcase i)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
306 (setq i (+ i (1+ (random 5)))))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (translate-region (point-min) (point-max) tbl)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (sit-for 0 2))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (defun zone-pgm-putz-with-case ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (goto-char (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (while (not (input-pending-p))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (let ((np (+ 2 (random 5)))
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
314 (pm (point-max)))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (while (< np pm)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
316 (goto-char np)
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (let ((prec (preceding-char))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (props (text-properties-at (1- (point)))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 (insert (if (zerop (random 2))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (upcase prec)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (downcase prec)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 (set-text-properties (1- (point)) (point) props))
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
323 (backward-char 2)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
324 (delete-char 1)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
325 (setq np (+ np (1+ (random 5))))))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (goto-char (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 (sit-for 0 2)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 ;;;; zone-pgm-rotate
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 (defun zone-line-specs ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (let (ret)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (save-excursion
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (goto-char (window-start))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 (while (< (point) (window-end))
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
337 (when (looking-at "[\t ]*\\([^\n]+\\)")
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
338 (setq ret (cons (cons (match-beginning 1) (match-end 1)) ret)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
339 (forward-line 1)))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 ret))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (defun zone-pgm-rotate (&optional random-style)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (let* ((specs (apply
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
344 'vector
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (let (res)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 (mapcar (lambda (ent)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 (let* ((beg (car ent))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 (end (cdr ent))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (amt (if random-style
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (funcall random-style)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (- (random 7) 3))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 (when (< (- end (abs amt)) beg)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (setq amt (random (- end beg))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (unless (= 0 amt)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (setq res
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (cons
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (vector amt beg (- end (abs amt)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 res)))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (zone-line-specs))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 res)))
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
361 (n (length specs))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
362 amt aamt cut paste txt i ent)
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (while (not (input-pending-p))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (setq i 0)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (while (< i n)
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
366 (setq ent (aref specs i))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
367 (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
368 (if (> 0 amt)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
369 (setq cut 1 paste 2)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
370 (setq cut 2 paste 1))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
371 (goto-char (aref ent cut))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
372 (setq txt (buffer-substring (point) (+ (point) aamt)))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
373 (delete-char aamt)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
374 (goto-char (aref ent paste))
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
375 (insert txt)
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
376 (setq i (1+ i)))
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 (sit-for 0.04))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 (defun zone-pgm-rotate-LR-lockstep ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 (zone-pgm-rotate (lambda () 1)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (defun zone-pgm-rotate-RL-lockstep ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (zone-pgm-rotate (lambda () -1)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (defun zone-pgm-rotate-LR-variable ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 (zone-pgm-rotate (lambda () (1+ (random 3)))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (defun zone-pgm-rotate-RL-variable ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 (zone-pgm-rotate (lambda () (1- (- (random 3))))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 ;;;; zone-pgm-drip
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (defun zone-cpos (pos)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (buffer-substring pos (1+ pos)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (defun zone-fret (pos)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (let* ((case-fold-search nil)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (c-string (zone-cpos pos))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (hmm (cond
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 ((string-match "[a-z]" c-string) (upcase c-string))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 ((string-match "[A-Z]" c-string) (downcase c-string))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (t " "))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (do ((i 0 (1+ i))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (wait 0.5 (* wait 0.8)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 ((= i 20))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (goto-char pos)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (delete-char 1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (insert (if (= 0 (% i 2)) hmm c-string))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (sit-for wait))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (delete-char -1) (insert c-string)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 (defun zone-fall-through-ws (c col wend)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (let ((fall-p nil) ; todo: move outward
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 (wait 0.15)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 (o (point)) ; for terminals w/o cursor hiding
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 (p (point)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (while (progn
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 (forward-line 1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (move-to-column col)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (looking-at " "))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 (setq fall-p t)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 (delete-char 1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 (insert (if (< (point) wend) c " "))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (save-excursion
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (goto-char p)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (delete-char 1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (insert " ")
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (goto-char o)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (sit-for (setq wait (* wait 0.8))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 (setq p (1- (point))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 fall-p))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 (defun zone-pgm-drip (&optional fret-p pancake-p)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (let* ((ww (1- (window-width)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (wh (window-height))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (mc 0) ; miss count
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (total (* ww wh))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (fall-p nil))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (goto-char (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 ;; fill out rectangular ws block
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (while (not (eobp))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (end-of-line)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (let ((cc (current-column)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (if (< cc ww)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (insert (make-string (- ww cc) ? ))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (delete-char (- ww cc))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (unless (eobp)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (forward-char 1)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 ;; what the hell is going on here?
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (let ((nl (- wh (count-lines (point-min) (point)))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 (when (> nl 0)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (let ((line (concat (make-string (1- ww) ? ) "\n")))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (do ((i 0 (1+ i)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 ((= i nl))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 (insert line)))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 ;;
32348
abc299ad3386 (zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 30628
diff changeset
458 (catch 'done; ugh
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (while (not (input-pending-p))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (goto-char (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (sit-for 0)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (let ((wbeg (window-start))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 (wend (window-end)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (setq mc 0)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 ;; select non-ws character, but don't miss too much
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (goto-char (+ wbeg (random (- wend wbeg))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (while (looking-at "[ \n\f]")
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (if (= total (setq mc (1+ mc)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (throw 'done 'sel)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (goto-char (+ wbeg (random (- wend wbeg))))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 ;; character animation sequence
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (let ((p (point)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (when fret-p (zone-fret p))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (goto-char p)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (setq fall-p (zone-fall-through-ws
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (zone-cpos p) (current-column) wend))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 ;; assuming current-column has not changed...
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (when (and pancake-p
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 fall-p
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 (< (count-lines (point-min) (point))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 wh))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (previous-line 1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 (forward-char 1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (sit-for 0.137)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (delete-char -1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (insert "@")
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (sit-for 0.137)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (delete-char -1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (insert "*")
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (sit-for 0.137)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (delete-char -1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (insert "_"))))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 (defun zone-pgm-drip-fretfully ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (zone-pgm-drip t))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (defun zone-pgm-five-oclock-swan-dive ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 (zone-pgm-drip nil t))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (defun zone-pgm-martini-swan-dive ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (zone-pgm-drip t t))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 ;;;; zone-pgm-paragraph-spaz
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (defun zone-pgm-paragraph-spaz ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (if (memq (zone-orig major-mode) '(text-mode fundamental-mode))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (let ((fill-column fill-column)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (fc-min fill-column)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (fc-max fill-column)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (max-fc (1- (frame-width))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (while (sit-for 0.1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 (fill-paragraph 1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 (setq fill-column (+ fill-column (- (random 5) 2)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (when (< fill-column fc-min)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (setq fc-min fill-column))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (when (> fill-column max-fc)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (setq fill-column max-fc))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 (when (> fill-column fc-max)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (setq fc-max fill-column))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (message "Zoning... (zone-pgm-rotate)")
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 (zone-pgm-rotate)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 ;;;; zone-pgm-stress
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (defun zone-pgm-stress ()
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 (goto-char (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (let (lines bg m-fg m-bg)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (while (< (point) (point-max))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 (let ((p (point)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (forward-line 1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 (setq lines (cons (buffer-substring p (point)) lines))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (sit-for 5)
30592
fbdf4c1e1acf (zone, zone-pgm-stress): Don't use window-system.
Eli Zaretskii <eliz@gnu.org>
parents: 30565
diff changeset
535 (when (display-color-p)
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (setq bg (frame-parameter (selected-frame) 'background-color)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 m-fg (face-foreground 'modeline)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 m-bg (face-background 'modeline))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (set-face-foreground 'modeline bg)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 (set-face-background 'modeline bg))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (let ((msg "Zoning... (zone-pgm-stress)"))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (while (not (string= msg ""))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (message (setq msg (substring msg 1)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 (sit-for 0.05)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (while (not (input-pending-p))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (when (< 50 (random 100))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (goto-char (point-max))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (forward-line -1)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 (let ((kill-whole-line t))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (kill-line))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (goto-char (point-min))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (insert (nth (random (length lines)) lines)))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (message (concat (make-string (random (- (frame-width) 5)) ? ) "grrr"))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (sit-for 0.1))
30592
fbdf4c1e1acf (zone, zone-pgm-stress): Don't use window-system.
Eli Zaretskii <eliz@gnu.org>
parents: 30565
diff changeset
555 (when (display-color-p)
30565
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (set-face-foreground 'modeline m-fg)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (set-face-background 'modeline m-bg))))
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 (provide 'zone)
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560
338238ca63ce *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 ;;; zone.el ends here