;;; -*- lexical-binding: t -*- (require 'org) ;; Mapping of skews to tags active for that skew. ;; Pairs with symbol keys makes it a p-list. (defconst recipe-skews '(normal (core) fluffy (core fluff))) (defun recipe-get-skew () "Get the current skew, error if invalid." (let* ((skew-str (or (getenv "SKEW") "normal")) (skew (car (read-from-string skew-str)))) ;; converts str "normal" to symbol 'normal (unless (plist-member recipe-skews skew) (error (format "Invalid skew: %s" skew))) skew)) (defun recipe-active (tag) "Return t if TAG active or nil if not." (let ((active-tags (plist-get recipe-skews recipe-skew))) (if (not active-tags) (error (format "No tags for skew: %s" recipe-skew)) (member tag active-tags)))) (defun recipe-tangle-for (tag) "Return :tangle output for TAG, depending on whether it is active." (if (recipe-active tag) recipe-out-file "no")) ;; The current skew (defvar recipe-skew (recipe-get-skew)) ;; Define the out file based on the current skew (defvar recipe-out-file (format "recipe-%s.tex" recipe-skew)) ;; Turn off eval confirmation, since we're using in script mode. (let ((org-confirm-babel-evaluate nil)) (org-babel-tangle-file "recipe.org"))