* Org Flashcards Spaced-repetition system for use with Emacs org-mode. This package should be considered *work in progress*. I use it on a daily basis but the API regularly changes in breaking ways. #+CAPTION: Review Demo [[file:images/review.png]] ** Introduction In the most abstract sense, this package deals with 1. Attaching timestamped review information to headlines 2. Querying all headings where reviews are due 3. Reviewing due *positions* of headings As mentioned in step 3, a heading can have multiple *positions*, e.g. to implement cloze-deletions where multiple items are reviewed independently from each other. In the reviewing step, display functions can be registered by card type. This allows easy addition of user-defined card types without having to think about storing and updating review data. Review functions are called with point on the headline of the card that should be reviewed and get passed a single argument, the position to be reviewed. They are expected to return either ~'quit~ to end the review or one of ~'again~, ~'hard~, ~'good~, ~'ease~, to rate the card. See also: - [[file:doc/alternative_applications.org][Alternative Applications]] - [[file:doc/incremental_reading.org][Incremental Reading]] (todo) ** Design Goals / Choices 1. Use of =awk= for quickly finding cards due for review 2. Support for multiple *positions* in a card / heading 3. All relevant data kept in org files for easy version control 4. Review directly on the source org file for easy editing of cards during review See [[file:doc/design_choices.org][Design Choices]] for more information. ** Prior Art There are a few other packages for implementing a SRS based on org-mode. Below, I've listed a the ones I've found so far that are actively maintained and implement a lot of useful functionality. - [[https://gitlab.com/phillord/org-drill/][phillord/org-drill]] - [[https://github.com/abo-abo/pamparam][abo-abo/pamparam]] Other (open source) flashcard / spaced repetition software: - [[https://apps.ankiweb.net/][Anki]] - [[https://mnemosyne-proj.org/][Mnemosyne Project]] Thanks to the maintainers and all contributors for their work on these packages! ** Performance All user-facing commands (especially during review) should be as fast as possible (<300ms). Using the =awk= indexer, searching 2500 org files (~200k lines in total) for due flashcards takes around ~500ms on my laptop (Thinkpad L470, SSD). Using the lisp indexer based on ~org-map-entries~, searching a single 6500 line file with 333 flashcards takes ~1000ms, indexing the same file with =awk= takes around ~50ms. ** Getting Started Before using this package, ~org-fc-directories~ should be set to the directory to search for org files containing flashcards. The file used to store the review history can be customized with ~org-fc-review-history-file~ and defaults to ~.emacs.d/org-fc-reviews.tvs~. *** Setup with [[https://github.com/jwiegley/use-package/][use-package]] #+begin_src emacs-lisp (use-package hydra) (use-package org-fc :load-path "~/src/org-fc" :config (setq org-fc-directories '("~/org"))) #+end_src *** Minimal Setup Assuming [[https://github.com/abo-abo/hydra][abo-abo/hydra]] is already loaded. #+begin_src emacs-lisp (add-to-list 'load-path "/home/leon/src/org-fc/") (setq org-fc-directories '("~/org")) #+end_src *** Default Hydra [[file:org-fc-hydra.el]] defines a hydra for accessing commonly used org-fc commands and for marking headlines as flashcards. It can be loaded and bound to a hotkey like this: #+begin_src emacs-lisp (require 'org-fc-hydra) (global-set-key (kbd "C-c f") 'org-fc-hydra/body) #+end_src *** Demo Mode A file demonstrating all card types is included. ~M-x org-fc-demo~ starts a review of this file. Note that the review data of the cards in this file *is not updated*. ** Card Types This package comes with a few predefined card types. They are documented in [[file:doc/card_types.org][Card Types]]. [[file:demo.org][demo.org]] includes examples for each of these types. ** Marking Headlines as Cards A *card* is an org-mode headline with a =:fc:= tag attached to it. Each card can have multiple *positions* reviewed independently from each other, e.g. one for each hole of a cloze card. Review data (ease, interval in days, box, due date) is stored in a table in a drawer inside the card. #+begin_src org :REVIEW_DATA: | position | ease | box | interval | due | |----------+------+-----+----------+------------------------| | 2 | 2.65 | 6 | 107.13 | 2020-04-07T01:01:00 | | 1 | 2.65 | 6 | 128.19 | 2020-04-29T06:44:00 | | 0 | 2.95 | 6 | 131.57 | 2020-04-30T18:03:00 | :END: #+end_src Review results are appended to a csv file to avoid cluttering the org files. Each card needs at least two properties, an *unique* ~:ID:~ and a ~:FC_TYPE:~. In addition to that, the date a card was created (i.e. the headline was marked as a flashcard) is stored to allow making statistics for how many cards were created in the last day / week / month. #+begin_src org :PROPERTIES: :ID: 4ffe66a7-7b5c-4811-bd3e-02b5c0862f55 :FC_TYPE: normal :FC_CREATED: 2019-10-11T14:08:32 :END: #+end_src Card types (should) implement a ~org-fc-type-...-init~ command that initializes these properties and sets up the review data drawer All timestamps created and used by org-flashcards use ISO8601 format with second precision and without a timezone (timezone UTC0). This prevents flashcard due dates from showing up in the org-agenda and allows filtering for due cards by string-comparing a timestamp with one of the current time. ** (Un)suspending Cards Cards can be suspended (excluded from review) by adding a =suspended= tag, either by hand or using the ~org-fc-suspend-card~ command. All cards in the current buffer can be suspended using the ~org-fc-suspend-buffer~ command. The reason for using a per-headline tag instead of a file keyword is that this way cards stay suspended when moved to another buffer. Cards can be un-suspended using the ~org-fc-unsuspend-card~ and ~org-fc-unsuspend-buffer~ commands. If the card being unsuspended was not due for review yet, or was due less than 10% of its interval ago, its review data is not reset. If it was due by more than that, its review data is reset to the initial values. ** Spacing Algorithm This package uses a modified version of the SM2 spacing algorithm, based on the one used by Anki. See also: - [[file:doc/custom_spacing_algorithms.org][Custom Spacing Algorithms]] (todo) - [[https://apps.ankiweb.net/docs/manual.html#what-algorithm][Anki Manual - Algorithm]] - [[https://www.supermemo.com/en/archives1990-2015/english/ol/sm2][SuperMemo - SM2 Algorithm]] ** Review Reviewing cards is done by opening the file the card is in, using a special narrowing function to hide other headings and drawers. With ~(point)~ on the headline to be reviewed, the setup function for this card type is called (e.g. to hide the cloze holes of the card). Then the flip function for the card type is called, usually opening a *hydra* showing available hotkeys. Once the card is flipped, another hydra for rating the card is shown. A review session can be started using ~org-fc-review-all~ to review all cards that are due, or using ~org-fc-review-buffer~ to review only cards in the current buffer. The current review session can be ended / reset using ~org-fc-review-quit~. Ideally, don't use any other hotkeys while in a review session. This exits the review hydra without ending the current review session making it necessary to do so manually (~org-fc-review-quit~). ~org-fc-tag-card~ can be used on a card heading or during review to add one of the ~org-fc-card-tags~ to the card. Tags can be added to this list using ~(add-to-list 'org-fc-card-tags "my-tag")~. See also: - [[file:doc/review_internals.org][Review Internals]] - [[file:doc/review_history.org][Review History]] ** Dashboard / Statistics ~org-fc-dashboard~ shows a buffer with statistics for review performance and cards / card types. See also: - [[file:doc/review_history.org][Review History]] - [[file:doc/advanced_statistics.org][Advanced Statistics]] (todo) ** Updating the Card Format I hope the current card / log format is flexible enough to accommodate upcoming changes. In case a update to the org sources is needed, I'll add a changelog entry with updating instructions. ** Other Documentation - [[file:doc/internals.org][Internals]] - [[file:doc/sharing_decks.org][Sharing Decks]] (todo)