Function: zone
zone is an autoloaded, interactive and byte-compiled function defined
in zone.el.gz.
Signature
(zone &optional PGM)
Documentation
Zone out, completely.
With a prefix argument the user is prompted for a program to run.
When called from Lisp the optional argument PGM can be used to
run a specific program. The program must be a member of
zone-programs.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/play/zone.el.gz
;;;###autoload
(defun zone (&optional pgm)
"Zone out, completely.
With a prefix argument the user is prompted for a program to run.
When called from Lisp the optional argument PGM can be used to
run a specific program. The program must be a member of
`zone-programs'."
(interactive
(and current-prefix-arg
(let ((choice (completing-read
"Program: "
(mapcar
(lambda (prog)
(substring (symbol-name prog) 9))
zone-programs)
nil t)))
(list (intern (concat "zone-pgm-" choice))))))
(unless pgm
(setq pgm (aref zone-programs (random (length zone-programs)))))
(save-window-excursion
(let ((f (selected-frame))
(outbuf (get-buffer-create "*zone*"))
(text (buffer-substring (window-start) (window-end nil t)))
(wp (1+ (- (window-point)
(window-start)))))
(put 'zone 'orig-buffer (current-buffer))
(switch-to-buffer outbuf)
(setq mode-name "Zone")
(erase-buffer)
(setq buffer-undo-list t
truncate-lines t
tab-width (zone-orig tab-width)
line-spacing (zone-orig line-spacing))
(insert text)
(untabify (point-min) (point-max))
(set-window-start (selected-window) (point-min))
(set-window-point (selected-window) wp)
(sit-for 0.500)
(let ((ct (and f (frame-parameter f 'cursor-type)))
(show-trailing-whitespace nil)
restore)
(when ct
(modify-frame-parameters f '((cursor-type . (bar . 0)))))
;; Make `restore' a self-disabling one-shot thunk.
(setq restore
(lambda ()
(when ct
(modify-frame-parameters
f (list (cons 'cursor-type ct))))
(kill-buffer outbuf)
(setq restore nil)))
(condition-case nil
(progn
(message "Zoning... (%s)" pgm)
(garbage-collect)
;; If some input is pending, zone says "sorry", which
;; isn't nice; this might happen e.g. when they invoke the
;; game by clicking the menu bar. So discard any pending
;; input before zoning out.
(if (input-pending-p)
(discard-input))
(zone-call pgm)
(message "Zoning...sorry"))
(error
(funcall restore)
(while (not (input-pending-p))
(message "We were zoning when we wrote %s..." pgm)
(sit-for 3)
(message "...here's hoping we didn't hose your buffer!")
(sit-for 3)))
(quit
(funcall restore)
(ding)
(message "Zoning...sorry")))
(when restore (funcall restore))))))