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

* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
  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-11-04 22:19 ` Philip Kaludercic
  2 siblings, 0 replies; 10+ messages in thread
From: Stefan Kangas @ 2022-10-13 14:20 UTC (permalink / raw)
  To: Philip Kaludercic, 58493

Philip Kaludercic <philipk@posteo.net> writes:

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

LGTM (but I didn't test it).





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

* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
  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-11-04 22:19 ` Philip Kaludercic
  2 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2022-10-13 15:55 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 58493

> From: Philip Kaludercic <philipk@posteo.net>
> Date: Thu, 13 Oct 2022 13:37:12 +0000
> 
> +(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."                             ^^^^^^^^^^^^^^^^^^^^^^^^^^

Passive tense alert!





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

* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
  2022-10-13 15:55 ` Eli Zaretskii
@ 2022-10-13 17:14   ` Philip Kaludercic
  2022-10-13 19:26     ` Eli Zaretskii
  2022-10-14  9:22     ` Stefan Kangas
  0 siblings, 2 replies; 10+ messages in thread
From: Philip Kaludercic @ 2022-10-13 17:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 58493

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Philip Kaludercic <philipk@posteo.net>
>> Date: Thu, 13 Oct 2022 13:37:12 +0000
>> 
>> +(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."                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Passive tense alert!

"... the command prompts the user for a program?"





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

* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
  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
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2022-10-13 19:26 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 58493

> From: Philip Kaludercic <philipk@posteo.net>
> Cc: 58493@debbugs.gnu.org
> Date: Thu, 13 Oct 2022 17:14:54 +0000
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: Philip Kaludercic <philipk@posteo.net>
> >> Date: Thu, 13 Oct 2022 13:37:12 +0000
> >> 
> >> +(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."                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > Passive tense alert!
> 
> "... the command prompts the user for a program?"

Possible.  Or just "... prompt for the program to use."







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

* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
  2022-10-13 19:26     ` Eli Zaretskii
@ 2022-10-13 20:22       ` Philip Kaludercic
  0 siblings, 0 replies; 10+ messages in thread
From: Philip Kaludercic @ 2022-10-13 20:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 58493

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Philip Kaludercic <philipk@posteo.net>
>> Cc: 58493@debbugs.gnu.org
>> Date: Thu, 13 Oct 2022 17:14:54 +0000
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> >> From: Philip Kaludercic <philipk@posteo.net>
>> >> Date: Thu, 13 Oct 2022 13:37:12 +0000
>> >> 
>> >> +(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."                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
>> >
>> > Passive tense alert!
>> 
>> "... the command prompts the user for a program?"
>
> Possible.  Or just "... prompt for the program to use."

As always your suggestion is preferable.  Thanks!





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

* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
  2022-10-13 17:14   ` Philip Kaludercic
  2022-10-13 19:26     ` Eli Zaretskii
@ 2022-10-14  9:22     ` Stefan Kangas
  2022-10-14 10:36       ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Kangas @ 2022-10-14  9:22 UTC (permalink / raw)
  To: Philip Kaludercic, Eli Zaretskii; +Cc: 58493

Philip Kaludercic <philipk@posteo.net> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Philip Kaludercic <philipk@posteo.net>
>>> Date: Thu, 13 Oct 2022 13:37:12 +0000
>>>
>>> +(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."                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> Passive tense alert!
>
> "... the command prompts the user for a program?"

I think we use the style

    "With a \\[universal-argument] prefix argument, prompt for a program."

I would personally put the interactive part first, and then say
explicitly:

    "When called from Lisp, ..."

This is a command, first and foremost, after all.





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

* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
  2022-10-14  9:22     ` Stefan Kangas
@ 2022-10-14 10:36       ` Eli Zaretskii
  2022-10-14 15:57         ` Philip Kaludercic
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2022-10-14 10:36 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: philipk, 58493

> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Fri, 14 Oct 2022 11:22:00 +0200
> Cc: 58493@debbugs.gnu.org
> 
> > "... the command prompts the user for a program?"
> 
> I think we use the style
> 
>     "With a \\[universal-argument] prefix argument, prompt for a program."

No, we rarely if at all mention universal-argument explicitly in doc
strings.  The assumption is that the reader knows well enough how to
invoke commands with a prefix argument.

> I would personally put the interactive part first, and then say
> explicitly:
> 
>     "When called from Lisp, ..."
> 
> This is a command, first and foremost, after all.

That's a matter of personal preferences.  We have both styles in our
doc strings, and both are okay, from my POV.





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

* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
  2022-10-14 10:36       ` Eli Zaretskii
@ 2022-10-14 15:57         ` Philip Kaludercic
  0 siblings, 0 replies; 10+ messages in thread
From: Philip Kaludercic @ 2022-10-14 15:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 58493, Stefan Kangas

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Stefan Kangas <stefankangas@gmail.com>
>> Date: Fri, 14 Oct 2022 11:22:00 +0200
>> Cc: 58493@debbugs.gnu.org
>> 
>> > "... the command prompts the user for a program?"
>> 
>> I think we use the style
>> 
>>     "With a \\[universal-argument] prefix argument, prompt for a program."
>
> No, we rarely if at all mention universal-argument explicitly in doc
> strings.  The assumption is that the reader knows well enough how to
> invoke commands with a prefix argument.

FWIW it wouldn't be bad to do so.  When I first got into Emacs I was
using it for maybe 1 or 1 1/2 years before I understood what prefix
arguments are.  Really improved my experience when I found out :)

>> I would personally put the interactive part first, and then say
>> explicitly:
>> 
>>     "When called from Lisp, ..."
>> 
>> This is a command, first and foremost, after all.
>
> That's a matter of personal preferences.  We have both styles in our
> doc strings, and both are okay, from my POV.

I agree with Stefan that in this case mentioning the interactive case
first is more intuitive.





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

* bug#58493: [PATCH] * lisp/play/zone.el (zone): Allow selecting a program
  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-11-04 22:19 ` Philip Kaludercic
  2 siblings, 0 replies; 10+ messages in thread
From: Philip Kaludercic @ 2022-11-04 22:19 UTC (permalink / raw)
  To: 58493-done

Philip Kaludercic <philipk@posteo.net> writes:

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

The patch has been applies, so I'll close the report.





^ permalink raw reply	[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.