louietan / anki-editor

Emacs minor mode for making Anki cards with Org
705 stars 87 forks source link

anki-editor for collaboration: prevented by using nid/note-id? instead use org-id? #21

Open 517qf opened 6 years ago

517qf commented 6 years ago

Your software is really useful as is. In fact it's so great that I had the idea to use your package to collaborate with a friend to create an Anki Deck together for one course. This is not a big project so all notes we create fit into one org-document that we want to share/sync/version via git.

But I think using note-ids prevents this: When I run anki-editor-push-notes new notes are created in Anki and their note-id is written back into a property drawer in the file. The nid/note-id is the creation time in milliseconds. When my friend get this file the note-ids in the file will not be in his collection. So they are at least useless to him (?). At the moment it's even worse: It seems that if a note-id property is present anki-editor tries to update this note. If the note is not in Anki (maybe it was deleted or it's a different profile) nothing happens and anki-editor reports a successful import. I think this shouldn't happen. Can other people replicate this behavior?

I wonder if using an org-id (an uuid) would be an alternative? This uuid will always be unique and doesn't change on import into Anki. In the Anki note the org-id could be stored in a separate field. One problem with this is that fields can always be accidently changed by a user. One option to prevent this would be to use an addon that hides such a field from the editor component (in the edit/add window and the browser). The add-on Image Occlusion Enhanced brings its own note type that has a field called 'id' which is hidden from the editor view with this function which could be extracted and reused.

I know that anki-editor wasn't created for this workflow ("it's for temporarily editing note with Org buffer in Emacs, in which case the Org file isn't meant to be kept", source). But I think this would be a great extension.

Did I miss something or would using an org-id really offer an advantage?

JayDugger commented 6 years ago

Could you use CrowdAnki for your collaboration? See the part that reads How to collaborate via Github.

Please let me know if that works for you. A superficial look at CrowdAnki's issues list doesn't show me any blockers, but I have not really tried to use CrowdAnki.

louietan commented 6 years ago

This is a good idea, but it currently can't be implemented elegantly within this minor mode.

The approach of using a specialized field for alternative identity requires a companion Anki add-on and this package to make a convention on which field to use. In addition, although it may seem to be no difference between using note id and using a field for identity from a user's perspective, querying a note by field is much slower than by note id in the sqlite database, as it doesn't have the advantage of using indexes that note id has.

If you really want to collaborate with Org documents, I have a few ideas that might help:

  1. git allows you to stage changes by hunk, which could be easily achieved by magit within Emacs, so you can commit the changes without note ids.
  2. Share the decks along with Org documents.
517qf commented 6 years ago

@louietan : I hadn't considered these technical problems. Thank you for your informative response and your hint at an alternative solution. I will definitly experiment. Thank you again for fixing my other issues.

@JayDugger: Thanks for the link. I think this is a great project but I don't like working with json. I hoped that an expansion of this tool would be a quick fix ...