#+TITLE: Gnosis User Manual
#+AUTHOR: Thanos Apollo
#+email: public@thanosapollo.org
#+language: en
#+options: ':t toc:nil author:t email:t num:t
#+startup: content
#+macro: stable-version 0.4.4
#+macro: release-date 2024-10-06
#+macro: file @@texinfo:@file{@@$1@@texinfo:}@@
#+macro: space @@texinfo:@: @@
#+macro: kbd @@texinfo:@kbd{@@$1@@texinfo:}@@
#+macro: file @@texinfo:@file{@@$1@@texinfo:}@@
#+macro: space @@texinfo:@: @@
#+macro: kbd @@texinfo:@kbd{@@$1@@texinfo:}@@
#+texinfo_filename: gnosis.info
#+texinfo_dir_category: Emacs misc features
#+texinfo_dir_title: Gnosis (γνῶσις): (gnosis) 
#+texinfo_dir_desc: Spaced Repetition System For Note Taking & Self-Testing
#+texinfo_header: @set MAINTAINERSITE @uref{https://thanosapollo.org,maintainer webpage}
#+texinfo_header: @set MAINTAINER Thanos Apollo
#+texinfo_header: @set MAINTAINEREMAIL @email{public@thanosapollo.org}
#+texinfo_header: @set MAINTAINERCONTACT @uref{mailto:public@thanosapollo.org,contact the maintainer}


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.

#+texinfo: @noindent
This manual is written for Gnosis version {{{stable-version}}}, released on {{{release-date}}}.

+ Manual:
  + <https://elpa.nongnu.org/nongnu/doc/gnosis.html>
  + <https://thanosapollo.org/projects/gnosis/> (Mirror)
+ Git repositories:
  + <https://git.thanosapollo.org/gnosis>
  + <https://codeberg.org/thanosapollo/emacs-gnosis> (Mirror)
  + <https://git.savannah.gnu.org/cgit/emacs/nongnu.git/?h=elpa/gnosis> (Mirror)

#+texinfo: @insertcopying

* Introduction

Gnosis (γνῶσις) is a spaced repetition system that enhances memory
retention through active recall. It employs a Q&A format, where each
note consists of a question, answer, and explanation. Notes are
reviewed at optimally spaced intervals based on the user's success or
failure to recall the answer.  Key benefits arise from writing out
answers when reviewing notes, fostering deeper understanding
and improved memory retention.

Gnosis algorithm is highly adjustable, allowing users to set specific
values not just for note decks but for tags as well.  Gnosis'
adjustability allows users to fine-tune settings not only for entire
note collections but also for specific tagged topics, thereby creating
a personalized learning environment for each topic.  Read more on
[[Gnosis Algorithm]]

Before continuing reading this manual, it's recommended you try out
=gnosis-demo=.

* Adding notes
Creating notes for gnosis can be done interactively with:

    =M-x gnosis-add-note=

Or from within =gnosis-dashboard=

When it comes to adding images, you can select images that are inside
=gnosis-images-dir=.  For adjusting image size, refer to [[#Customization][Customization]]

* Note Types
** Cloze
:PROPERTIES:
:CUSTOM_ID: Cloze
:END:
A cloze note type is a format where you create sentences or paragraphs
with "missing" words.  A fill-in-the-blanks question.  

You can create a cloze note type using =M-x gnosis-add-note= and
selecting ~Cloze~, the question should be formatted like this:

#+BEGIN_QUOTE
{c1:Cyproheptadine::drug name} is a(n) {c2:5-HT2} receptor antagonist used to treat {c2:serotonin syndrome}
#+END_QUOTE

You can also format clozes like Anki if you so prefer; e.g ~{{c1::Cyproheptadine::drug name}}~

+ For each cX-tag there will be created a cloze type note, the above
  example creates 2 cloze type notes.
  
+ Each cX tag can have multiple clozes, but each cloze must be a
  *UNIQUE* word, or a unique combination of words, in given note.

  + If a cloze is repeated, such as in phrases with "acetyl" &
    acetylcholine, include whitespace in the cloze to denote a single
    word.

+ You can use the keyword =::= to indicate a hint.

You can remove the /guidance/ string by adjusting
=gnosis-cloze-guidance=.

** MC-Cloze (Under development)

MC-Cloze is disabled by default, to enable it add to your configuration:

    =(add-to-list 'gnosis-note-types "MC-Cloze")=

A MC-Cloze (/Multiple Choice Cloze/) is a fill-in-the-blank note,
but unlike [[#Cloze][cloze note type]] the user is prompted to select an option
instead of typing an answer.

You can create multiple notes from one input, but each note can only
have *one* cloze. The first option will always be the right answer
(will be randomized in the database), separated by the rest of the
answer by =gnosis-mc-cloze-separator= (default value is "&&"), and a
note will be generated from each cloze.

Example:
#+BEGIN_QUOTE
    The greatest text editor is Emacs&&Vim&&Helix
#+END_QUOTE

When customizing =gnosis-mc-cloze=separator= pay attention to not use
values that would mess up with regex functions.
** MCQ

A MCQ note type, as the name suggests, is a multiple choice question.

The stem field (question) is separated by the options (choices) via
=gnosis-mcq-separator=, each option is separated by =gnosis-mcq-option-separator=.

You can remove the /guidance/ string by adjusting
=gnosis-mcq-guidance=.

** Basic Type

Basic note type is a simple question/answer note, where the user first
sees a "main" part, which is usually a question, and he is prompted to
input the answer. 

** Double
Double note type, is essentially a note that generates 2 basic notes.
The second one reverses question/answer.

Ideal for vocabulary acquisition notes.

** y-or-n
y-or-n (yes or no) note type, user is presented with a question and
prompted to enter character "y" or "n".

When using the hidden function =gnosis-add-note--y-or-n=, note that the
ANSWER must be either 121 (~y~) or 110 (~n~), as those correspond to the
character values used to represent them.

* Customization
:PROPERTIES:
:CUSTOM_ID: Customization
:END:
** Image size
:PROPERTIES:
:CUSTOM_ID: image-size
:END:
Adjust image size using =gnosis-image-height= & =gnosis-image-width=

Example:
#+begin_src emacs-lisp
(setf gnosis-image-height 300
      gnosis-image-width 300)
#+end_src
** Typos | String Comparison
You can adjust =gnosis-string-difference=, this is a threshold value
for string comparison that determines the maximum acceptable
Levenshtein distance between two strings, which identifies their
similarity

Let's illustrate with an example:
#+begin_src emacs-lisp
(setf gnosis-string-difference 1)
#+end_src

In this scenario, we set =gnosis-string-difference= to 1. This implies
that two strings will be recognized as similar if they exhibit a
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."
* Gnosis Algorithm

Each gnosis note has a gnosis score, which is a list of 3 values,
(gnosis-plus gnosis-minus gnosis-synolon/total).  Gnosis-synolon is
what is used to determine the next interval upon a successful recall,
gnosis-plus is added to gnosis-synolon upon a successful recall as
well, gnosis-minus is subtracted from gnosis-synolon upon failing to
recall a note's answer.

Gnosis has 2 special events, one is ~anagnosis~ /ανάγνωση/ and ~lethe~ /λήθη/.
** Anagnosis Event
~Anagnosis~, which means comprehension & recognition of knowledge, is
triggered when the consecutive successful or failed recalls are equal
or greater to anagnosis value.

When ~anagnosis~ is triggered by consecutive *successful* recalls,
~epignosis~ value is added to gnosis-plus.  /Epignosis means accuracy of knowledge/.

When ~anagnosis~ is triggered by consecutive *failed* recalls,
~agnoia~ value is added to gnosis-minus. /Agnoia means lack of knowledge/

You can set specific values for each deck and tag of the variables
mentioned above by adjusting =gnosis-custom-values=.

** Proto

The default initial interval is defined at
=gnosis-algorithm-proto=, you can define a custom initial interval
for each deck as well.

=gnosis-algorithm-interval= is a list of numbers, representing the
first initial intervals for successful reviews.  There is no limit on
the length of the list.

Example:

#+begin_src emacs-lisp
  (setq gnosis-algorithm-interval '(0 1 2 30))
#+end_src

Upon each successful note review, the algorithm will increment to the
next interval value: 0 days (0), 1 day later (1), 2 days later
(2), and 30 days later.

Upon failing to review a note without completing it's proto successful reviews,
it's next review date will be on the same date.

* Editing notes
+ Currently there are 2 ways for editing notes:

    + You can edit a note after review by pressing ~e~
    + Open =gnosis-dashboard= with =M-x gnosis-dashboard=, find the note you want to edit and press ~e~
* Configuring Note Types
** Custom Note Types
Each gnosis note type has an /interactive/ function, named
=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:

#+begin_src emacs-lisp
  (defun gnosis-add-note-custombasic (deck)
    (gnosis-add-note--basic :deck deck
  			  :question (gnosis-read-string-from-buffer "Question: " "")
  			  :answer (read-string "Answer: ")
  			  :hint (gnosis-hint-prompt gnosis-previous-note-hint)
  			  :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_src

Now ~custombasic~ is available as a note type, for which you won't be prompted to enter
anything for ~extra~ & ~images~.

** Development
To make development and customization easier, gnosis comes with
=gnosis-test= module, that should be used to create a custom database for
testing.

To exit the testing environment, rerun =M-x gnosis-test-start= and
then enter =n= (no) at the prompt "Start development env?"

* Sync between devices

Gnosis uses git to maintain data integrity and facilitate
synchronization across devices.

You will need to configure your remote manually.

Example:

#+begin_src bash
 cd ~/.emacs.d/gnosis # default location for gnosis, no-littering is ~/.emacs.d/var/gnosis
 git init # After completing your first review session, a git repo should have been initialized automatically.
 git remote add origin <remote_url>
 git push --set-upstream origin master
#+end_src


You can interactively use =gnosis-vc-push= & =gnosis-vc-pull=. As the
name suggests, they rely on =vc= to work properly.

Depending on your setup, =vc= might require an external package for
the ssh passphrase dialog, such as ~x11-ssh-askpass~.

To automatically push changes after a review session, add this to your configuration:
#+begin_src emacs-lisp
(setf gnosis-vc-auto-push t)
(gnosis-vc-pull) ;; Run vc-pull for gnosis on startup
#+end_src

* Interactions with other software
** emacs-no-littering

If you are a user of [[https://github.com/emacscollective/no-littering][emacs-no-littering]], you can theme Gnosis to fit
its standards by adding the following snippet to your configuration:

#+begin_src emacs-lisp
(setq gnosis-dir (no-littering-expand-var-file-name "gnosis/"))
#+end_src

This sets =gnosis-dir= to =~/.emacs.d/var/gnosis=, in line with the folders of other packages.
* Contributing

Thank you for considering contributing back to gnosis.  You can
contribute by submitting a pull request on the codeberg mirror
repository, or directly sending me patch via email.

** How to create a patch

/Example:/

#+begin_src bash
$ git clone https://git.thanosapollo.com/gnosis.git && cd gnosis
$ emacs something
$ git add something
$ git commit -m "Fix something"
$ git format-patch HEAD^1
0001-Fix-something.patch
#+end_src

You can sent the patch to "Thanos Apollo", the email of which you can
find on the git log.
