unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* A more demanding yes-or-no and a wordlists package
@ 2023-09-28 21:11 Yuval Langer
  2023-09-30 19:20 ` Marcin Borkowski
  2023-10-07 19:53 ` Yuval Langer
  0 siblings, 2 replies; 3+ messages in thread
From: Yuval Langer @ 2023-09-28 21:11 UTC (permalink / raw)
  To: help-gnu-emacs

People often alias yes-or-no with y-or-n, which is a less demanding
confirmation function.

I thought, hey, what about aliasing yes-or-no with something even more
demanding to avoid confirming stuff accidentally?

I had a few ideas which I plan on implementing:

One idea (Google's Gmail's Drunk Mode) is to ask the user to solve a
small arithmetic problem, which I haven't yet implemented.

Another idea given by a friend was to prompt something like this with
randomly capitalised letters:

"If yOU undERstanD what you'rE doing, enter the capitalized letters here:"

What I did do is write a function which asks the user to write a
sequence of randomly selected words from a wordlist in order to
confirm, and another to decline. [1] Right now it only uses a dummy
wordlist, but I have also written another package which provides a
selection of publicly known wordlists, which the first package would
be dependent on.

The wordlist package [2] bundles publicly known worslists such as the
Diceware wordlists and the EFF wordlists.  I took the original files
as they are from those projects, and produce vectors of strings, each
vector is a wordlist.

It might just be my horrid code, but it takes a noticeable amount of
time to produce the vectors.  How should I cache the results of the
wordlist producing functions?

Another concern is that this solution takes a lot of memory?  Could I
make this dependency optional in the super-duper-yes-or-no package?

This is partly an exercise in learning Emacs Lisp, but maybe someone
would find it useful?

p.s. I haven't yet created their https://sr.ht/ homes, so they are
still only up on https://codeberg.org/

[1]: <https://codeberg.org/yuvallangerontheroad/super-duper-yes-or-no>
[2]: <https://codeberg.org/yuvallangerontheroad/emacs-wordlists>


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

* Re: A more demanding yes-or-no and a wordlists package
  2023-09-28 21:11 A more demanding yes-or-no and a wordlists package Yuval Langer
@ 2023-09-30 19:20 ` Marcin Borkowski
  2023-10-07 19:53 ` Yuval Langer
  1 sibling, 0 replies; 3+ messages in thread
From: Marcin Borkowski @ 2023-09-30 19:20 UTC (permalink / raw)
  To: Yuval Langer; +Cc: help-gnu-emacs


On 2023-09-28, at 23:11, Yuval Langer <yuval.langer@gmail.com> wrote:

> People often alias yes-or-no with y-or-n, which is a less demanding
> confirmation function.
>
> I thought, hey, what about aliasing yes-or-no with something even more
> demanding to avoid confirming stuff accidentally?

Interestingly, I came up with a very similar idea about a week ago, and
your email prompted me to desribe it on my blog:
https://mbork.pl/2023-09-30_Confirming_potentially_dangerous_actions

Best,

-- 
Marcin Borkowski
http://mbork.pl



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

* Re: A more demanding yes-or-no and a wordlists package
  2023-09-28 21:11 A more demanding yes-or-no and a wordlists package Yuval Langer
  2023-09-30 19:20 ` Marcin Borkowski
@ 2023-10-07 19:53 ` Yuval Langer
  1 sibling, 0 replies; 3+ messages in thread
From: Yuval Langer @ 2023-10-07 19:53 UTC (permalink / raw)
  To: help-gnu-emacs

On September 28, 2023 9:11:29 PM UTC, Yuval Langer <yuval.langer@gmail.com> wrote:
>I thought, hey, what about aliasing yes-or-no with something even more
>demanding to avoid confirming stuff accidentally?

I now have three yes-or-no-p replacements.

One, super-duper-yes-or-no-yes-or-no-words-p, takes a prompt string and displays the prompt and two random non-identical sequences of words in the minibuffer.  One for affirmative, the other for negative.  The user must enter one of them for the function to return.

Running:

(super-duper-yes-or-no-yes-or-no-words-p "Do some action? ")

Displays:

Do some action? (Enter "aaaaa foo" for yes, "aaaaa aaaaa" for no)

The user then must enter exactly, without the doube quotes, "aaaaa foo" for yes and "aaaaa aaaaa" for no.

The second, super-duper-yes-or-no-yes-or-no-toggle-case-p, takes a prompt string, and displays the prompt and two phrases with a small number of the letters' case flipped.  The use must enter the letters in sequence as they appear in the phrases for the function to return.

Running:

(super-duper-yes-or-no-yes-or-no-toggle-case-p "Do some
action? ")

Displays:

Do some action? (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 "no"):

Enter "IUDIE" for yes and "INNL" for no.

The third, sd-yes-or-no-arithmetic-problem-p, the same as the above, but with simple arithmetic problems:

Running:

(super-duper-yes-or-no-yes-or-no-arithmetic-problem-p "Do some
action? ")

Displays:

Do some action? Please answer (+ (* 8 0) (* 1 0)) for "yes" and (+
(* 8 2) (* 2 1)) for "no":

Enter "9" for yes and "18" for no.

There are several customizable variables one can set.  The docstrings explain them.

The only repository online currently is on <https://codeberg.org/yuvallangerontheroad/super-duper-yes-or-no> but I am not sure if I should move it to Source Hut or not.

Anyway, I would appreciate advice, any advice!

Thank you,
Yuval Langer.


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

end of thread, other threads:[~2023-10-07 19:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-28 21:11 A more demanding yes-or-no and a wordlists package Yuval Langer
2023-09-30 19:20 ` Marcin Borkowski
2023-10-07 19:53 ` Yuval Langer

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).