-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbvr-uuid.el
46 lines (38 loc) · 1.14 KB
/
bvr-uuid.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
;;; UUID --- Insert UUID as number at point
;;;
;;; Commentary:
;;;
;;; Code:
(require 'uuidgen)
(use-package bvr-utils)
(defgroup bvr-uuid nil
"Properties of 'bvr-uuid package."
:group 'bvr-utils)
(defcustom bvr/random-uuid-string-length 8
"String length of uuid string to insert."
:type '(integer)
:local t
:group 'bvr-uuid)
(defun bvr/random-seed-from-uuidgen nil
"Insert random seed int at poing from uuidgen."
(interactive)
(let* ((snum (uuidgen-4))
(snum (split-string snum "-"))
(snum (seq-take snum 2))
(snum (string-join snum))
(snum (string-to-number snum 16)))
(insert (number-to-string snum))))
(defun bvr/random-uuid-string (arg)
"Insert random string from uuid.
Prompt for string length if prefix ARG is given."
(interactive "P")
(let* ((slen bvr/random-uuid-string-length)
(slen (if (and slen (not arg)) slen
(read-integer "String Length: ")))
(snum (uuidgen-4))
(snum (split-string snum "-"))
(snum (string-join snum))
(snum (substring snum 0 slen)))
(insert snum)))
(provide 'bvr-uuid)
;;; bvr-uuid.el ends here