From 1e8e5fc529ad7dd1f1ca0fb8988cd309e3e24bd8 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Mon, 2 Sep 2024 09:32:18 +0300 Subject: New variable-watcher: custom-values-watcher. * Watch & validate new custom gnosis values. --- gnosis.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'gnosis.el') 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) -- cgit v1.2.3