[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnosis a783b56772 10/19: New function: Add validate-custom
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnosis a783b56772 10/19: New function: Add validate-custom-values. |
Date: |
Thu, 5 Sep 2024 13:00:31 -0400 (EDT) |
branch: elpa/gnosis
commit a783b56772fe44111395e3045cfebbf986259495
Author: Thanos Apollo <public@thanosapollo.org>
Commit: Thanos Apollo <public@thanosapollo.org>
New function: Add validate-custom-values.
* Function to be used with a variable watcher to validate custom
gnosis values.
---
gnosis.el | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/gnosis.el b/gnosis.el
index 2e8af51275..61ab5db0cb 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -2017,6 +2017,35 @@ SUSPEND: Suspend note, 0 for unsuspend, 1 for suspend"
(gnosis-update 'notes `(= ,field ',value) `(= id ,id)))
(t (gnosis-update 'notes `(= ,field ,value) `(= id ,id))))))
+(defun gnosis-validate-custom-values (new-value)
+ "Validate the structure and values of NEW-VALUE for gnosis-custom-values."
+ (unless (listp new-value)
+ (error "GNOSIS-CUSTOM-VALUES should be a list of entries"))
+ (dolist (entry new-value)
+ (unless (and (listp entry) (= (length entry) 3)
+ (memq (nth 0 entry) '(:deck :tag))
+ (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))
+ (anagnosis (plist-get (nth 2 entry) :anagnosis))
+ (epignosis (plist-get (nth 2 entry) :epignosis))
+ (agnoia (plist-get (nth 2 entry) :agnoia))
+ (amnesia (plist-get (nth 2 entry) :amnesia))
+ (lethe (plist-get (nth 2 entry) :lethe)))
+ (unless (listp proto)
+ (error "Proto must be a list of interval integer values"))
+ (unless (or (null anagnosis) (integerp anagnosis))
+ (error "Anagnosis should be an integer"))
+ (unless (or (null epignosis) (numberp epignosis))
+ (error "Epignosis should be a number"))
+ (unless (or (null agnoia) (numberp agnoia))
+ (error "Agnoia should be a number"))
+ (unless (or (null amnesia) (and (numberp amnesia) (<= amnesia 1) (>=
amnesia 0)))
+ (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-get-custom-values--validate (plist valid-keywords)
"Verify that PLIST consists of VALID-KEYWORDS."
(let ((keys (let (ks)
- [nongnu] elpa/gnosis updated (013fca6bae -> 731f0ba491), ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 48ca4aa6f2 07/19: [Refactor] Rewrite org-insert-heading, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis a783b56772 10/19: New function: Add validate-custom-values.,
ELPA Syncer <=
- [nongnu] elpa/gnosis 56ed928045 09/19: export-deck: Add demo export., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 1e8e5fc529 11/19: New variable-watcher: custom-values-watcher., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis d034335bde 18/19: Packaging: Add version 0.4.2., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 4d90489c5b 05/19: elpaignore: Add manifest.scm, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 11e526b496 02/19: New module: gnosis-org: Use org-mode with gnosis., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis cfa0462972 01/19: packaging: Version 0.4.2-dev, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 061633adca 03/19: packaging: Require emacsql-4.0.1., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 487d903de1 04/19: New file: Add manifest.scm, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 02a4e13520 12/19: [fix] display-images: Display images only on graphical envs., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis bb1469aad5 08/19: Update todos., ELPA Syncer, 2024/09/05