Mercurial > emacs
annotate lisp/play/zone.el @ 95230:fa14617b247e
Delete unused variables and add casting for char *
throughout the file.
(fontset_font): Try the fallback fonts of the current fontset
before consulting the default fontset.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 23 May 2008 02:21:30 +0000 |
parents | 949bd6ad1ba4 |
children | a9dc0e7c3f2b |
rev | line source |
---|---|
30565 | 1 ;;; zone.el --- idle display hacks |
2 | |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64433
diff
changeset
|
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, |
79716 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
30565 | 5 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
6 ;; Author: Victor Zandy <zandy@cs.wisc.edu> |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
7 ;; Maintainer: Thien-Thi Nguyen <ttn@gnu.org> |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
8 ;; Keywords: games |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
9 ;; Created: June 6, 1998 |
30565 | 10 |
11 ;; This file is part of GNU Emacs. | |
12 | |
94675
949bd6ad1ba4
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
30565 | 14 ;; it under the terms of the GNU General Public License as published by |
94675
949bd6ad1ba4
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
949bd6ad1ba4
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; (at your option) any later version. |
30565 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94675
949bd6ad1ba4
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
30565 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; Don't zone out in front of Emacs! Try M-x zone. | |
29 ;; If it eventually irritates you, try M-x zone-leave-me-alone. | |
30 | |
31 ;; 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
|
32 ;; `zone-programs'. See `zone-call' for higher-ordered zoning. |
30565 | 33 |
34 ;; WARNING: Not appropriate for Emacs sessions over modems or | |
59000
ee201fcb86f7
Commentary munging; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58998
diff
changeset
|
35 ;; computers as slow as mine. |
30565 | 36 |
59000
ee201fcb86f7
Commentary munging; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58998
diff
changeset
|
37 ;; THANKS: Christopher Mayer, Scott Flinchbaugh, |
ee201fcb86f7
Commentary munging; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58998
diff
changeset
|
38 ;; Rachel Kalmar, Max Froumentin, Juri Linkov, |
ee201fcb86f7
Commentary munging; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58998
diff
changeset
|
39 ;; Luigi Panzeri, John Paul Wallington. |
30565 | 40 |
41 ;;; Code: | |
42 | |
43 (require 'timer) | |
44 (require 'tabify) | |
45 (eval-when-compile (require 'cl)) | |
46 | |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
47 (defvar zone-timer nil |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
48 "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
|
49 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
50 (defvar zone-timeout nil |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
51 "*Seconds to timeout the zoning. |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
52 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
|
53 |
30565 | 54 ;; Vector of functions that zone out. `zone' will execute one of |
55 ;; these functions, randomly chosen. The chosen function is invoked | |
56 ;; in the *zone* buffer, which contains the text of the selected | |
57 ;; window. If the function loops, it *must* periodically check and | |
58 ;; halt if `input-pending-p' is t (because quitting is disabled when | |
59 ;; Emacs idle timers are run). | |
60 (defvar zone-programs [ | |
61 zone-pgm-jitter | |
62 zone-pgm-putz-with-case | |
63 zone-pgm-dissolve | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
64 ;; zone-pgm-explode |
30565 | 65 zone-pgm-whack-chars |
66 zone-pgm-rotate | |
67 zone-pgm-rotate-LR-lockstep | |
68 zone-pgm-rotate-RL-lockstep | |
69 zone-pgm-rotate-LR-variable | |
70 zone-pgm-rotate-RL-variable | |
71 zone-pgm-drip | |
72 zone-pgm-drip-fretfully | |
73 zone-pgm-five-oclock-swan-dive | |
74 zone-pgm-martini-swan-dive | |
82823
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
75 zone-pgm-rat-race |
30565 | 76 zone-pgm-paragraph-spaz |
77 zone-pgm-stress | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
78 zone-pgm-stress-destress |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
79 zone-pgm-random-life |
30565 | 80 ]) |
81 | |
82 (defmacro zone-orig (&rest body) | |
83 `(with-current-buffer (get 'zone 'orig-buffer) | |
84 ,@body)) | |
85 | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
86 (defmacro zone-hiding-modeline (&rest body) |
84982
0bb1eda0b839
(zone-hiding-modeline): Use mode-line-format.
Richard M. Stallman <rms@gnu.org>
parents:
84916
diff
changeset
|
87 ;; This formerly worked by temporarily altering face `mode-line', |
0bb1eda0b839
(zone-hiding-modeline): Use mode-line-format.
Richard M. Stallman <rms@gnu.org>
parents:
84916
diff
changeset
|
88 ;; which did not even work right, it seems. |
0bb1eda0b839
(zone-hiding-modeline): Use mode-line-format.
Richard M. Stallman <rms@gnu.org>
parents:
84916
diff
changeset
|
89 `(let (mode-line-format) |
0bb1eda0b839
(zone-hiding-modeline): Use mode-line-format.
Richard M. Stallman <rms@gnu.org>
parents:
84916
diff
changeset
|
90 ,@body)) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
91 |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
92 (defun zone-call (program &optional timeout) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
93 "Call PROGRAM in a zoned way. |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
94 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
|
95 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
|
96 if unspecified, q.v. |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
97 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
|
98 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
|
99 apply `zone-call' recursively." |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
100 (cond ((functionp program) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
101 (with-timeout ((or timeout zone-timeout (ash 1 26))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
102 (funcall program))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
103 ((listp program) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
104 (mapcar (lambda (elem) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
105 (cond ((functionp elem) (zone-call elem)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
106 ((and (listp elem) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
107 (functionp (car elem)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
108 (numberp (cadr elem))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
109 (apply 'zone-call elem)) |
53856
ac105516179d
(zone-call): Fix format string.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
110 (t (error "bad `zone-call' elem: %S" elem)))) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
111 program)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
112 |
30565 | 113 ;;;###autoload |
114 (defun zone () | |
115 "Zone out, completely." | |
116 (interactive) | |
65878
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
117 (save-window-excursion |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
118 (let ((f (selected-frame)) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
119 (outbuf (get-buffer-create "*zone*")) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
120 (text (buffer-substring (window-start) (window-end))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
121 (wp (1+ (- (window-point (selected-window)) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
122 (window-start))))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
123 (put 'zone 'orig-buffer (current-buffer)) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
124 (put 'zone 'modeline-hidden-level 0) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
125 (switch-to-buffer outbuf) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
126 (setq mode-name "Zone") |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
127 (erase-buffer) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
128 (setq buffer-undo-list t |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
129 truncate-lines t |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
130 tab-width (zone-orig tab-width) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
131 line-spacing (zone-orig line-spacing)) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
132 (insert text) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
133 (untabify (point-min) (point-max)) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
134 (set-window-start (selected-window) (point-min)) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
135 (set-window-point (selected-window) wp) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
136 (sit-for 0 500) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
137 (let ((pgm (elt zone-programs (random (length zone-programs)))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
138 (ct (and f (frame-parameter f 'cursor-type))) |
84996
a4806daa82af
(zone): Let-bind show-trailing-whitespace to nil.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
84982
diff
changeset
|
139 (show-trailing-whitespace nil) |
65878
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
140 (restore (list '(kill-buffer outbuf)))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
141 (when ct |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
142 (modify-frame-parameters f '((cursor-type . (bar . 0)))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
143 (setq restore (cons '(modify-frame-parameters |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
144 f (list (cons 'cursor-type ct))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
145 restore))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
146 ;; Make `restore' a self-disabling one-shot thunk. |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
147 (setq restore `(lambda () ,@restore (setq restore nil))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
148 (condition-case nil |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
149 (progn |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
150 (message "Zoning... (%s)" pgm) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
151 (garbage-collect) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
152 ;; If some input is pending, zone says "sorry", which |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
153 ;; isn't nice; this might happen e.g. when they invoke the |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
154 ;; game by clicking the menu bar. So discard any pending |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
155 ;; input before zoning out. |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
156 (if (input-pending-p) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
157 (discard-input)) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
158 (zone-call pgm) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
159 (message "Zoning...sorry")) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
160 (error |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
161 (funcall restore) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
162 (while (not (input-pending-p)) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
163 (message "We were zoning when we wrote %s..." pgm) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
164 (sit-for 3) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
165 (message "...here's hoping we didn't hose your buffer!") |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
166 (sit-for 3))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
167 (quit |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
168 (funcall restore) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
169 (ding) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
170 (message "Zoning...sorry"))) |
011947140bc7
(zone): Wrap body with save-window-excursion.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65585
diff
changeset
|
171 (when restore (funcall restore)))))) |
30565 | 172 |
173 ;;;; Zone when idle, or not. | |
174 | |
175 (defun zone-when-idle (secs) | |
176 "Zone out when Emacs has been idle for SECS seconds." | |
177 (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
|
178 (if (timerp zone-timer) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
179 (cancel-timer zone-timer)) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
180 (setq zone-timer nil) |
30565 | 181 (or (<= secs 0) |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
182 (setq zone-timer (run-with-idle-timer secs t 'zone)))) |
30565 | 183 |
184 (defun zone-leave-me-alone () | |
185 "Don't zone out when Emacs is idle." | |
186 (interactive) | |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
187 (if (timerp zone-timer) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
188 (cancel-timer zone-timer)) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
189 (setq zone-timer nil) |
30565 | 190 (message "I won't zone out any more")) |
191 | |
192 | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
193 ;;;; jittering |
30565 | 194 |
195 (defun zone-shift-up () | |
196 (let* ((b (point)) | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
197 (e (progn (forward-line 1) (point))) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
198 (s (buffer-substring b e))) |
30565 | 199 (delete-region b e) |
200 (goto-char (point-max)) | |
201 (insert s))) | |
202 | |
203 (defun zone-shift-down () | |
204 (goto-char (point-max)) | |
205 (let* ((b (point)) | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
206 (e (progn (forward-line -1) (point))) |
42645
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-min)) | |
210 (insert s))) | |
211 | |
212 (defun zone-shift-left () | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
213 (let (s) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
214 (while (not (eobp)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
215 (unless (eolp) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
216 (setq s (buffer-substring (point) (1+ (point)))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
217 (delete-char 1) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
218 (end-of-line) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
219 (insert s)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
220 (forward-char 1)))) |
30565 | 221 |
222 (defun zone-shift-right () | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
223 (goto-char (point-max)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
224 (end-of-line) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
225 (let (s) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
226 (while (not (bobp)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
227 (unless (bolp) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
228 (setq s (buffer-substring (1- (point)) (point))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
229 (delete-char -1) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
230 (beginning-of-line) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
231 (insert s)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
232 (end-of-line 0)))) |
30565 | 233 |
234 (defun zone-pgm-jitter () | |
235 (let ((ops [ | |
236 zone-shift-left | |
237 zone-shift-right | |
238 zone-shift-down | |
239 zone-shift-up | |
240 ])) | |
241 (goto-char (point-min)) | |
242 (while (not (input-pending-p)) | |
243 (funcall (elt ops (random (length ops)))) | |
244 (goto-char (point-min)) | |
245 (sit-for 0 10)))) | |
246 | |
247 | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
248 ;;;; whacking chars |
30565 | 249 |
250 (defun zone-pgm-whack-chars () | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
251 (let ((tbl (copy-sequence (get 'zone-pgm-whack-chars 'wc-tbl)))) |
30565 | 252 (while (not (input-pending-p)) |
253 (let ((i 48)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
254 (while (< i 122) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
255 (aset tbl i (+ 48 (random (- 123 48)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
256 (setq i (1+ i))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
257 (translate-region (point-min) (point-max) tbl) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
258 (sit-for 0 2))))) |
30565 | 259 |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
260 (put 'zone-pgm-whack-chars 'wc-tbl |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
261 (let ((tbl (make-string 128 ?x)) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
262 (i 0)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
263 (while (< i 128) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
264 (aset tbl i i) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
265 (setq i (1+ i))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
266 tbl)) |
30565 | 267 |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
268 ;;;; dissolving |
30565 | 269 |
270 (defun zone-remove-text () | |
271 (let ((working t)) | |
272 (while working | |
273 (setq working nil) | |
274 (save-excursion | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
275 (goto-char (point-min)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
276 (while (not (eobp)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
277 (if (looking-at "[^(){}\n\t ]") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
278 (let ((n (random 5))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
279 (if (not (= n 0)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
280 (progn |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
281 (setq working t) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
282 (forward-char 1)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
283 (delete-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
284 (insert " "))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
285 (forward-char 1)))) |
30565 | 286 (sit-for 0 2)))) |
287 | |
288 (defun zone-pgm-dissolve () | |
289 (zone-remove-text) | |
290 (zone-pgm-jitter)) | |
291 | |
292 | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
293 ;;;; exploding |
30565 | 294 |
295 (defun zone-exploding-remove () | |
296 (let ((i 0)) | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
297 (while (< i 5) |
30565 | 298 (save-excursion |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
299 (goto-char (point-min)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
300 (while (not (eobp)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
301 (if (looking-at "[^*\n\t ]") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
302 (let ((n (random 5))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
303 (if (not (= n 0)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
304 (forward-char 1)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
305 (insert " "))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
306 (forward-char 1))) |
30565 | 307 (setq i (1+ i)) |
308 (sit-for 0 2))) | |
309 (zone-pgm-jitter)) | |
310 | |
311 (defun zone-pgm-explode () | |
312 (zone-exploding-remove) | |
313 (zone-pgm-jitter)) | |
314 | |
315 | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
316 ;;;; putzing w/ case |
30565 | 317 |
318 ;; Faster than `zone-pgm-putz-with-case', but not as good: all | |
319 ;; instances of the same letter have the same case, which produces a | |
320 ;; less interesting effect than you might imagine. | |
321 (defun zone-pgm-2nd-putz-with-case () | |
322 (let ((tbl (make-string 128 ?x)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
323 (i 0)) |
30565 | 324 (while (< i 128) |
325 (aset tbl i i) | |
326 (setq i (1+ i))) | |
327 (while (not (input-pending-p)) | |
328 (setq i ?a) | |
329 (while (<= i ?z) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
330 (aset tbl i |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
331 (if (zerop (random 5)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
332 (upcase i) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
333 (downcase i))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
334 (setq i (+ i (1+ (random 5))))) |
30565 | 335 (setq i ?A) |
336 (while (<= i ?z) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
337 (aset tbl i |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
338 (if (zerop (random 5)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
339 (downcase i) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
340 (upcase i))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
341 (setq i (+ i (1+ (random 5))))) |
30565 | 342 (translate-region (point-min) (point-max) tbl) |
343 (sit-for 0 2)))) | |
344 | |
345 (defun zone-pgm-putz-with-case () | |
346 (goto-char (point-min)) | |
347 (while (not (input-pending-p)) | |
348 (let ((np (+ 2 (random 5))) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
349 (pm (point-max))) |
30565 | 350 (while (< np pm) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
351 (goto-char np) |
30565 | 352 (let ((prec (preceding-char)) |
353 (props (text-properties-at (1- (point))))) | |
354 (insert (if (zerop (random 2)) | |
355 (upcase prec) | |
356 (downcase prec))) | |
357 (set-text-properties (1- (point)) (point) props)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
358 (backward-char 2) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
359 (delete-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
360 (setq np (+ np (1+ (random 5)))))) |
30565 | 361 (goto-char (point-min)) |
362 (sit-for 0 2))) | |
363 | |
364 | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
365 ;;;; rotating |
30565 | 366 |
367 (defun zone-line-specs () | |
368 (let (ret) | |
369 (save-excursion | |
370 (goto-char (window-start)) | |
371 (while (< (point) (window-end)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
372 (when (looking-at "[\t ]*\\([^\n]+\\)") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
373 (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
|
374 (forward-line 1))) |
30565 | 375 ret)) |
376 | |
377 (defun zone-pgm-rotate (&optional random-style) | |
378 (let* ((specs (apply | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
379 'vector |
30565 | 380 (let (res) |
84916
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
381 (mapc (lambda (ent) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
382 (let* ((beg (car ent)) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
383 (end (cdr ent)) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
384 (amt (if random-style |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
385 (funcall random-style) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
386 (- (random 7) 3)))) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
387 (when (< (- end (abs amt)) beg) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
388 (setq amt (random (- end beg)))) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
389 (unless (= 0 amt) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
390 (setq res |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
391 (cons |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
392 (vector amt beg (- end (abs amt))) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
393 res))))) |
e41433198a1b
(zone-pgm-rotate): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82823
diff
changeset
|
394 (zone-line-specs)) |
30565 | 395 res))) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
396 (n (length specs)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
397 amt aamt cut paste txt i ent) |
30565 | 398 (while (not (input-pending-p)) |
399 (setq i 0) | |
400 (while (< i n) | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
401 (setq ent (aref specs i)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
402 (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
|
403 (if (> 0 amt) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
404 (setq cut 1 paste 2) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
405 (setq cut 2 paste 1)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
406 (goto-char (aref ent cut)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
407 (setq txt (buffer-substring (point) (+ (point) aamt))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
408 (delete-char aamt) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
409 (goto-char (aref ent paste)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
410 (insert txt) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
411 (setq i (1+ i))) |
30565 | 412 (sit-for 0.04)))) |
413 | |
414 (defun zone-pgm-rotate-LR-lockstep () | |
415 (zone-pgm-rotate (lambda () 1))) | |
416 | |
417 (defun zone-pgm-rotate-RL-lockstep () | |
418 (zone-pgm-rotate (lambda () -1))) | |
419 | |
420 (defun zone-pgm-rotate-LR-variable () | |
421 (zone-pgm-rotate (lambda () (1+ (random 3))))) | |
422 | |
423 (defun zone-pgm-rotate-RL-variable () | |
424 (zone-pgm-rotate (lambda () (1- (- (random 3)))))) | |
425 | |
426 | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
427 ;;;; dripping |
30565 | 428 |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
429 (defsubst zone-cpos (pos) |
30565 | 430 (buffer-substring pos (1+ pos))) |
431 | |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
432 (defsubst zone-replace-char (count del-count char-as-string new-value) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
433 (delete-char (or del-count (- count))) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
434 (aset char-as-string 0 new-value) |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
435 (dotimes (i count) (insert char-as-string))) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
436 |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
437 (defsubst zone-park/sit-for (pos seconds) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
438 (let ((p (point))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
439 (goto-char pos) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
440 (prog1 (sit-for seconds) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
441 (goto-char p)))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
442 |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
443 (defun zone-fret (wbeg pos) |
30565 | 444 (let* ((case-fold-search nil) |
445 (c-string (zone-cpos pos)) | |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
446 (cw-ceil (ceiling (char-width (aref c-string 0)))) |
30565 | 447 (hmm (cond |
448 ((string-match "[a-z]" c-string) (upcase c-string)) | |
449 ((string-match "[A-Z]" c-string) (downcase c-string)) | |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
450 (t (propertize " " 'display `(space :width ,cw-ceil)))))) |
30565 | 451 (do ((i 0 (1+ i)) |
452 (wait 0.5 (* wait 0.8))) | |
453 ((= i 20)) | |
454 (goto-char pos) | |
455 (delete-char 1) | |
456 (insert (if (= 0 (% i 2)) hmm c-string)) | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
457 (zone-park/sit-for wbeg wait)) |
30565 | 458 (delete-char -1) (insert c-string))) |
459 | |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
460 (defun zone-fill-out-screen (width height) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
461 (let ((start (window-start)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
462 (line (make-string width 32))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
463 (goto-char start) |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
464 ;; fill out rectangular ws block |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
465 (while (progn (end-of-line) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
466 (let ((cc (current-column))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
467 (if (< cc width) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
468 (insert (substring line cc)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
469 (delete-char (- width cc))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
470 (cond ((eobp) (insert "\n") nil) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
471 (t (forward-char 1) t))))) |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
472 ;; pad ws past bottom of screen |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
473 (let ((nl (- height (count-lines (point-min) (point))))) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
474 (when (> nl 0) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
475 (setq line (concat line "\n")) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
476 (do ((i 0 (1+ i))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
477 ((= i nl)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
478 (insert line)))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
479 (goto-char start) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
480 (recenter 0) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
481 (sit-for 0))) |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
482 |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
483 (defun zone-fall-through-ws (c wbeg wend) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
484 (let* ((cw-ceil (ceiling (char-width (aref c 0)))) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
485 (spaces (make-string cw-ceil 32)) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
486 (col (current-column)) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
487 (wait 0.15) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
488 newpos fall-p) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
489 (while (when (save-excursion |
85478
786d3a985758
* term/x-win.el (x-gtk-stock-map, icon-map-list)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84996
diff
changeset
|
490 (forward-line 1) |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
491 (and (= col (current-column)) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
492 (setq newpos (point)) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
493 (string= spaces (buffer-substring-no-properties |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
494 newpos (+ newpos cw-ceil))) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
495 (setq newpos (+ newpos (1- cw-ceil))))) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
496 (setq fall-p t) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
497 (delete-char 1) |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
498 (insert spaces) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
499 (goto-char newpos) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
500 (when (< (point) wend) |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
501 (delete-char cw-ceil) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
502 (insert c) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
503 (forward-char -1) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
504 (zone-park/sit-for wbeg (setq wait (* wait 0.8)))))) |
30565 | 505 fall-p)) |
506 | |
507 (defun zone-pgm-drip (&optional fret-p pancake-p) | |
508 (let* ((ww (1- (window-width))) | |
509 (wh (window-height)) | |
510 (mc 0) ; miss count | |
511 (total (* ww wh)) | |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
512 (fall-p nil) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
513 wbeg wend c) |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
514 (zone-fill-out-screen ww wh) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
515 (setq wbeg (window-start) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
516 wend (window-end)) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
517 (catch 'done |
30565 | 518 (while (not (input-pending-p)) |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
519 (setq mc 0 wend (window-end)) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
520 ;; select non-ws character, but don't miss too much |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
521 (goto-char (+ wbeg (random (- wend wbeg)))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
522 (while (looking-at "[ \n\f]") |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
523 (if (= total (setq mc (1+ mc))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
524 (throw 'done 'sel) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
525 (goto-char (+ wbeg (random (- wend wbeg)))))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
526 ;; character animation sequence |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
527 (let ((p (point))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
528 (when fret-p (zone-fret wbeg p)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
529 (goto-char p) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
530 (setq c (zone-cpos p) |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
531 fall-p (zone-fall-through-ws c wbeg wend))) |
30565 | 532 ;; assuming current-column has not changed... |
533 (when (and pancake-p | |
534 fall-p | |
535 (< (count-lines (point-min) (point)) | |
536 wh)) | |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
537 (let ((cw (ceiling (char-width (aref c 0))))) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
538 (zone-replace-char cw 1 c ?@) (zone-park/sit-for wbeg 0.137) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
539 (zone-replace-char cw nil c ?*) (zone-park/sit-for wbeg 0.137) |
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
540 (zone-replace-char cw nil c ?_))))))) |
30565 | 541 |
542 (defun zone-pgm-drip-fretfully () | |
543 (zone-pgm-drip t)) | |
544 | |
545 (defun zone-pgm-five-oclock-swan-dive () | |
546 (zone-pgm-drip nil t)) | |
547 | |
548 (defun zone-pgm-martini-swan-dive () | |
549 (zone-pgm-drip t t)) | |
550 | |
82823
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
551 (defun zone-pgm-rat-race () |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
552 (while (not (input-pending-p)) |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
553 (zone-call '((zone-pgm-rotate 10) |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
554 (zone-pgm-drip-fretfully 15) |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
555 (zone-pgm-drip 10) |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
556 ((lambda () |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
557 (goto-char (point-min)) |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
558 (while (re-search-forward " +$" nil t) |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
559 (delete-region (match-beginning 0) (match-end 0)))) |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
560 5))))) |
ee04117a2f17
(zone-pgm-rat-race): New func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78227
diff
changeset
|
561 |
30565 | 562 |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
563 ;;;; paragraph spazzing (for textish modes) |
30565 | 564 |
565 (defun zone-pgm-paragraph-spaz () | |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
566 (if (memq (zone-orig major-mode) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
567 ;; there should be a better way to distinguish textish modes |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
568 '(text-mode texinfo-mode fundamental-mode)) |
30565 | 569 (let ((fill-column fill-column) |
570 (fc-min fill-column) | |
571 (fc-max fill-column) | |
572 (max-fc (1- (frame-width)))) | |
573 (while (sit-for 0.1) | |
574 (fill-paragraph 1) | |
575 (setq fill-column (+ fill-column (- (random 5) 2))) | |
576 (when (< fill-column fc-min) | |
577 (setq fc-min fill-column)) | |
578 (when (> fill-column max-fc) | |
579 (setq fill-column max-fc)) | |
580 (when (> fill-column fc-max) | |
581 (setq fc-max fill-column)))) | |
582 (message "Zoning... (zone-pgm-rotate)") | |
583 (zone-pgm-rotate))) | |
584 | |
585 | |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
586 ;;;; stressing and destressing |
30565 | 587 |
588 (defun zone-pgm-stress () | |
589 (goto-char (point-min)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
590 (let (lines) |
30565 | 591 (while (< (point) (point-max)) |
592 (let ((p (point))) | |
593 (forward-line 1) | |
594 (setq lines (cons (buffer-substring p (point)) lines)))) | |
595 (sit-for 5) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
596 (zone-hiding-modeline |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
597 (let ((msg "Zoning... (zone-pgm-stress)")) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
598 (while (not (string= msg "")) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
599 (message (setq msg (substring msg 1))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
600 (sit-for 0.05))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
601 (while (not (input-pending-p)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
602 (when (< 50 (random 100)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
603 (goto-char (point-max)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
604 (forward-line -1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
605 (let ((kill-whole-line t)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
606 (kill-line)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
607 (goto-char (point-min)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
608 (insert (nth (random (length lines)) lines))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
609 (message (concat (make-string (random (- (frame-width) 5)) ? ) "grrr")) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
610 (sit-for 0.1))))) |
38677
7177c6c2aaba
(zone-pgm-stress): Use unwind-protect to make sure
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
611 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
612 (defun zone-pgm-stress-destress () |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
613 (zone-call 'zone-pgm-stress 25) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
614 (zone-hiding-modeline |
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 (erase-buffer) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
617 (sit-for 3) |
64433
e0e9bea5acc5
(zone-pgm-stress-destress): Use `insert-buffer-substring', not `insert-buffer'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
618 (insert-buffer-substring "*Messages*") |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
619 (message "") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
620 (goto-char (point-max)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
621 (recenter -1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
622 (sit-for 3) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
623 (delete-region (point-min) (window-start)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
624 (message "hey why stress out anyway?") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
625 (zone-call '((zone-pgm-rotate 30) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
626 (zone-pgm-whack-chars 10) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
627 zone-pgm-drip)))) |
30565 | 628 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
629 |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
630 ;;;; the lyfe so short the craft so long to lerne --chaucer |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
631 |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
632 (defvar zone-pgm-random-life-wait nil |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
633 "*Seconds to wait between successive `life' generations. |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
634 If nil, `zone-pgm-random-life' chooses a value from 0-3 (inclusive).") |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
635 |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
636 (defun zone-pgm-random-life () |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
637 (require 'life) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
638 (zone-fill-out-screen (1- (window-width)) (1- (window-height))) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
639 (let ((top (progn (goto-char (window-start)) (forward-line 7) (point))) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
640 (bot (progn (goto-char (window-end)) (forward-line -7) (point))) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
641 (rtc (- (frame-width) 11)) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
642 (min (window-start)) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
643 (max (1- (window-end))) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
644 s c col) |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
645 (delete-region max (point-max)) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
646 (while (and (progn (goto-char min) (sit-for 0.05)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
647 (progn (goto-char (+ min (random max))) |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
648 (or (progn (skip-chars-forward " @\n" max) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
649 (not (= max (point)))) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
650 (unless (or (= 0 (skip-chars-backward " @\n" min)) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
651 (= min (point))) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
652 (forward-char -1) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
653 t)))) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
654 (unless (or (eolp) (eobp)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
655 (setq s (zone-cpos (point)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
656 c (aref s 0)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
657 (zone-replace-char |
59013
811c3c23099a
(zone): Init `line-spacing' from orig buffer.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59000
diff
changeset
|
658 (char-width c) |
59015
34b8a83e2361
(zone-pgm-random-life): Fix typo.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
59013
diff
changeset
|
659 1 s (cond ((or (> top (point)) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
660 (< bot (point)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
661 (or (> 11 (setq col (current-column))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
662 (< rtc col))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
663 32) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
664 ((and (<= ?a c) (>= ?z c)) (+ c (- ?A ?a))) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
665 ((and (<= ?A c) (>= ?Z c)) ?*) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
666 (t ?@))))) |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
667 (sit-for 3) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
668 (setq col nil) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
669 (goto-char bot) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
670 (while (< top (point)) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
671 (setq c (point)) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
672 (move-to-column 9) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
673 (setq col (cons (buffer-substring (point) c) col)) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
674 (end-of-line 0) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
675 (forward-char -10)) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
676 (let ((life-patterns (vector |
58998
dd8c66d7733c
(zone): Fix omission bug: Use a self-disabling
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58979
diff
changeset
|
677 (if (and col (search-forward "@" max t)) |
58978
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
678 (cons (make-string (length (car col)) 32) col) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
679 (list (mapconcat 'identity |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
680 (make-list (/ (- rtc 11) 15) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
681 (make-string 5 ?@)) |
848f5e78398e
(zone): Set `truncate-lines'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
58889
diff
changeset
|
682 (make-string 10 32))))))) |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
683 (life (or zone-pgm-random-life-wait (random 4))) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
684 (kill-buffer nil)))) |
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
685 |
84996
a4806daa82af
(zone): Let-bind show-trailing-whitespace to nil.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
84982
diff
changeset
|
686 |
76953 | 687 (random t) |
58889
f3d97fc520ff
(zone-programs): Add `zone-pgm-random-life'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53856
diff
changeset
|
688 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
689 ;;;;;;;;;;;;;;; |
30565 | 690 (provide 'zone) |
691 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
692 ;; arch-tag: 7092503d-74a9-4325-a55c-a026ede58cea |
30565 | 693 ;;; zone.el ends here |