Add random-alnum function
This commit is contained in:
parent
03dd2cbb1f
commit
410841f531
@ -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/<persisted-vars-file> as a plist of (variable-name variable-value).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user