-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsk-53.el
40 lines (36 loc) · 1.69 KB
/
msk-53.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
;;; machine in G5e office
;; git paths
;(setenv "PATH" (concat "d:\\unix_env\\mingw\\bin;" (getenv "PATH")))
;(setenv "PATH" (concat "d:\\unix_env\\mingw\\bin\\core_perl;d:\\unix_env\\mingw\\bin\\site_perl;")(getenv "PATH"))
;(setenv "PATH" (concat "c:\\Program Files\\Git\\mingw64\\bin;"(getenv "PATH")))
; (push "d:/unix_env/mingw/bin" exec-path)
(push "c:/Program Files/Git/mingw64/bin" exec-path)
;; shell prompt fix
(setenv "PS1" "\\[\\e[32m\\]\\u@\\h \\[\\e[33m\\]\\w\\[\\e[0m\\]\\n\\$ ")
(defun transform-items (itemstring)
(cl-flet ((alg (KEY ALIST ) (alist-get KEY ALIST nil nil 'equal)))
(let ((json-object-type 'alist)
(json-array-type 'list)
(json-key-type 'string)
(result (list "reward_items")))
(let* ((items-sec (alg "items" (json-read-from-string itemstring)))
(item-ids (alg "itemId" items-sec))
(item-counts (alg "count" items-sec)))
(loop for id in item-ids
for count in item-counts
collect (list (cons "id" id) (cons "count" count)) into inner-res
finally return (nconc result (list inner-res)))))))
(defun transform-selected (begin end)
(interactive "r")
(atomic-change-group
(let (;; Distinguish an empty objects from 'null'
(json-null :json-null)
;; Ensure that ordering is maintained
(json-object-type 'alist)
(txt (delete-and-extract-region begin end)))
(let* ((transformed (transform-items (concat "{" txt "}")))
(json-encoding-pretty-print t)
(prev-pos (point)))
(insert (substring (json-encode transformed) 2 -2) "\n")
(indent-region prev-pos (point))))))
(require 'squirrel-mode)