annotate lisp/play/zone.el @ 112278:ef719132ddfa

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