From 8015d65c3f20541c502dee3068e515f3a5a074f5 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 6 Sep 2024 15:23:37 +0300 Subject: [fix] edit-update-note: Adjust for null clozes. * Previous change would cause breakage for null clozes in a list. * Update docs as well. --- doc/gnosis.info | 105 +++++++++++++++++++++++--------------------------------- doc/gnosis.texi | 62 ++++++++++++--------------------- gnosis.el | 7 ++-- 3 files changed, 69 insertions(+), 105 deletions(-) diff --git a/doc/gnosis.info b/doc/gnosis.info index 69f63bc..b57f067 100644 --- a/doc/gnosis.info +++ b/doc/gnosis.info @@ -12,14 +12,15 @@ File: gnosis.info, Node: Top, Next: Introduction, Up: (dir) Gnosis User Manual ****************** -Gnosis is a customizable spaced repetition system designed to enhance -memory retention through active recall. It allows users to set specific -review intervals for note decks & tags, creating an optimal learning -environment tailored to each specific topic. +Gnosis (GNU-sis) is a customizable spaced repetition system designed to +enhance memory retention through active recall. It allows users to set +specific review intervals for note decks & tags, creating an optimal +learning environment tailored to each specific topic/subject. -This manual is written for Gnosis version 0.4.0, released on 2024-08-7. +This manual is written for Gnosis version 0.4.2, released on 2024-09-5. - • Official manual: + • Official manual: + • • Git repositories: • @@ -57,8 +58,7 @@ Gnosis Algorithm Configuring Note Types -* Adjust Current Types Entries:: -* Creating Custom Note Types:: +* Custom Note Types:: * Development:: @@ -384,23 +384,24 @@ File: gnosis.info, Node: Configuring Note Types, Prev: Sync between devices, * Menu: -* Adjust Current Types Entries:: -* Creating Custom Note Types:: +* Custom Note Types:: * Development::  -File: gnosis.info, Node: Adjust Current Types Entries, Next: Creating Custom Note Types, Up: Configuring Note Types +File: gnosis.info, Node: Custom Note Types, Next: Development, Up: Configuring Note Types -8.1 Adjust Current Types Entries -================================ +8.1 Custom Note Types +===================== Each gnosis note type has an _interactive_ function, named -‘gnosis-add-note-TYPE’. You can set default values for each entry by -hard coding specific values to their keywords. +‘gnosis-add-note-TYPE’ and a "hidden" function named +‘gnosis-add-note--TYPE’. You can create your own custom interactive +functions to ignore or hard-code specific values by using already +defined hidden functions that handle all the logic. For example: - (defun gnosis-add-note-basic (deck) + (defun gnosis-add-note-custombasic (deck) (gnosis-add-note--basic :deck deck :question (gnosis-read-string-from-buffer "Question: " "") :answer (read-string "Answer: ") @@ -408,35 +409,16 @@ hard coding specific values to their keywords. :extra "" :images nil :tags (gnosis-prompt-tags--split gnosis-previous-note-tags))) + ;; Add custom note type to gnosis-note-types + (add-to-list 'gnosis-note-types "custombasic") - By evaluating the above code snippet, you won't be prompted to enter -anything for ‘extra’ & ‘images’. - - -File: gnosis.info, Node: Creating Custom Note Types, Next: Development, Prev: Adjust Current Types Entries, Up: Configuring Note Types - -8.2 Creating Custom Note Types -============================== - -Creating custom note types for gnosis is a fairly simple thing to do - - • First add your NEW-TYPE to ‘gnosis-note-types’ - - (add-to-list 'gnosis-note-types "NEW-TYPE") - • Create an interactive function - - Each note type has a ‘gnosis-add-note-TYPE’ that is used -interactively & a "hidden function" ‘gnosis-add-note--TYPE’ that handles -all the logic. You can use one of the ‘current gnosis-add-note--TYPE’ -functions or create one of your own. - - Refer to ‘gnosis-add-note-basic’ & ‘gnosis-add-note--basic’ for a -simple example of how this is done, as well as ‘gnosis-add-note-double’. + Now ‘custombasic’ is available as a note type, for which you won't be +prompted to enter anything for ‘extra’ & ‘images’.  -File: gnosis.info, Node: Development, Prev: Creating Custom Note Types, Up: Configuring Note Types +File: gnosis.info, Node: Development, Prev: Custom Note Types, Up: Configuring Note Types -8.3 Development +8.2 Development =============== To make development and customization easier, gnosis comes with @@ -450,27 +432,26 @@ then enter ‘n’ (no) at the prompt "Start development env?"  Tag Table: Node: Top250 -Node: Introduction1350 -Node: Adding notes2363 -Node: Note Types2774 -Node: Cloze2992 -Node: MC-Cloze (Under development)4154 -Node: MCQ5142 -Node: Basic Type5580 -Node: Double5856 -Node: y-or-n6122 -Node: Customization6524 -Node: Image size6709 -Node: Typos | String Comparison6995 -Node: Gnosis Algorithm7770 -Node: Anagnosis Event8417 -Node: Proto9158 -Node: Editing notes9925 -Node: Sync between devices10317 -Node: Configuring Note Types11344 -Node: Adjust Current Types Entries11576 -Node: Creating Custom Note Types12576 -Node: Development13412 +Node: Introduction1341 +Node: Adding notes2354 +Node: Note Types2765 +Node: Cloze2983 +Node: MC-Cloze (Under development)4145 +Node: MCQ5133 +Node: Basic Type5571 +Node: Double5847 +Node: y-or-n6113 +Node: Customization6515 +Node: Image size6700 +Node: Typos | String Comparison6986 +Node: Gnosis Algorithm7761 +Node: Anagnosis Event8408 +Node: Proto9149 +Node: Editing notes9916 +Node: Sync between devices10308 +Node: Configuring Note Types11335 +Node: Custom Note Types11525 +Node: Development12735  End Tag Table diff --git a/doc/gnosis.texi b/doc/gnosis.texi index 779ea47..e5cc81f 100644 --- a/doc/gnosis.texi +++ b/doc/gnosis.texi @@ -25,17 +25,21 @@ @node Top @top Gnosis User Manual -Gnosis is a customizable spaced repetition system designed to enhance +Gnosis (GNU-sis) is a customizable spaced repetition system designed to enhance memory retention through active recall. It allows users to set specific review intervals for note decks & tags, creating an optimal -learning environment tailored to each specific topic. +learning environment tailored to each specific topic/subject. @noindent -This manual is written for Gnosis version 0.4.0, released on 2024-08-7. +This manual is written for Gnosis version 0.4.2, released on 2024-09-5. @itemize @item -Official manual: @uref{https://thanosapollo.org/user-manual/gnosis} +Official manual: +@itemize +@item +@uref{https://elpa.nongnu.org/nongnu/doc/gnosis.html} +@end itemize @item Git repositories: @itemize @@ -45,6 +49,7 @@ Git repositories: @end itemize @insertcopying + @end ifnottex @menu @@ -81,8 +86,7 @@ Gnosis Algorithm Configuring Note Types -* Adjust Current Types Entries:: -* Creating Custom Note Types:: +* Custom Note Types:: * Development:: @end detailmenu @@ -272,7 +276,7 @@ difference of at most one character edit. To demonstrate, 'example' and 'examples' will be recognized as similar, considering that the latter involves just one additional -character.`` +character." @node Gnosis Algorithm @chapter Gnosis Algorithm @@ -370,7 +374,6 @@ name suggests, they rely on @samp{vc} to work properly. Depending on your setup, @samp{vc} might require an external package for the ssh passphrase dialog, such as @code{x11-ssh-askpass}. - To automatically push changes after a review session, add this to your configuration: @lisp (setf gnosis-vc-auto-push t) @@ -381,22 +384,23 @@ To automatically push changes after a review session, add this to your configura @chapter Configuring Note Types @menu -* Adjust Current Types Entries:: -* Creating Custom Note Types:: +* Custom Note Types:: * Development:: @end menu -@node Adjust Current Types Entries -@section Adjust Current Types Entries +@node Custom Note Types +@section Custom Note Types Each gnosis note type has an @emph{interactive} function, named -@samp{gnosis-add-note-TYPE}. You can set default values for each entry by -hard coding specific values to their keywords. +@samp{gnosis-add-note-TYPE} and a ``hidden'' function +named @samp{gnosis-add-note--TYPE}. You can create your own custom interactive +functions to ignore or hard-code specific values by using already +defined hidden functions that handle all the logic. For example: @lisp -(defun gnosis-add-note-basic (deck) +(defun gnosis-add-note-custombasic (deck) (gnosis-add-note--basic :deck deck :question (gnosis-read-string-from-buffer "Question: " "") :answer (read-string "Answer: ") @@ -404,35 +408,13 @@ For example: :extra "" :images nil :tags (gnosis-prompt-tags--split gnosis-previous-note-tags))) +;; Add custom note type to gnosis-note-types +(add-to-list 'gnosis-note-types "custombasic") @end lisp -By evaluating the above code snippet, you won't be prompted to enter +Now @code{custombasic} is available as a note type, for which you won't be prompted to enter anything for @code{extra} & @code{images}. -@node Creating Custom Note Types -@section Creating Custom Note Types - -Creating custom note types for gnosis is a fairly simple thing to do - -@itemize -@item -First add your NEW-TYPE to @samp{gnosis-note-types} - -@lisp -(add-to-list 'gnosis-note-types "NEW-TYPE") -@end lisp -@item -Create an interactive function -@end itemize - -Each note type has a @samp{gnosis-add-note-TYPE} that is used interactively -& a ``hidden function'' @samp{gnosis-add-note--TYPE} that handles all the -logic. You can use one of the @samp{current gnosis-add-note--TYPE} -functions or create one of your own. - -Refer to @samp{gnosis-add-note-basic} & @samp{gnosis-add-note--basic} for a simple -example of how this is done, as well as @samp{gnosis-add-note-double}. - @node Development @section Development diff --git a/gnosis.el b/gnosis.el index 4619fa9..022f5d8 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1989,7 +1989,8 @@ SUSPEND: Suspend note, 0 for unsuspend, 1 for suspend" (cl-assert (and (listp tags) (cl-every #'stringp tags)) nil "Tags must be a list of strings") (cl-assert (and (listp gnosis) (length= gnosis 3) (cl-every #'floatp gnosis)) nil "gnosis must be a list of 3 floats") - (cl-assert (or (stringp options) (and (listp options) (cl-every #'stringp options))) + (cl-assert (or (stringp options) (and (listp options) (cl-every #'(lambda (x) (or (stringp x) (null x))) + options))) nil "Options must be a string or a list of strings") (cl-assert (and (numberp suspend) (or (= suspend 0) (= suspend 1))) nil "Suspend must be either 0 or 1") (when (and (string= (gnosis-get-type id) "cloze") @@ -2030,14 +2031,14 @@ SUSPEND: Suspend note, 0 for unsuspend, 1 for suspend" (memq (nth 0 entry) '(:deck :tag)) (stringp (nth 1 entry)) (listp (nth 2 entry))) ; Ensure the third element is a plist - (error "Each entry should a :deck or :tag keyword, a string, and a plist of custom values")) + (error "Each entry should a have :deck or :tag keyword, a string, and a plist of custom values")) (let ((proto (plist-get (nth 2 entry) :proto)) (anagnosis (plist-get (nth 2 entry) :anagnosis)) (epignosis (plist-get (nth 2 entry) :epignosis)) (agnoia (plist-get (nth 2 entry) :agnoia)) (amnesia (plist-get (nth 2 entry) :amnesia)) (lethe (plist-get (nth 2 entry) :lethe))) - (unless (listp proto) + (unless (and (listp proto) (cl-every #'integerp proto)) (error "Proto must be a list of interval integer values")) (unless (or (null anagnosis) (integerp anagnosis)) (error "Anagnosis should be an integer")) -- cgit v1.2.3