]> git.earman.xyz Git - emacsinit.git/commitdiff
Condense the lists of characters into two
authorrearman <rearman@r717.net>
Thu, 18 Sep 2025 15:58:37 +0000 (11:58 -0400)
committerrearman <rearman@r717.net>
Thu, 18 Sep 2025 15:58:37 +0000 (11:58 -0400)
Only care about the split between special/non-special, so combine non-special
characters into one list, called alphanumerics.

re/re-pass-alike.el

index 734baeef25beb21c5f54b71e45782082836d5948..01ba9bd253ce43db779afa5876fcbc5a6a587397 100644 (file)
@@ -106,31 +106,24 @@ Assumes same structure as `pass(1)'."
 \f
 ;; Password generation
 
-(defconst *lowercase*
+(defconst *alphanumerics*
   '("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m"
-    "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z")
-  "List of strings containing the lowercase English alphabet.")
-
-(defconst *uppercase*
-  '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M"
-    "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z")
-  "List of strings containing the uppercase English alphabet.")
-
-(defconst *numbers*
-  '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")
-  "List of strings containing the single-digit numbers.")
-
-(defconst *special-characters* '("!" "?" "$" "%" "&" "'" "(" ")" "*"
-                                "+" "," "-" "." "/" ":" ";" "<" "=" ">"
-                                "?" "@" "[" "]" "^" "_" "{" "|" "}" "~")
+    "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
+    "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M"
+    "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"
+    "0" "1" "2" "3" "4" "5" "6" "7" "8" "9")
+  "List of strings of the upper/lower-case English alphabet, and the single-digit numbers.")
+
+(defconst *special-characters*
+  '("!" "?" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "."
+    "/" ":" ";" "<" "=" ">" "?" "@" "[" "]" "^" "_" "{"
+    "|" "}" "~")
   "List of strings containing the special visible characters excluding \\ and \" .")
 
 (defun pw-get-char (&optional no-special-chars)
   "Select a single character at random to be used in a password.
 If `no-special-chars' is t, use only alpha-numeric characters."
-  (let ((selected-charset (append *lowercase*
-                                 *uppercase*
-                                 *numbers*
+  (let ((selected-charset (append *alphanumerics*
                                  (when (null no-special-chars)
                                    *special-characters*))))
     (elt selected-charset (random (length selected-charset)))))