diff options
author | Thanos Apollo <[email protected]> | 2024-02-28 01:59:20 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-02-28 01:59:20 +0200 |
commit | 839567fd6c242ebd1f8093bf66544a5b83c2d608 (patch) | |
tree | 1c2df69ec4efe1f5684a6ed4934de28a5cf34bdb | |
parent | 346d30737443ff5b70d974a65d4ba1224273392a (diff) |
gnosis-cloze-replace-words: Update error handling
If cloze given is not valid throw an error. Just having search-forward
return error alone is confusing.
-rw-r--r-- | gnosis.el | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -730,8 +730,12 @@ Works both with {} and {{}} to make easier to import anki notes." "In STRING replace only the first occurrence of each word in WORDS with NEW." (cl-assert (listp words)) (cl-loop for word in words - do (when (string-match (concat "\\<" word "\\>") string) - (setq string (replace-match new t t string)))) + do (if (string-match (concat "\\<" word "\\>") string) + (setq string (replace-match new t t string)) + ;; This error will be produced when user has edited a + ;; note to an invalid cloze. + (error "`%s' is an invalid cloze for question: `%s'." + word string ))) string) (defun gnosis-cloze-extract-answers (str) |