/org-anki

Sync org notes to Anki via AnkiConnect

Primary LanguageEmacs LispBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

org-anki

Non-invasive minor mode to synchronize your org-mode notes to Anki.

Works via AnkiConnect add-on to Anki.[fn:via]

How

Creates “Basic” or “Cloze” type notes.

By default “Basic” cards are created where org entry’s heading is the card front and content is the back.[fn:how] If the heading has Cloze syntax ({{...}}) then the heading is used to create both the question and the answer, and content of the org entry is not used.

Tags are also synchronized.

See example.org and the resulting screenshots for how the cards look after being synced to Anki.

Commands

org-anki-sync-entry
adds or updates the current org-entry under cursor.
org-anki-update-all
updates all entries in buffer. “All” means all entries that have ANKI_NOTE_ID property set.
org-anki-sync-all
adds or updates all entries in buffer. Use #+ANKI_MATCH: some_property=”some value” at top-of-file to selectively sync matched entries. Syntax is same as the MATCH argument for org-map-entries.
org-anki-delete-entry
deletes entry from Anki. Entry must have ANKI_NOTE_ID property.
org-anki-delete-all
delete all entries with ANKI_NOTE_ID property set from Anki.
org-anki-cloze-dwim
converts a region or word under cursor to Cloze syntax, i.e {{c1::hidden text::hint text}}. This should be used in org entry’s title.
org-anki-browse-entry
Browse entry at point on anki’s browser dialog with searching nid

Setup

  • Start Anki with AnkiConnect installed
  • Set destination deck name, either as:
    • (customize-set-variable 'org-anki-default-deck "my-target-deck") in your .emacs
    • #+ANKI_DECK: my-target-deck on top of an .org file
    • :ANKI_DECK: my-target-deck in the properties’ drawer of the item
    • Note that deck mentioned in the above ways must pre-exist (it has to be separately created in the Anki app)
  • Run anki-sync-entry to sync org entry under cursor

    Note: the card browser must be closed while synchronizing, as it won’t update the note otherwise (issue).

  • Run org-anki-delete-entry to delete entry under cursor
  • Optionally configure org-anki-ankiconnnect-listen-address if AnkiConnect doesn’t listen on the default address (http://127.0.0.1:8765)

You probably want to bind org-anki-sync-entry to a key sequence, but not org-anki-delete-entry – as accidentally deleting notes will become too easy.

In any case, don’t forget to create backups, as deleting notes will lose their scheduling information.

Why

.. as there are anki-editor, pamparam, org-drill, org-fc?

Anki-editor requires subheadings for card front and card back, thus existing .org notes need to be modified to be ankified. This package takes the heading as card front and content as card back.

The other three are emacs or org-mode only[fn:others], so no spaced repetition from your phone or web.

Footnotes

[fn:via] AnkiConnect starts a HTTP server on localhost:8765 which the current package talks to.

[fn:how] It does this even if the next heading is a sub-heading (you probably don’t want subheadings in card contents anyway).

[fn:others] I mean, do you really want to use this just to use Anki?? :p