commit 89cfe2c41dcadd8bfa4c2aae35f9631e6b3dd097
parent b51897b96ae55a361ced056058af6edee5dc6655
Author: Yuval Langer <yuvallangerontheroad@gmail.com>
Date: Sat, 7 Oct 2023 22:55:15 +0300
Add parentheses to default case toggle prompts. Also beautify code a bit.
Diffstat:
1 file changed, 29 insertions(+), 11 deletions(-)
diff --git a/super-duper-yes-or-no.el b/super-duper-yes-or-no.el
@@ -56,13 +56,13 @@
"Words to be used by `sd-yes-or-no-words-p'.")
(defcustom sd-upper-case-phrase-for-yes
- "If you understand what you're doing, enter the capitalized letters here for \"yes\""
+ "(If you understand what you're doing, enter the capitalized letters here for \"yes\")"
"Phrase to be used by the \"yes\" prong of `sd-yes-or-no-toggle-case-p'."
:type 'string
:group 'super-duper-yes-or-no)
(defcustom sd-upper-case-phrase-for-no
- "If you understand what you're doing, enter the capitalized letters here for \"no\""
+ "(If you understand what you're doing, enter the capitalized letters here for \"no\")"
"Phrase to be used by the \"no\" prong of `sd-yes-or-no-toggle-case-p'."
:type 'string
:group 'super-duper-yes-or-no)
@@ -306,18 +306,24 @@ otherwise, the uppercase letters of the second."
(sd--randomly-toggle-string-case
sd-upper-case-phrase-for-yes
sd-number-of-case-toggle-characters)
+
for wanted-no-prompt =
(sd--randomly-toggle-string-case
sd-upper-case-phrase-for-no
sd-number-of-case-toggle-characters)
+
for wanted-input-yes =
(sd--string-only-uppercase
wanted-yes-prompt)
+
for wanted-input-no =
(sd--string-only-uppercase
wanted-no-prompt)
- while (equal wanted-input-yes
- wanted-input-no)
+
+ while
+ (equal wanted-input-yes
+ wanted-input-no)
+
finally return
(cl-loop
for user-input =
@@ -327,10 +333,12 @@ otherwise, the uppercase letters of the second."
"\n"
wanted-no-prompt
":\n"))
+
until (or (equal user-input
wanted-input-yes)
(equal user-input
wanted-input-no))
+
finally return
(equal user-input
wanted-input-yes))))
@@ -360,7 +368,8 @@ otherwise, the uppercase letters of the second."
(cond
((null arithmetic-expression-template) '())
(t (cons (car arithmetic-expression-template)
- (sd--make-arithmetic-problem-arguments (cdr arithmetic-expression-template))))))
+ (sd--make-arithmetic-problem-arguments
+ (cdr arithmetic-expression-template))))))
(defun sd-yes-or-no-arithmetic-problem-p (prompt)
"Ask user a yes or no question, but as an answer to an arithmetic expression.
@@ -373,15 +382,21 @@ problem, otherwise, the answer to the second problem."
for wanted-yes-prompt =
(sd--make-arithmetic-problem
sd--arithmetic-problem-template)
+
for wanted-no-prompt =
(sd--make-arithmetic-problem
sd--arithmetic-problem-template)
+
for wanted-input-yes =
(eval wanted-yes-prompt)
+
for wanted-input-no =
(eval wanted-no-prompt)
- while (= wanted-input-yes
- wanted-input-no)
+
+ while
+ (= wanted-input-yes
+ wanted-input-no)
+
finally return
(cl-loop
for user-input =
@@ -393,10 +408,13 @@ problem, otherwise, the answer to the second problem."
" for \"yes\" and "
(format "%S" wanted-no-prompt)
" for \"no\": ")))
- until (or (= user-input
- wanted-input-yes)
- (= user-input
- wanted-input-no))
+
+ until
+ (or (= user-input
+ wanted-input-yes)
+ (= user-input
+ wanted-input-no))
+
finally return
(= user-input
wanted-input-yes))))