diff options
author | Arun Isaac | 2020-08-01 20:07:22 +0530 |
---|---|---|
committer | Arun Isaac | 2020-08-02 03:20:15 +0530 |
commit | 5fb7f96d886848f6d3b2401a895fb1e203190ca9 (patch) | |
tree | a7beb1a6ee1946a63e01bcde8e6904510c2ecb48 | |
parent | 0b0f36bf5c574a5f5ccad87a869f6899856c062b (diff) | |
download | ennum-5fb7f96d886848f6d3b2401a895fb1e203190ca9.tar.gz ennum-5fb7f96d886848f6d3b2401a895fb1e203190ca9.tar.lz ennum-5fb7f96d886848f6d3b2401a895fb1e203190ca9.zip |
Create a functional setter for ennum-post-translations.
* ennum.el (ennum-make-functional-setter): New macro.
(ennum-post-set-translations): New function.
(ennum-posts): Use ennum-post-set-translations.
-rw-r--r-- | ennum.el | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -130,11 +130,20 @@ respectively by - and _, and the pad character = is optional." (reverse (ennum-directory-files item nil t)))) (ennum-input items)))) +(defmacro ennum-make-functional-setter (name copier accessor) + `(defun ,name (object new-value) + (let ((object-copy (,copier object))) + (setf (,accessor object-copy) new-value) + object-copy))) + (cl-defstruct (ennum-post (:constructor ennum-make-post) (:copier ennum-copy-post)) filename slug author date language links tangle summary tags thumbnail title translation-group translations) +(ennum-make-functional-setter + ennum-post-set-translations ennum-copy-post ennum-post-translations) + (cl-defstruct (ennum-link (:constructor ennum-make-link) (:copier nil)) type path) @@ -154,13 +163,11 @@ respectively by - and _, and the pad character = is optional." (ennum-post-slug post))) posts))) (seq-map (lambda (post) - (let ((post-copy (ennum-post-copy post))) - (setf (ennum-post-translations post-copy) - (seq-remove (pcase-lambda (`(,_ . ,slug)) - (string= (ennum-post-slug post) - slug)) - translations)) - post-copy)) + (ennum-post-set-translations + post + (seq-remove (pcase-lambda (`(,_ . ,slug)) + (string= (ennum-post-slug post) slug)) + translations))) posts))) ;; Read posts from org files and group them by translation ;; group. |