summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-09-02 09:32:18 +0300
committerThanos Apollo <[email protected]>2024-09-02 10:42:19 +0300
commit1e8e5fc529ad7dd1f1ca0fb8988cd309e3e24bd8 (patch)
tree50d155dc1347ee6ed1fcde1fe66c4565400895ad
parenta783b56772fe44111395e3045cfebbf986259495 (diff)
New variable-watcher: custom-values-watcher.
* Watch & validate new custom gnosis values.
-rw-r--r--gnosis.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/gnosis.el b/gnosis.el
index 61ab5db..caef741 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -2027,8 +2027,7 @@ SUSPEND: Suspend note, 0 for unsuspend, 1 for suspend"
(stringp (nth 1 entry))
(listp (nth 2 entry))) ; Ensure the third element is a plist
(error "Each entry should a :deck or :tag keyword, a string, and a plist of custom values"))
- (let ((nested-plist (nth 2 entry))
- (proto (plist-get (nth 2 entry) :proto))
+ (let ((proto (plist-get (nth 2 entry) :proto))
(anagnosis (plist-get (nth 2 entry) :anagnosis))
(epignosis (plist-get (nth 2 entry) :epignosis))
(agnoia (plist-get (nth 2 entry) :agnoia))
@@ -2046,6 +2045,20 @@ SUSPEND: Suspend note, 0 for unsuspend, 1 for suspend"
(error "Amnesia should be a number between 0 and 1"))
(unless (or (null lethe) (and (integerp lethe) (> lethe 0)))
(error "Lethe should be an integer greater than 0")))))
+
+(defun gnosis-custom-values-watcher (symbol new-value _operation _where)
+ "Watcher for gnosis custom values.
+
+SYMBOL to watch changes for.
+NEW-VALUE is the new value set to the variable.
+OPERATION is the type of operation being performed.
+WHERE is the buffer or object where the change happens."
+ (when (eq symbol 'gnosis-custom-values)
+ (gnosis-validate-custom-values new-value)))
+
+(add-variable-watcher 'gnosis-custom-values 'gnosis-custom-values-watcher)
+
+;; Validate custom values during review process as well.
(defun gnosis-get-custom-values--validate (plist valid-keywords)
"Verify that PLIST consists of VALID-KEYWORDS."
(let ((keys (let (ks)