diff options
author | Philip Kaludercic <philipk@posteo.net> | 2022-10-11 12:28:45 +0200 |
---|---|---|
committer | Philip Kaludercic <philipk@posteo.net> | 2022-10-14 18:07:51 +0200 |
commit | be1afa047f74f3197e530b28971249593b12d177 (patch) | |
tree | a57d3e8e943d583c42f721a789f3d6a1b32b30f8 | |
parent | b175a9fb7eea49cdf8171821498f2c5efaaecd98 (diff) | |
download | emacs-be1afa047f74f3197e530b28971249593b12d177.tar.gz |
* lisp/play/zone.el (zone): Allow selecting a program
-rw-r--r-- | lisp/play/zone.el | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lisp/play/zone.el b/lisp/play/zone.el index b0ce0194cf0..5ea5bbc9267 100644 --- a/lisp/play/zone.el +++ b/lisp/play/zone.el @@ -103,9 +103,24 @@ If the element is a function or a list of a function and a number, program)))) ;;;###autoload -(defun zone () - "Zone out, completely." - (interactive) +(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*")) @@ -125,8 +140,7 @@ If the element is a function or a list of a function and a number, (set-window-start (selected-window) (point-min)) (set-window-point (selected-window) wp) (sit-for 0 500) - (let ((pgm (elt zone-programs (random (length zone-programs)))) - (ct (and f (frame-parameter f 'cursor-type))) + (let ((ct (and f (frame-parameter f 'cursor-type))) (show-trailing-whitespace nil) restore) (when ct |