diff options
author | Thanos Apollo <[email protected]> | 2024-01-03 06:59:23 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-01-03 07:10:23 +0200 |
commit | 511a4fa54ca7c7ef38a2e9c923b9de194029fd72 (patch) | |
tree | ff074ba6fcbc63696563b48f60b992c3b2860cd4 /gnosis.el | |
parent | 7d681f4c5b3806eb3aa359f82af283ef1110cb81 (diff) |
Add gnosis-replace-item-at-index
Used to change/edit values at gnosis-db, that are represented as
lists, such as ef
Diffstat (limited to 'gnosis.el')
-rw-r--r-- | gnosis.el | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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)))) |