summaryrefslogtreecommitdiff
path: root/ennu.el
diff options
context:
space:
mode:
Diffstat (limited to 'ennu.el')
-rw-r--r--ennu.el27
1 files changed, 16 insertions, 11 deletions
diff --git a/ennu.el b/ennu.el
index 7169b9a..76485a3 100644
--- a/ennu.el
+++ b/ennu.el
@@ -241,12 +241,15 @@ last form in BODY."
(when (member link-type (list "image" "static" "video"))
(cons link-type (org-element-property :path link))))))))))
-(defun plist-put* (plist &rest key-value-pairs)
- (pcase key-value-pairs
- (`(,key ,value)
- (plist-put plist key value))
- (`(,key ,value . ,tail)
- (apply 'plist-put* (plist-put plist key value) tail))))
+(defun ennu-plist-map-to-plist (function plist)
+ "Apply FUNCTION to each key-value pair of PLIST and return the
+result as a plist with keys being the keys in PLIST and the
+values being the values returned by FUNCTION. FUNCTION is called
+with two arguments -- the key and the value."
+ (seq-mapcat
+ (pcase-lambda (`(,key ,value))
+ (list key (funcall function key value)))
+ (seq-partition plist 2)))
(defun ennu-post-metadata (post)
(ennu--post-metadata-memoized
@@ -261,11 +264,13 @@ last form in BODY."
(unless (plist-member metadata key)
(user-error "Metadata %s not specified" key)))
ennu-mandatory-metadata)
- (plist-put*
- metadata
- :title (funcall export (first (plist-get metadata :title)))
- :date (org-timestamp-to-time (first (plist-get metadata :date)))
- :author (funcall export (first (plist-get metadata :author)))))))
+ (ennu-plist-map-to-plist
+ (lambda (key value)
+ (pcase key
+ (:title (funcall export (first (plist-get metadata :title))))
+ (:date (org-timestamp-to-time (first (plist-get metadata :date))))
+ (:author (funcall export (first (plist-get metadata :author))))))
+ metadata))))
(defvar ennu-mandatory-metadata
(list :title :date))