summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-12-29 04:56:08 +0200
committerThanos Apollo <[email protected]>2023-12-29 04:56:08 +0200
commit47dd5f1613d5be4a53277961550dd8634f5f587e (patch)
treed63914b9b1bc1c38fabccf223dbfc265962f98e2 /gnosis.el
parentcebbef623bfd42b0d2d61fc509318bbc7e61ff8a (diff)
gnosis-display: Rewrite cloze-reveal
Rewrite as cl-defun with keywords, change previous default values. New: Optionally add custom face
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el13
1 files changed, 8 insertions, 5 deletions
diff --git a/gnosis.el b/gnosis.el
index b824e15..e4bc8d2 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -164,14 +164,17 @@ When SUCCESS nil, display USER-INPUT as well"
(propertize "\n\n-----\n" 'face 'gnosis-face-seperator)
(propertize hint 'face 'gnosis-face-hint)))))
-(defun gnosis-display--cloze-reveal (cloze-chars replace success)
- "Replace CLOZE-CHARS with REPLACE.
+(cl-defun gnosis-display-cloze-reveal (&key (cloze-char gnosis-cloze-char) replace (success t) (face nil))
+ "Replace CLOZE-CHAR with REPLACE.
-If SUCCESS t"
+If FACE nil, propertize replace using `gnosis-face-correct', or
+`gnosis-face-false' when (not SUCCESS). Else use FACE value."
(with-gnosis-buffer
(goto-char (point-min))
- (search-forward cloze-chars nil t)
- (replace-match (propertize replace 'face (if success 'gnosis-face-correct 'gnosis-face-false)))))
+ (search-forward cloze-char nil t)
+ (replace-match (propertize replace 'face (if (not face)
+ (if success 'gnosis-face-correct 'gnosis-face-false)
+ face)))))
(cl-defun gnosis-display--cloze-user-answer (user-input &optional (false nil))
"Display USER-INPUT answer for cloze note.