feat(wpcarro/emacs): Support struct-update!

Support mutable variant of `struct-update`. Also remove the `dash` dependency in
`tests.el`.

Change-Id: I76fc809e96b7cbbd3b39fd16db339cb62eab002c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6027
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
This commit is contained in:
William Carroll 2022-08-02 13:10:10 -07:00 committed by clbot
parent 9d475c5b9b
commit 44f520ccd1
3 changed files with 41 additions and 12 deletions

View file

@ -39,6 +39,16 @@ This is immutable."
(setf (,accessor copy) (funcall ,f (,accessor copy)))
copy)))
(defmacro struct-update! (type field f xs)
"Mutably apply F to FIELD in XS."
(let ((accessor (->> field
symbol-name
(s-prepend (s-concat (symbol-name type) "-"))
intern)))
`(progn
(setf (,accessor ,xs) (funcall ,f (,accessor ,xs)))
,xs)))
(defmacro struct-set (type field x xs)
"Immutably set FIELD in XS (struct TYPE) to X."
(let ((copier (->> type