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