summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-03-04 09:21:14 +0200
committerThanos Apollo <[email protected]>2024-03-04 09:21:14 +0200
commitb82bfebecd829f78ab151c12336500003c32c72d (patch)
tree15609c3f1ac3e91e205eec54d0509f18adcc89af /gnosis.el
parent4851677fe4ba6f2e093c189ca991f02b784e4f0a (diff)
Refactor gnosis-compare-strings
Adjust for when gnosis-string-difference is >= answer length
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/gnosis.el b/gnosis.el
index a0bf469..bb7b6d6 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -788,9 +788,13 @@ Valid cloze formats include:
"Compare STR1 and STR2.
Compare 2 strings, ignoring case and whitespace."
- (<= (string-distance (downcase (replace-regexp-in-string "\\s-" "" str1))
- (downcase (replace-regexp-in-string "\\s-" "" str2)))
- gnosis-string-difference))
+ (let ((string-compare-func (if (or (>= (length str1) gnosis-string-difference)
+ (>= (length str2) gnosis-string-difference))
+ #'(lambda (str1 str2) (<= (string-distance str1 str2) gnosis-string-difference))
+ #'string=)))
+ (funcall string-compare-func
+ (downcase (replace-regexp-in-string "\\s-" "" str1))
+ (downcase (replace-regexp-in-string "\\s-" "" str2)))))
(defun gnosis-directory-files (&optional dir regex)