aboutsummaryrefslogtreecommitdiff
path: root/ennu.el
diff options
context:
space:
mode:
authorArun Isaac2019-09-02 22:56:11 +0530
committerArun Isaac2019-09-02 22:56:11 +0530
commit3f2eef6a230278fc4ed3cbc71d6bbcfc80f3f13c (patch)
treefdd3002868c6b2c650eda4c33a5200f5ddc73e61 /ennu.el
parentdfdbc51501bcf535c6ecb742cfc169f6041be224 (diff)
downloadennum-3f2eef6a230278fc4ed3cbc71d6bbcfc80f3f13c.tar.gz
ennum-3f2eef6a230278fc4ed3cbc71d6bbcfc80f3f13c.tar.lz
ennum-3f2eef6a230278fc4ed3cbc71d6bbcfc80f3f13c.zip
Add tangle slot to post structure.
* ennu.el (ennu-post): Add tangle slot. (ennu--read-post): Initialize tangle slot.
Diffstat (limited to 'ennu.el')
-rw-r--r--ennu.el27
1 files changed, 19 insertions, 8 deletions
diff --git a/ennu.el b/ennu.el
index be81523..f8bab98 100644
--- a/ennu.el
+++ b/ennu.el
@@ -14,7 +14,7 @@
(cl-defstruct (ennu-post (:constructor ennu-make-post)
(:copier nil))
- filename slug author date language links
+ filename slug author date language links tangle
summary tags thumbnail title translation-group)
(cl-defstruct (ennu-operation (:constructor ennu-make-operation)
@@ -46,13 +46,14 @@
(unless (plist-member metadata key)
(user-error "Metadata %s not specified" key)))
ennu-mandatory-metadata)
- (let ((links (org-element-map (org-element-parse-buffer) 'link
- (lambda (link)
- (pcase link
- (`(link ,properties . ,_)
- (let ((link-type (org-element-property :type link)))
- (when (member link-type (list "image" "static" "video"))
- (cons link-type (org-element-property :path link))))))))))
+ (let* ((tree (org-element-parse-buffer))
+ (links (org-element-map tree 'link
+ (lambda (link)
+ (pcase link
+ (`(link ,properties . ,_)
+ (let ((link-type (org-element-property :type link)))
+ (when (member link-type (list "image" "static" "video"))
+ (cons link-type (org-element-property :path link))))))))))
(ennu-make-post
:filename filename
:slug (file-name-base filename)
@@ -60,6 +61,16 @@
:date (org-timestamp-to-time (first (plist-get metadata :date)))
:language (plist-get metadata :language)
:links links
+ ;; TODO: Deal with cases when the :tangle parameter is "yes"
+ :tangle (seq-uniq
+ (org-element-map tree 'src-block
+ (lambda (src-block)
+ (pcase (org-babel-get-src-block-info nil src-block)
+ (`(,_ ,_ ,arguments ,_ ,_ ,_ ,_)
+ (let ((tangle-output-file (map-elt arguments :tangle)))
+ (pcase tangle-output-file
+ ("no" nil)
+ (_ tangle-output-file))))))))
:summary (funcall export (first (plist-get metadata :summary)))
:tags (plist-get metadata :filetags)
:thumbnail (or (plist-get metadata :thumbnail)