/[emacs]/emacs/lisp/play/zone.el
ViewVC logotype

Diff of /emacs/lisp/play/zone.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by ttn, Thu Jan 10 22:09:54 2002 UTC revision 1.8.4.1 by miles, Fri Apr 4 06:20:31 2003 UTC
# Line 44  Line 44 
44  (require 'tabify)  (require 'tabify)
45  (eval-when-compile (require 'cl))  (eval-when-compile (require 'cl))
46    
47  (defvar zone-idle 20  (defvar zone-timer nil
48    "*Seconds to idle before zoning out.")    "The timer we use to decide when to zone out, or nil if none.")
49    
50  (defvar zone-timeout nil  (defvar zone-timeout nil
51    "*Seconds to timeout the zoning.    "*Seconds to timeout the zoning.
# Line 132  If the element is a function or a list o Line 132  If the element is a function or a list o
132  (defun zone ()  (defun zone ()
133    "Zone out, completely."    "Zone out, completely."
134    (interactive)    (interactive)
   (let ((timer (get 'zone 'timer)))  
     (and (timerp timer) (cancel-timer timer)))  
   (put 'zone 'timer nil)  
135    (let ((f (selected-frame))    (let ((f (selected-frame))
136          (outbuf (get-buffer-create "*zone*"))          (outbuf (get-buffer-create "*zone*"))
137          (text (buffer-substring (window-start) (window-end)))          (text (buffer-substring (window-start) (window-end)))
# Line 175  If the element is a function or a list o Line 172  If the element is a function or a list o
172             (sit-for 3)))             (sit-for 3)))
173          (quit (ding) (message "Zoning...sorry")))          (quit (ding) (message "Zoning...sorry")))
174        (when ct (modify-frame-parameters f (list (cons 'cursor-type ct)))))        (when ct (modify-frame-parameters f (list (cons 'cursor-type ct)))))
175      (kill-buffer outbuf)      (kill-buffer outbuf)))
     (zone-when-idle zone-idle)))  
176    
177  ;;;; Zone when idle, or not.  ;;;; Zone when idle, or not.
178    
179  (defun zone-when-idle (secs)  (defun zone-when-idle (secs)
180    "Zone out when Emacs has been idle for SECS seconds."    "Zone out when Emacs has been idle for SECS seconds."
181    (interactive "nHow long before I start zoning (seconds): ")    (interactive "nHow long before I start zoning (seconds): ")
182      (if (timerp zone-timer)
183          (cancel-timer zone-timer))
184      (setq zone-timer nil)
185    (or (<= secs 0)    (or (<= secs 0)
186        (let ((timer (get 'zone 'timer)))        (setq zone-timer (run-with-idle-timer secs t 'zone))))
         (or (eq timer t)  
             (timerp timer)))  
       (put 'zone 'timer (run-with-idle-timer secs t 'zone))))  
187    
188  (defun zone-leave-me-alone ()  (defun zone-leave-me-alone ()
189    "Don't zone out when Emacs is idle."    "Don't zone out when Emacs is idle."
190    (interactive)    (interactive)
191    (let ((timer (get 'zone 'timer)))    (if (timerp zone-timer)
192      (and (timerp timer) (cancel-timer timer)))        (cancel-timer zone-timer))
193    (put 'zone 'timer t)    (setq zone-timer nil)
194    (message "I won't zone out any more"))    (message "I won't zone out any more"))
195    
196    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.8.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26