From dd668288d4d8b6f161b751545008966f867428d7 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Mon, 29 Jan 2024 06:09:11 +0200 Subject: gnosis-completing-read: Shart quote function names --- gnosis.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnosis.el b/gnosis.el index 87cfdfd..62255ba 100644 --- a/gnosis.el +++ b/gnosis.el @@ -204,7 +204,7 @@ OPTIONS is a list of strings. INFO is a list of strings, which will be displayed as additional info for option FACE-FOR-INFO is the face used to display info for option." (let* ((choices (cl-mapcar 'cons options info)) - (max-choice-length (apply 'max (mapcar 'length options))) + (max-choice-length (apply #'max (mapcar #'length options))) (formatted-choices (mapcar (lambda (choice) (cons (concat (format "%s" (car choice)) -- cgit v1.2.3 From e0652144a2e30f27e2d2907f6094d18f5082541a Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Mon, 29 Jan 2024 06:10:01 +0200 Subject: Remove unnecessary `concat' --- gnosis.el | 97 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 47 insertions(+), 50 deletions(-) diff --git a/gnosis.el b/gnosis.el index 62255ba..5ab25ec 100644 --- a/gnosis.el +++ b/gnosis.el @@ -226,32 +226,29 @@ FACE-FOR-INFO is the face used to display info for option." "Display main row for note ID." (let ((question (gnosis-get 'main 'notes `(= id ,id)))) (erase-buffer) - (fill-paragraph (insert (concat "\n" - (propertize question 'face 'gnosis-face-main)))))) + (fill-paragraph (insert "\n" (propertize question 'face 'gnosis-face-main))))) (defun gnosis-display-cloze-sentence (sentence clozes) "Display cloze sentence for SENTENCE with CLOZES." (erase-buffer) (fill-paragraph - (insert - (concat "\n" - (gnosis-cloze-replace-words sentence clozes (propertize gnosis-cloze-string 'face 'gnosis-face-cloze)))))) + (insert "\n" + (gnosis-cloze-replace-words sentence clozes (propertize gnosis-cloze-string 'face 'gnosis-face-cloze))))) (defun gnosis-display-basic-answer (answer success user-input) "Display ANSWER. When SUCCESS nil, display USER-INPUT as well" - (insert - (concat "\n\n" - (propertize "Answer:" 'face 'gnosis-face-directions) + (insert "\n\n" + (propertize "Answer:" 'face 'gnosis-face-directions) + " " + (propertize answer 'face 'gnosis-face-correct)) + ;; Insert user wrong answer + (when (not success) + (insert "\n" + (propertize "Your answer:" 'face 'gnosis-face-directions) " " - (propertize answer 'face 'gnosis-face-correct))) - ;; Insert user wrong answer - (when (not success) - (insert (concat "\n" - (propertize "Your answer:" 'face 'gnosis-face-directions) - " " - (propertize user-input 'face 'gnosis-face-false))))) + (propertize user-input 'face 'gnosis-face-false)))) (cl-defun gnosis-display-y-or-n-answer (&key answer success) "Display y-or-n answer for note ID. @@ -260,60 +257,60 @@ ANSWER is the correct answer, either y or n. Answer is either 121 or 110, which are the char values for y & n respectively SUCCESS is t when user-input is correct, else nil" (let ((answer (if (equal answer 121) "y" "n"))) - (insert - (concat "\n\n" - (propertize "Answer:" 'face 'gnosis-face-directions) - " " - (propertize answer 'face (if success 'gnosis-face-correct 'gnosis-face-false)))))) + (insert + "\n\n" + (propertize "Answer:" 'face 'gnosis-face-directions) + " " + (propertize answer 'face (if success 'gnosis-face-correct 'gnosis-face-false))))) (defun gnosis-display-hint (hint) "Display HINT." - (goto-char (point-max)) - (insert (concat - (propertize "\n\n-----\n" 'face 'gnosis-face-seperator) - (propertize hint 'face 'gnosis-face-hint)))) + (goto-char (point-max)) + (insert + (propertize "\n\n-----\n" 'face 'gnosis-face-seperator) + (propertize hint 'face 'gnosis-face-hint))) (cl-defun gnosis-display-cloze-reveal (&key (cloze-char gnosis-cloze-string) replace (success t) (face nil)) "Replace CLOZE-CHAR with REPLACE. If FACE nil, propertize replace using `gnosis-face-correct', or `gnosis-face-false' when (not SUCCESS). Else use FACE value." - (goto-char (point-min)) - (search-forward cloze-char nil t) - (replace-match (propertize replace 'face (if (not face) - (if success 'gnosis-face-correct 'gnosis-face-false) - face)))) + (goto-char (point-min)) + (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 t)) "Display USER-INPUT answer for cloze note upon failed review. If FALSE t, use gnosis-face-false face" - (goto-char (point-max)) - (insert (concat "\n\n" - (propertize "Your answer:" 'face 'gnosis-face-directions) - " " - (propertize user-input 'face (if false 'gnosis-face-false 'gnosis-face-correct))))) + (goto-char (point-max)) + (insert "\n\n" + (propertize "Your answer:" 'face 'gnosis-face-directions) + " " + (propertize user-input 'face (if false 'gnosis-face-false 'gnosis-face-correct)))) (defun gnosis-display-correct-answer-mcq (answer user-choice) "Display correct ANSWER & USER-CHOICE for MCQ note." - (insert (concat "\n\n" - (propertize "Correct Answer:" 'face 'gnosis-face-directions) - " " - (propertize answer 'face 'gnosis-face-correct) - "\n" - (propertize "Your answer:" 'face 'gnosis-face-directions) - " " - (propertize user-choice 'face (if (string= answer user-choice) - 'gnosis-face-correct - 'gnosis-face-false))))) + (insert "\n\n" + (propertize "Correct Answer:" 'face 'gnosis-face-directions) + " " + (propertize answer 'face 'gnosis-face-correct) + "\n" + (propertize "Your answer:" 'face 'gnosis-face-directions) + " " + (propertize user-choice 'face (if (string= answer user-choice) + 'gnosis-face-correct + 'gnosis-face-false)))) (defun gnosis-display-extra (id) "Display extra information for note ID." (let ((extras (gnosis-get 'extra-notes 'extras `(= id ,id)))) (goto-char (point-max)) (insert (propertize "\n\n-----\n" 'face 'gnosis-face-seperator)) - (fill-paragraph (insert (concat "\n" (propertize extras 'face 'gnosis-face-extra)))))) + (fill-paragraph (insert "\n" (propertize extras 'face 'gnosis-face-extra))))) (defun gnosis-display-image (id) "Display image for note ID." @@ -328,10 +325,10 @@ If FALSE t, use gnosis-face-false face" "Display next interval for note ID." (let ((interval (gnosis-get 'next-rev 'review-log `(= id ,id)))) (goto-char (point-max)) - (insert (concat "\n\n" - (propertize "Next review:" 'face 'gnosis-face-directions) - " " - (propertize (format "%s" interval) 'face 'gnosis-face-next-review))))) + (insert "\n\n" + (propertize "Next review:" 'face 'gnosis-face-directions) + " " + (propertize (format "%s" interval) 'face 'gnosis-face-next-review)))) (cl-defun gnosis--prompt (prompt &optional (downcase nil) (split nil)) "PROMPT user for input until `q' is given. @@ -1130,7 +1127,7 @@ changes." (image ,image) (second-image ,second-image)) do (cond ((eq field 'id) - (insert (format (concat ":%s " (propertize "%s" 'read-only t) "\n") field value))) + (insert (format ":id %s \n" (propertize (number-to-string value) 'read-only t)))) ((numberp value) (insert (format ":%s %s\n" field value))) ((and (listp value) -- cgit v1.2.3 From fc81421f8c500730c91b48260b3bee66ddedf18b Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Mon, 29 Jan 2024 10:25:21 +0200 Subject: gnosis-algorithm: Remove package-requires --- gnosis-algorithm.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/gnosis-algorithm.el b/gnosis-algorithm.el index 0dc2579..46a2abe 100644 --- a/gnosis-algorithm.el +++ b/gnosis-algorithm.el @@ -7,8 +7,6 @@ ;; URL: https://git.thanosapollo.org/gnosis ;; Version: 0.0.1 -;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2")) - ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or -- cgit v1.2.3 From 5cc5a913be70d7aba571e78a8cb10bd970e6c503 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Mon, 29 Jan 2024 10:27:56 +0200 Subject: Style & Fix indentation --- gnosis.el | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/gnosis.el b/gnosis.el index 5ab25ec..5d63884 100644 --- a/gnosis.el +++ b/gnosis.el @@ -225,8 +225,8 @@ FACE-FOR-INFO is the face used to display info for option." (defun gnosis-display-question (id) "Display main row for note ID." (let ((question (gnosis-get 'main 'notes `(= id ,id)))) - (erase-buffer) - (fill-paragraph (insert "\n" (propertize question 'face 'gnosis-face-main))))) + (erase-buffer) + (fill-paragraph (insert "\n" (propertize question 'face 'gnosis-face-main))))) (defun gnosis-display-cloze-sentence (sentence clozes) "Display cloze sentence for SENTENCE with CLOZES." @@ -267,7 +267,7 @@ SUCCESS is t when user-input is correct, else nil" (defun gnosis-display-hint (hint) "Display HINT." (goto-char (point-max)) - (insert + (insert (propertize "\n\n-----\n" 'face 'gnosis-face-seperator) (propertize hint 'face 'gnosis-face-hint))) @@ -911,20 +911,20 @@ SUCCESS is a binary value, 1 is for successful review." (defun gnosis-review-mcq (id) "Display multiple choice answers for question ID." - (gnosis-display-image id) - (gnosis-display-question id) - (let* ((choices (gnosis-get 'options 'notes `(= id ,id))) - (answer (nth (- (gnosis-get 'answer 'notes `(= id ,id)) 1) choices)) - (user-choice (gnosis-mcq-answer id))) - (if (string= answer user-choice) - (progn - (gnosis-review--update id 1) - (message "Correct!")) - (gnosis-review--update id 0) - (message "False")) - (gnosis-display-correct-answer-mcq answer user-choice) - (gnosis-display-extra id) - (gnosis-display-next-review id))) + (gnosis-display-image id) + (gnosis-display-question id) + (let* ((choices (gnosis-get 'options 'notes `(= id ,id))) + (answer (nth (- (gnosis-get 'answer 'notes `(= id ,id)) 1) choices)) + (user-choice (gnosis-mcq-answer id))) + (if (string= answer user-choice) + (progn + (gnosis-review--update id 1) + (message "Correct!")) + (gnosis-review--update id 0) + (message "False")) + (gnosis-display-correct-answer-mcq answer user-choice) + (gnosis-display-extra id) + (gnosis-display-next-review id))) (defun gnosis-review-basic (id) "Review basic type note for ID." @@ -941,16 +941,16 @@ SUCCESS is a binary value, 1 is for successful review." (defun gnosis-review-y-or-n (id) "Review y-or-n type note for ID." - (gnosis-display-image id) - (gnosis-display-question id) - (gnosis-display-hint (gnosis-get 'options 'notes `(= id ,id))) - (let* ((answer (gnosis-get 'answer 'notes `(= id ,id))) - (user-input (read-char-choice "[y]es or [n]o: " '(?y ?n))) - (success (equal answer user-input))) - (gnosis-display-y-or-n-answer :answer answer :success success) - (gnosis-display-extra id) - (gnosis-review--update id (if success 1 0)) - (gnosis-display-next-review id))) + (gnosis-display-image id) + (gnosis-display-question id) + (gnosis-display-hint (gnosis-get 'options 'notes `(= id ,id))) + (let* ((answer (gnosis-get 'answer 'notes `(= id ,id))) + (user-input (read-char-choice "[y]es or [n]o: " '(?y ?n))) + (success (equal answer user-input))) + (gnosis-display-y-or-n-answer :answer answer :success success) + (gnosis-display-extra id) + (gnosis-review--update id (if success 1 0)) + (gnosis-display-next-review id))) (defun gnosis-review-cloze--input (cloze) "Prompt for user input during cloze review. @@ -1239,7 +1239,7 @@ to improve readability." (insert (format ":%s %s\n" field value))) ((listp value) (insert (format ":%s %s\n" field (format "%s" (cl-loop for item in value - collect (format "\"%s\"" item)))))) + collect (format "\"%s\"" item)))))) ((equal value nil) (insert (format ":%s %s\n" field 'nil))) (t (insert (format ":%s \"%s\"\n" field value)) -- cgit v1.2.3