From 47dd5f1613d5be4a53277961550dd8634f5f587e Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 29 Dec 2023 04:56:08 +0200 Subject: gnosis-display: Rewrite cloze-reveal Rewrite as cl-defun with keywords, change previous default values. New: Optionally add custom face --- gnosis.el | 13 ++++++++----- 1 file 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. -- cgit v1.2.3