summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnosis.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/gnosis.el b/gnosis.el
index c7c3fa5..d114ddc 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -85,8 +85,9 @@ WARNING: Do not change this value!")
(cl-defun gnosis-update (table value where)
"Update records in TABLE with to new VALUE based on the given WHERE condition.
+
Example:
- (gnosis-update `''notes `''(= main \"NEW VALUE\") `''(= id 12))"
+ (gnosis-update ='notes ='(= main \"NEW VALUE\") ='(= id 12))"
(emacsql gnosis-db `[:update ,table :set ,value :where ,where]))
(cl-defun gnosis-get (value table &optional (restrictions '1=1))
@@ -130,6 +131,12 @@ FACE-FOR-INFO is the face used to display info for option."
(cdr (assoc (completing-read prompt formatted-choices nil t)
formatted-choices))))
+(defun gnosis-replace-item-at-index (index new-item list)
+ "Replace item at INDEX in LIST with NEW-ITEM."
+ (cl-loop for i from 0 for item in list
+ if (= i index) collect new-item
+ else collect item))
+
(defun gnosis-display--question (id)
"Display main row for note ID."
(let ((question (gnosis-get 'main 'notes `(= id ,id))))