-
Notifications
You must be signed in to change notification settings - Fork 5
/
shampoo-dict.el
41 lines (30 loc) · 1.05 KB
/
shampoo-dict.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
;;; shampoo-dict.el --- Shampoo aux dictionary object
;;
;; Copyright (C) 2010 - 2012 Dmitry Matveev <[email protected]>
;;
;; This software is released under terms of the MIT license,
;; please refer to the LICENSE file for details.
(eval-when-compile (require 'cl))
(defun make-shampoo-dict ()
(make-hash-table))
(defun* shampoo-dict-put (&key key value into)
(puthash key value into))
(defun shampoo-dict-drop (key data)
(remhash key data))
(defun shampoo-dict-apply (key f data)
(let ((v (shampoo-dict-get key data)))
(shampoo-dict-put :key key :value (funcall f v) :into data)))
(defun shampoo-dict-apply-many (keys f data)
(dolist (k keys)
(shampoo-dict-apply k f data))
data)
(defun shampoo-dict-get (key data)
(gethash key data))
(defun shampoo-dict-has (key data)
(not (null (shampoo-dict-get key data))))
(defun shampoo-dict-binder-for-regexp (class-data)
(lexical-let ((d class-data))
(lambda (key value)
(shampoo-dict-put :key key :value value :into d))))
(provide 'shampoo-dict)
;;; shampoo-dict.el ends here.