emacs-super-duper-yes-or-no

Replace the yes-or-no function with an even more demanding yes or no prompt, rather than with y-or-n.
Log | Files | Refs | LICENSE

commit cdf8de6b4b1bc42622308c7bf4a34cb7a1b0840c
parent ec60e46240162695a6b9b514a15017218b18da81
Author: Yuval Langer <yuvallangerontheroad@gmail.com>
Date:   Thu,  5 Oct 2023 16:54:12 +0300

Rename the wordlist variable and fix the random wordlist function.

Turns out wordlists that are vectors should not be named `-list`………
(Thanks, Fade!)

Diffstat:
Msuper-duper-yes-or-no.el | 76++++++++++++++++++++++++++++++++++++++++++----------------------------------
1 file changed, 42 insertions(+), 34 deletions(-)

diff --git a/super-duper-yes-or-no.el b/super-duper-yes-or-no.el @@ -32,7 +32,7 @@ (defvar sd-number-of-words 2) -(defvar sd-word-list +(defvar sd-words ["aaaaa" "moo" "foo" @@ -65,11 +65,11 @@ (defun sd--make-random-input-string (wanted-number-of-words) (let ((words ()) - (wordlist-size (seq-length sd-word-list))) + (wordlist-size (seq-length sd-words))) (while (not (= (seq-length words) wanted-number-of-words)) (let* ((word-index (random wordlist-size)) - (random-word (aref sd-word-list + (random-word (aref sd-words word-index))) (setq words (cons random-word words)))) @@ -102,37 +102,45 @@ "" (interactive) - (let ((result nil)) - (while (not result) - (let* ((wanted-yes-or-no (sd--make-random-yes-or-no-input-pair - sd-number-of-words)) - (wanted-yes (car wanted-yes-or-no)) - (wanted-no (cadr wanted-yes-or-no)) - (wanted-yes-string (apply 'concat - (sd--list-intersperse wanted-yes - " "))) - (wanted-no-string (apply 'concat - (sd--list-intersperse wanted-no - " "))) - (user-input - (read-from-minibuffer - (concat prompt - "(Enter \"" - wanted-yes-string - "\" for yes, \"" - wanted-no-string - "\" for no) ")))) - - (cond - ((equal user-input - wanted-yes-string) - (setq result - t)) - ((equal user-input - wanted-no-string) - (setq result - '()))))) - result)) + (let* ((wanted-yes-or-no (sd--make-random-yes-or-no-input-pair + sd-number-of-words)) + (wanted-yes (car wanted-yes-or-no)) + (wanted-no (cadr wanted-yes-or-no)) + (wanted-yes-string (apply 'concat + (sd--list-intersperse wanted-yes + " "))) + (wanted-no-string (apply 'concat + (sd--list-intersperse wanted-no + " "))) + (user-input + (read-from-minibuffer + (concat prompt + "(Enter \"" + wanted-yes-string + "\" for yes, \"" + wanted-no-string + "\" for no) ")))) + (while (not (or (equal user-input + wanted-yes-string) + (equal user-input + wanted-no-string))) + (setq user-input + (read-from-minibuffer + (concat prompt + "(Enter \"" + wanted-yes-string + "\" for yes, \"" + wanted-no-string + "\" for no) ")))) + (cond + ((equal user-input + wanted-yes-string) + (setq result + t)) + ((equal user-input + wanted-no-string) + (setq result + '()))))) (defun sd--toggle-char-case (our-char) (cond