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.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/play/zone.el.gz
;;;; Here we zone...

;;;###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)))))
  (run-hooks 'zone-start-hook)
  (let* ((start-time (current-time))
         (zone-again nil)
         (src-winbuf (zone--choose-window-and-buffer))
         (src-win  (car src-winbuf))
         (src-buf  (cdr src-winbuf))
         (src-frm  (window-frame src-win)))
    (setq zone-frame-configuration-alist nil)
    (unwind-protect
        (progn
          (zone--save-frame-configuration src-frm)
          (zone--build-zone-buffer src-win src-buf)
          (zone--prepare-frames src-frm)
          (condition-case zone-err
              (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
             (message "%s error: %S" (or pgm 'zone) zone-err)
             (zone--apologize-for-failing pgm)
             (setq zone-again t))

            (quit
             (ding)
             (message "Zoning...sorry"))))
      (zone--restore-all-frame-configurations))
    (when (and zone-again
               (not (input-pending-p)))
      (zone))
    (setq zone-time-elapsed-while-zoning (time-since start-time)))
    (run-hooks 'zone-finish-hook))