aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-08-15 00:28:52 +0530
committerArun Isaac2022-08-15 16:37:32 +0530
commitf20a79207c4b6f243e6de029f5f0fffd81dc0c1c (patch)
tree6f37561b99d00a2941cace2435793fd3c0778498
parentd4db2699ed44e468d8f4c083bade11e7a1ab9ca3 (diff)
downloadennum-f20a79207c4b6f243e6de029f5f0fffd81dc0c1c.tar.gz
ennum-f20a79207c4b6f243e6de029f5f0fffd81dc0c1c.tar.lz
ennum-f20a79207c4b6f243e6de029f5f0fffd81dc0c1c.zip
Track variables provided by certain features.
We track the value of variables provided by certain features. This is so that we rebuild correctly when the user sets a configuration variable. * ennum.el: Require loadhist. (ennum-track-features, ennum-feature-hash): New variables. (ennum--feature-environment): New function. (ennum-exp): Include ennum-feature-hash in hash computation. (ennum-publish): Recompute ennum-feature-hash.
-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)))