summaryrefslogtreecommitdiff
path: root/ennum.el
diff options
context:
space:
mode:
Diffstat (limited to 'ennum.el')
-rw-r--r--ennum.el35
1 files changed, 35 insertions, 0 deletions
diff --git a/ennum.el b/ennum.el
index 31e5e5f..7161eeb 100644
--- a/ennum.el
+++ b/ennum.el
@@ -5,6 +5,7 @@
(require 'ox)
(require 'seq)
(require 'cl)
+(require 'loadhist)
(require 'map)
(require 'memoize)
(require 'simple-httpd)
@@ -15,6 +16,14 @@
(defvar ennum-blog nil
"Property list specifying ennum publish settings")
+(defvar ennum-track-features
+ '(ennum ennum-html ennum-image ob-tangle org ox ox-html)
+ "List of features to track on expression evaluation.")
+
+(defvar ennum-feature-hash
+ nil
+ "List of hashes tracking current state of features.")
+
;; TODO: Should the store have an absolute path to deal with directory
;; changes? Yes, since we ask for an absolute working directory, we
;; should.
@@ -57,6 +66,28 @@ respectively by - and _, and the pad character = is optional."
(insert file)
(ennum--hash)))
+(defun ennum--feature-environment (feature)
+ "Return hash of the current state of FEATURE.
+
+The returned hash is the hash of the file providing FEATURE, and
+the current state of all its variables."
+ (pcase (feature-symbols feature)
+ (`(,file . ,entries)
+ (with-temp-buffer
+ ;; Print hash of file.
+ (print (ennum-file-hash file) (current-buffer))
+ ;; Print variables and their values.
+ (dolist (variable entries)
+ (print (if (and (atom variable)
+ (boundp variable)
+ ;; Exclude `ennum-feature-hash' since it
+ ;; is meant to be changed on each run.
+ (not (eq variable 'ennum-feature-hash)))
+ (cons variable (symbol-value variable))
+ variable)
+ (current-buffer)))
+ (ennum--hash)))))
+
(defun ennum--set-file-modes-recursively (directory directory-mode file-mode executable-file-mode)
(chmod directory directory-mode)
(seq-do (lambda (file)
@@ -75,6 +106,7 @@ respectively by - and _, and the pad character = is optional."
(with-temp-buffer
(let ((print-length nil)
(print-level nil))
+ (print ennum-feature-hash (current-buffer))
(print closure (current-buffer)))
(ennum--hash))
(ennum-setting :store))))
@@ -648,6 +680,9 @@ as keys. Keys are compared using `equal'."
(defun ennum-publish ()
(interactive)
+ ;; Recompute feature hash.
+ (setq ennum-feature-hash
+ (seq-map 'ennum--feature-environment ennum-track-features))
(ennum-with-current-directory (ennum-setting :working-directory)
(let* ((blog-title (ennum-setting :blog-title))
(posts (ennum-posts (ennum-setting :posts-directory)))