From 410841f53179346813bad93ce87cf29b937d22cd Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 18 Dec 2019 11:26:50 -0500 Subject: [PATCH] Add random-alnum function --- emacs/init.org | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/emacs/init.org b/emacs/init.org index 3e6bcab..c6c725f 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -451,6 +451,16 @@ Convenience macro to run some code in a particular default-directory: ,@body)) #+END_SRC +#+BEGIN_SRC emacs-lisp + (defun random-alnum (&optional n) + (let* ((n-chars (or n 1)) + (alnum "abcdefghijklmnopqrstuvwxyz0123456789") + (result "")) + (dotimes (_ n-chars result) + (let ((i (% (abs (random)) (length alnum)))) + (setq result + (concat result (substring alnum i (1+ i)))))))) +#+END_SRC ** Persisting variables between session The idea behind this is pretty simple - variables get persisted in ~/.emacs.d/ as a plist of (variable-name variable-value).