unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: 58493@debbugs.gnu.org
Subject: bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
Date: Thu, 13 Oct 2022 13:37:12 +0000	[thread overview]
Message-ID: <87sfjr3kvr.fsf@posteo.net> (raw)

[-- 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


             reply	other threads:[~2022-10-13 13:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 13:37 Philip Kaludercic [this message]
2022-10-13 14:20 ` bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sfjr3kvr.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=58493@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).