From 6b8d8f418b229bc2bd030dbda14ac08c9903f585 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 27 Dec 2023 06:42:06 +0200 Subject: Add gnosis-cloze-replace-words --- gnosis.el | 8 ++++++++ 1 file changed, 8 insertions(+) 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. -- cgit v1.2.3