annotate lisp/play/zone.el @ 30958:ec347dd209e8

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