summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-12-27 06:42:06 +0200
committerThanos Apollo <[email protected]>2023-12-27 06:42:06 +0200
commit6b8d8f418b229bc2bd030dbda14ac08c9903f585 (patch)
treec3772e9f2db0af9be06501387c7fd9695937700a
parent3a6cd769d7c24287bd33f7439c5e1d6de0d4a1dc (diff)
Add gnosis-cloze-replace-words
-rw-r--r--gnosis.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/gnosis.el b/gnosis.el
index 61411b6..4ae140e 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -262,6 +262,14 @@ choice in the `CHOICES' list. Each note must correspond to one `DECK'.
;; As our push/assoc approach prepends elements, not appends them
;; (mapcar (lambda (x) (cons (car x) (cdr x))) (nreverse res)) ;; check for cl-rest
(mapcar (lambda (x) (cdr x)) (nreverse res))))
+(defun gnosis-cloze-replace-words (string words new)
+ "In STRING replace WORDS with NEW."
+ (cl-assert (listp words))
+ (cl-loop for word
+ in words
+ do (setf string (replace-regexp-in-string (concat "\\<" word "\\>") ;; use word boundary indentifiers
+ new string)))
+ string)
;; Review
(defun gnosis-review--algorithm (id success)
"Get next review date & ef for note with value of id ID.