all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
@ 2022-10-13 13:37 Philip Kaludercic
  2022-10-13 14:20 ` Stefan Kangas
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Philip Kaludercic @ 2022-10-13 13:37 UTC (permalink / raw)
  To: 58493

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

Tags: patch


By default zone chooses a random program, but it seems to me that it
should be OK to allow choosing a specific effect.


In GNU Emacs 29.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version
 3.24.34, cairo version 1.17.6) of 2022-10-13 built on rhea
Repository revision: 0b170c6caeeb669df3cf97c54c43da9cf77e6b42
Repository branch: master
System Description: Fedora Linux 36 (Workstation Edition)

Configured using:
 'configure --with-pgtk --with-imagemagick'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-play-zone.el-zone-Allow-selecting-a-program.patch --]
[-- Type: text/patch, Size: 1870 bytes --]

From c122c2a921d0b06d7b49fa8231ab685faeb6169f Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Tue, 11 Oct 2022 12:28:45 +0200
Subject: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program

---
 lisp/play/zone.el | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/lisp/play/zone.el b/lisp/play/zone.el
index b0ce0194cf..47fdbbec0a 100644
--- a/lisp/play/zone.el
+++ b/lisp/play/zone.el
@@ -103,9 +103,24 @@ zone-call
                  program))))
 
 ;;;###autoload
-(defun zone ()
-  "Zone out, completely."
-  (interactive)
+(defun zone (&optional pgm)
+  "Zone out, completely.
+The optional argument PGM should be an element of `zone-programs'
+or nil to have a random element chosen.  When invoked
+interactively with a prefix argument, the user is prompted for a
+program."
+  (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 @@ zone
       (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
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-04 22:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-13 13:37 bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program Philip Kaludercic
2022-10-13 14:20 ` Stefan Kangas
2022-10-13 15:55 ` Eli Zaretskii
2022-10-13 17:14   ` Philip Kaludercic
2022-10-13 19:26     ` Eli Zaretskii
2022-10-13 20:22       ` Philip Kaludercic
2022-10-14  9:22     ` Stefan Kangas
2022-10-14 10:36       ` Eli Zaretskii
2022-10-14 15:57         ` Philip Kaludercic
2022-11-04 22:19 ` Philip Kaludercic

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.