From 6d8bb7376b7b83d998e230c3f4b3d5948f43183e Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 1 May 2024 20:49:34 +0300 Subject: gnosis-display: Use fill-paragraph as optional arg --- gnosis.el | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/gnosis.el b/gnosis.el index 392b3a2..8f779bf 100644 --- a/gnosis.el +++ b/gnosis.el @@ -280,11 +280,15 @@ Example: if (= i index) collect new-item else collect item)) -(defun gnosis-display-question (id) - "Display main row for note ID." +(defun gnosis-display-question (id &optional fill-paragraph-p) + "Display main row for note ID. + +If FILL-PARAGRAPH-P, insert question using `fill-paragraph'." (let ((question (gnosis-get 'main 'notes `(= id ,id)))) (erase-buffer) - (fill-paragraph (insert "\n" (propertize question 'face 'gnosis-face-main))))) + (if fill-paragraph-p + (fill-paragraph (insert "\n" (propertize question 'face 'gnosis-face-main)))) + (insert "\n" (propertize question 'face 'gnosis-face-main)))) (defun gnosis-display-mcq-options (id) "Display answer options for mcq note ID." @@ -295,12 +299,17 @@ Example: do (insert (format "\n%s. %s" option-num option)) (setf option-num (1+ option-num))))) -(defun gnosis-display-cloze-sentence (sentence clozes) - "Display cloze sentence for SENTENCE with CLOZES." +(defun gnosis-display-cloze-sentence (sentence clozes &optional fill-paragraph-p) + "Display cloze sentence for SENTENCE with CLOZES. + +If FILL-PARAGRAPH-P, insert using `fill-paragraph'" (erase-buffer) - (fill-paragraph - (insert "\n" - (gnosis-cloze-replace-words sentence clozes (propertize gnosis-cloze-string 'face 'gnosis-face-cloze))))) + (let ((cloze-sentence + (gnosis-cloze-replace-words sentence clozes (propertize gnosis-cloze-string 'face 'gnosis-face-cloze)))) + (if fill-paragraph-p + (fill-paragraph + (insert "\n" cloze-sentence)) + (insert "\n" cloze-sentence)))) (defun gnosis-display-basic-answer (answer success user-input) "Display ANSWER. -- cgit v1.2.3