aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThien-Thi Nguyen2000-10-10 01:59:17 +0000
committerThien-Thi Nguyen2000-10-10 01:59:17 +0000
commit930baf47868ef54656be63ef9d38803680d07a30 (patch)
treea3bafe3e9a6a36f3d637e76649b47df2ec4bbd46
parent5a430f9cb68c4e106bc55d9348d629d174e5f3b7 (diff)
downloademacs-930baf47868ef54656be63ef9d38803680d07a30.tar.gz
emacs-930baf47868ef54656be63ef9d38803680d07a30.zip
(zone-timer, zone-wc-tbl): Rework
these vars as symbol properties. (zone, zone-when-idle, zone-leave-me-alone, zone-pgm-whack-chars): Use new symbol properties.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/play/zone.el231
2 files changed, 118 insertions, 118 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6bd1ef21ea5..cec95234ca2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12000-10-09 Thien-Thi Nguyen <ttn@gnu.org> 12000-10-09 Thien-Thi Nguyen <ttn@gnu.org>
2 2
3 * play/zone.el (zone-timer, zone-wc-tbl): Rework
4 these vars as symbol properties.
5 (zone, zone-when-idle, zone-leave-me-alone,
6 zone-pgm-whack-chars): Use new symbol properties.
7
3 * battery.el (display-battery): Doc spelling fix. 8 * battery.el (display-battery): Doc spelling fix.
4 9
5 * vc.el (with-vc-file, edit-vc-file): Specify `indent-function' 10 * vc.el (with-vc-file, edit-vc-file): Specify `indent-function'
diff --git a/lisp/play/zone.el b/lisp/play/zone.el
index f0c5ded1b1d..87d69ac8709 100644
--- a/lisp/play/zone.el
+++ b/lisp/play/zone.el
@@ -44,8 +44,6 @@
44(require 'tabify) 44(require 'tabify)
45(eval-when-compile (require 'cl)) 45(eval-when-compile (require 'cl))
46 46
47(defvar zone-timer nil)
48
49(defvar zone-idle 20 47(defvar zone-idle 20
50 "*Seconds to idle before zoning out.") 48 "*Seconds to idle before zoning out.")
51 49
@@ -82,13 +80,14 @@
82(defun zone () 80(defun zone ()
83 "Zone out, completely." 81 "Zone out, completely."
84 (interactive) 82 (interactive)
85 (and (timerp zone-timer) (cancel-timer zone-timer)) 83 (let ((timer (get 'zone 'timer)))
86 (setq zone-timer nil) 84 (and (timerp timer) (cancel-timer timer)))
85 (put 'zone 'timer nil)
87 (let ((f (selected-frame)) 86 (let ((f (selected-frame))
88 (outbuf (get-buffer-create "*zone*")) 87 (outbuf (get-buffer-create "*zone*"))
89 (text (buffer-substring (window-start) (window-end))) 88 (text (buffer-substring (window-start) (window-end)))
90 (wp (1+ (- (window-point (selected-window)) 89 (wp (1+ (- (window-point (selected-window))
91 (window-start))))) 90 (window-start)))))
92 (put 'zone 'orig-buffer (current-buffer)) 91 (put 'zone 'orig-buffer (current-buffer))
93 (set-buffer outbuf) 92 (set-buffer outbuf)
94 (setq mode-name "Zone") 93 (setq mode-name "Zone")
@@ -104,47 +103,45 @@
104 (ct (and f (frame-parameter f 'cursor-type)))) 103 (ct (and f (frame-parameter f 'cursor-type))))
105 (when ct (modify-frame-parameters f '((cursor-type . (bar . 0))))) 104 (when ct (modify-frame-parameters f '((cursor-type . (bar . 0)))))
106 (condition-case nil 105 (condition-case nil
107 (progn 106 (progn
108 (message "Zoning... (%s)" pgm) 107 (message "Zoning... (%s)" pgm)
109 (garbage-collect) 108 (garbage-collect)
110 ;; If some input is pending, zone says "sorry", which 109 ;; If some input is pending, zone says "sorry", which
111 ;; isn't nice; this might happen e.g. when they invoke the 110 ;; isn't nice; this might happen e.g. when they invoke the
112 ;; game by clicking the menu bar. So discard any pending 111 ;; game by clicking the menu bar. So discard any pending
113 ;; input before zoning out. 112 ;; input before zoning out.
114 (if (input-pending-p) 113 (if (input-pending-p)
115 (discard-input)) 114 (discard-input))
116 (funcall pgm) 115 (funcall pgm)
117 (message "Zoning...sorry")) 116 (message "Zoning...sorry"))
118 (error 117 (error
119 (while (not (input-pending-p)) 118 (while (not (input-pending-p))
120 (message (format "We were zoning when we wrote %s..." pgm)) 119 (message (format "We were zoning when we wrote %s..." pgm))
121 (sit-for 3) 120 (sit-for 3)
122 (message "...here's hoping we didn't hose your buffer!") 121 (message "...here's hoping we didn't hose your buffer!")
123 (sit-for 3))) 122 (sit-for 3)))
124 (quit (ding) (message "Zoning...sorry"))) 123 (quit (ding) (message "Zoning...sorry")))
125 (when ct (modify-frame-parameters f (list (cons 'cursor-type ct))))) 124 (when ct (modify-frame-parameters f (list (cons 'cursor-type ct)))))
126 (kill-buffer outbuf) 125 (kill-buffer outbuf)
127 (zone-when-idle zone-idle))) 126 (zone-when-idle zone-idle)))
128 127
129;;;; Zone when idle, or not. 128;;;; Zone when idle, or not.
130 129
131(defvar zone-timer nil
132 "Timer that zone sets to triggle idle zoning out.
133If t, zone won't zone out.")
134
135(defun zone-when-idle (secs) 130(defun zone-when-idle (secs)
136 "Zone out when Emacs has been idle for SECS seconds." 131 "Zone out when Emacs has been idle for SECS seconds."
137 (interactive "nHow long before I start zoning (seconds): ") 132 (interactive "nHow long before I start zoning (seconds): ")
138 (or (<= secs 0) 133 (or (<= secs 0)
139 (eq zone-timer t) 134 (let ((timer (get 'zone 'timer)))
140 (timerp zone-timer) 135 (or (eq timer t)
141 (setq zone-timer (run-with-idle-timer secs t 'zone)))) 136 (timerp timer)))
137 (put 'zone 'timer (run-with-idle-timer secs t 'zone))))
142 138
143(defun zone-leave-me-alone () 139(defun zone-leave-me-alone ()
144 "Don't zone out when Emacs is idle." 140 "Don't zone out when Emacs is idle."
145 (interactive) 141 (interactive)
146 (and (timerp zone-timer) (cancel-timer zone-timer)) 142 (let ((timer (get 'zone 'timer)))
147 (setq zone-timer t) 143 (and (timerp timer) (cancel-timer timer)))
144 (put 'zone 'timer t)
148 (message "I won't zone out any more")) 145 (message "I won't zone out any more"))
149 146
150 147
@@ -152,10 +149,10 @@ If t, zone won't zone out.")
152 149
153(defun zone-shift-up () 150(defun zone-shift-up ()
154 (let* ((b (point)) 151 (let* ((b (point))
155 (e (progn 152 (e (progn
156 (end-of-line) 153 (end-of-line)
157 (if (looking-at "\n") (1+ (point)) (point)))) 154 (if (looking-at "\n") (1+ (point)) (point))))
158 (s (buffer-substring b e))) 155 (s (buffer-substring b e)))
159 (delete-region b e) 156 (delete-region b e)
160 (goto-char (point-max)) 157 (goto-char (point-max))
161 (insert s))) 158 (insert s)))
@@ -165,10 +162,10 @@ If t, zone won't zone out.")
165 (forward-line -1) 162 (forward-line -1)
166 (beginning-of-line) 163 (beginning-of-line)
167 (let* ((b (point)) 164 (let* ((b (point))
168 (e (progn 165 (e (progn
169 (end-of-line) 166 (end-of-line)
170 (if (looking-at "\n") (1+ (point)) (point)))) 167 (if (looking-at "\n") (1+ (point)) (point))))
171 (s (buffer-substring b e))) 168 (s (buffer-substring b e)))
172 (delete-region b e) 169 (delete-region b e)
173 (goto-char (point-min)) 170 (goto-char (point-min))
174 (insert s))) 171 (insert s)))
@@ -176,20 +173,20 @@ If t, zone won't zone out.")
176(defun zone-shift-left () 173(defun zone-shift-left ()
177 (while (not (eobp)) 174 (while (not (eobp))
178 (or (eolp) 175 (or (eolp)
179 (let ((c (following-char))) 176(let ((c (following-char)))
180 (delete-char 1) 177 (delete-char 1)
181 (end-of-line) 178 (end-of-line)
182 (insert c))) 179 (insert c)))
183 (forward-line 1))) 180 (forward-line 1)))
184 181
185(defun zone-shift-right () 182(defun zone-shift-right ()
186 (while (not (eobp)) 183 (while (not (eobp))
187 (end-of-line) 184 (end-of-line)
188 (or (bolp) 185 (or (bolp)
189 (let ((c (preceding-char))) 186(let ((c (preceding-char)))
190 (delete-backward-char 1) 187 (delete-backward-char 1)
191 (beginning-of-line) 188 (beginning-of-line)
192 (insert c))) 189 (insert c)))
193 (forward-line 1))) 190 (forward-line 1)))
194 191
195(defun zone-pgm-jitter () 192(defun zone-pgm-jitter ()
@@ -215,24 +212,23 @@ If t, zone won't zone out.")
215 212
216;;;; zone-pgm-whack-chars 213;;;; zone-pgm-whack-chars
217 214
218(defvar zone-wc-tbl
219 (let ((tbl (make-string 128 ?x))
220 (i 0))
221 (while (< i 128)
222 (aset tbl i i)
223 (setq i (1+ i)))
224 tbl))
225
226(defun zone-pgm-whack-chars () 215(defun zone-pgm-whack-chars ()
227 (let ((tbl (copy-sequence zone-wc-tbl))) 216 (let ((tbl (copy-sequence (get 'zone-pgm-whack-chars 'wc-tbl))))
228 (while (not (input-pending-p)) 217 (while (not (input-pending-p))
229 (let ((i 48)) 218 (let ((i 48))
230 (while (< i 122) 219(while (< i 122)
231 (aset tbl i (+ 48 (random (- 123 48)))) 220 (aset tbl i (+ 48 (random (- 123 48))))
232 (setq i (1+ i))) 221 (setq i (1+ i)))
233 (translate-region (point-min) (point-max) tbl) 222(translate-region (point-min) (point-max) tbl)
234 (sit-for 0 2))))) 223(sit-for 0 2)))))
235 224
225(put 'zone-pgm-whack-chars 'wc-tbl
226 (let ((tbl (make-string 128 ?x))
227 (i 0))
228 (while (< i 128)
229 (aset tbl i i)
230 (setq i (1+ i)))
231 tbl))
236 232
237;;;; zone-pgm-dissolve 233;;;; zone-pgm-dissolve
238 234
@@ -241,17 +237,17 @@ If t, zone won't zone out.")
241 (while working 237 (while working
242 (setq working nil) 238 (setq working nil)
243 (save-excursion 239 (save-excursion
244 (goto-char (point-min)) 240(goto-char (point-min))
245 (while (not (eobp)) 241(while (not (eobp))
246 (if (looking-at "[^(){}\n\t ]") 242 (if (looking-at "[^(){}\n\t ]")
247 (let ((n (random 5))) 243 (let ((n (random 5)))
248 (if (not (= n 0)) 244(if (not (= n 0))
249 (progn 245 (progn
250 (setq working t) 246 (setq working t)
251 (forward-char 1)) 247 (forward-char 1))
252 (delete-char 1) 248 (delete-char 1)
253 (insert " "))) 249 (insert " ")))
254 (forward-char 1)))) 250 (forward-char 1))))
255 (sit-for 0 2)))) 251 (sit-for 0 2))))
256 252
257(defun zone-pgm-dissolve () 253(defun zone-pgm-dissolve ()
@@ -265,14 +261,14 @@ If t, zone won't zone out.")
265 (let ((i 0)) 261 (let ((i 0))
266 (while (< i 20) 262 (while (< i 20)
267 (save-excursion 263 (save-excursion
268 (goto-char (point-min)) 264(goto-char (point-min))
269 (while (not (eobp)) 265(while (not (eobp))
270 (if (looking-at "[^*\n\t ]") 266 (if (looking-at "[^*\n\t ]")
271 (let ((n (random 5))) 267 (let ((n (random 5)))
272 (if (not (= n 0)) 268(if (not (= n 0))
273 (forward-char 1)) 269 (forward-char 1))
274 (insert " "))) 270 (insert " ")))
275 (forward-char 1))) 271 (forward-char 1)))
276 (setq i (1+ i)) 272 (setq i (1+ i))
277 (sit-for 0 2))) 273 (sit-for 0 2)))
278 (zone-pgm-jitter)) 274 (zone-pgm-jitter))
@@ -289,25 +285,25 @@ If t, zone won't zone out.")
289;; less interesting effect than you might imagine. 285;; less interesting effect than you might imagine.
290(defun zone-pgm-2nd-putz-with-case () 286(defun zone-pgm-2nd-putz-with-case ()
291 (let ((tbl (make-string 128 ?x)) 287 (let ((tbl (make-string 128 ?x))
292 (i 0)) 288(i 0))
293 (while (< i 128) 289 (while (< i 128)
294 (aset tbl i i) 290 (aset tbl i i)
295 (setq i (1+ i))) 291 (setq i (1+ i)))
296 (while (not (input-pending-p)) 292 (while (not (input-pending-p))
297 (setq i ?a) 293 (setq i ?a)
298 (while (<= i ?z) 294 (while (<= i ?z)
299 (aset tbl i 295(aset tbl i
300 (if (zerop (random 5)) 296 (if (zerop (random 5))
301 (upcase i) 297 (upcase i)
302 (downcase i))) 298(downcase i)))
303 (setq i (+ i (1+ (random 5))))) 299(setq i (+ i (1+ (random 5)))))
304 (setq i ?A) 300 (setq i ?A)
305 (while (<= i ?z) 301 (while (<= i ?z)
306 (aset tbl i 302(aset tbl i
307 (if (zerop (random 5)) 303 (if (zerop (random 5))
308 (downcase i) 304 (downcase i)
309 (upcase i))) 305(upcase i)))
310 (setq i (+ i (1+ (random 5))))) 306(setq i (+ i (1+ (random 5)))))
311 (translate-region (point-min) (point-max) tbl) 307 (translate-region (point-min) (point-max) tbl)
312 (sit-for 0 2)))) 308 (sit-for 0 2))))
313 309
@@ -315,18 +311,18 @@ If t, zone won't zone out.")
315 (goto-char (point-min)) 311 (goto-char (point-min))
316 (while (not (input-pending-p)) 312 (while (not (input-pending-p))
317 (let ((np (+ 2 (random 5))) 313 (let ((np (+ 2 (random 5)))
318 (pm (point-max))) 314 (pm (point-max)))
319 (while (< np pm) 315 (while (< np pm)
320 (goto-char np) 316(goto-char np)
321 (let ((prec (preceding-char)) 317 (let ((prec (preceding-char))
322 (props (text-properties-at (1- (point))))) 318 (props (text-properties-at (1- (point)))))
323 (insert (if (zerop (random 2)) 319 (insert (if (zerop (random 2))
324 (upcase prec) 320 (upcase prec)
325 (downcase prec))) 321 (downcase prec)))
326 (set-text-properties (1- (point)) (point) props)) 322 (set-text-properties (1- (point)) (point) props))
327 (backward-char 2) 323(backward-char 2)
328 (delete-char 1) 324(delete-char 1)
329 (setq np (+ np (1+ (random 5)))))) 325(setq np (+ np (1+ (random 5))))))
330 (goto-char (point-min)) 326 (goto-char (point-min))
331 (sit-for 0 2))) 327 (sit-for 0 2)))
332 328
@@ -338,14 +334,14 @@ If t, zone won't zone out.")
338 (save-excursion 334 (save-excursion
339 (goto-char (window-start)) 335 (goto-char (window-start))
340 (while (< (point) (window-end)) 336 (while (< (point) (window-end))
341 (when (looking-at "[\t ]*\\([^\n]+\\)") 337(when (looking-at "[\t ]*\\([^\n]+\\)")
342 (setq ret (cons (cons (match-beginning 1) (match-end 1)) ret))) 338 (setq ret (cons (cons (match-beginning 1) (match-end 1)) ret)))
343 (forward-line 1))) 339(forward-line 1)))
344 ret)) 340 ret))
345 341
346(defun zone-pgm-rotate (&optional random-style) 342(defun zone-pgm-rotate (&optional random-style)
347 (let* ((specs (apply 343 (let* ((specs (apply
348 'vector 344 'vector
349 (let (res) 345 (let (res)
350 (mapcar (lambda (ent) 346 (mapcar (lambda (ent)
351 (let* ((beg (car ent)) 347 (let* ((beg (car ent))
@@ -362,22 +358,22 @@ If t, zone won't zone out.")
362 res))))) 358 res)))))
363 (zone-line-specs)) 359 (zone-line-specs))
364 res))) 360 res)))
365 (n (length specs)) 361 (n (length specs))
366 amt aamt cut paste txt i ent) 362 amt aamt cut paste txt i ent)
367 (while (not (input-pending-p)) 363 (while (not (input-pending-p))
368 (setq i 0) 364 (setq i 0)
369 (while (< i n) 365 (while (< i n)
370 (setq ent (aref specs i)) 366 (setq ent (aref specs i))
371 (setq amt (aref ent 0) aamt (abs amt)) 367 (setq amt (aref ent 0) aamt (abs amt))
372 (if (> 0 amt) 368 (if (> 0 amt)
373 (setq cut 1 paste 2) 369 (setq cut 1 paste 2)
374 (setq cut 2 paste 1)) 370 (setq cut 2 paste 1))
375 (goto-char (aref ent cut)) 371 (goto-char (aref ent cut))
376 (setq txt (buffer-substring (point) (+ (point) aamt))) 372 (setq txt (buffer-substring (point) (+ (point) aamt)))
377 (delete-char aamt) 373 (delete-char aamt)
378 (goto-char (aref ent paste)) 374 (goto-char (aref ent paste))
379 (insert txt) 375 (insert txt)
380 (setq i (1+ i))) 376 (setq i (1+ i)))
381 (sit-for 0.04)))) 377 (sit-for 0.04))))
382 378
383(defun zone-pgm-rotate-LR-lockstep () 379(defun zone-pgm-rotate-LR-lockstep ()
@@ -459,7 +455,7 @@ If t, zone won't zone out.")
459 ((= i nl)) 455 ((= i nl))
460 (insert line))))) 456 (insert line)))))
461 ;; 457 ;;
462 (catch 'done ; ugh 458 (catch 'done; ugh
463 (while (not (input-pending-p)) 459 (while (not (input-pending-p))
464 (goto-char (point-min)) 460 (goto-char (point-min))
465 (sit-for 0) 461 (sit-for 0)
@@ -563,4 +559,3 @@ If t, zone won't zone out.")
563(provide 'zone) 559(provide 'zone)
564 560
565;;; zone.el ends here 561;;; zone.el ends here
566