Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number Cloze deletions with consecutive IDs automatically #86

Open
abvbv opened this issue Jan 5, 2021 · 1 comment
Open

Number Cloze deletions with consecutive IDs automatically #86

abvbv opened this issue Jan 5, 2021 · 1 comment

Comments

@abvbv
Copy link

abvbv commented Jan 5, 2021

If we have the next note:

anki-editor – Emacs minor mode for making Anki cards with Org

I'd like to have two Cloze deletions:

{{c1::anki-editor::what mode}} – {{c2::Emacs minor mode for making Anki cards with Org::what does it do}}

Currently anki-editor-cloze-region and anki-editor-cloze-dwim commands insert c1 deletions by default. So we can:

  1. Create two deletions with either command and then manually change the ID of the second deletion from c1 to c2.
  2. Use optional argument before invoking a command to set a particular ID.

The problem with both approaches is that they're error prone and quite laborious, if we have more deletions.

It would be nice to have a way to insert consecutively numbered deletions automatically.

I think (but don't have any proofs) it's more common to have deletions with different, not identical, IDs. So maybe it'd be nice to change the default behavior to automatic numbering.

P.S. Thank you for anki-editor! It's an amazing tool. It makes Anki note management a much more pleasant experience.

@teeann
Copy link

teeann commented Jun 8, 2021

Hi, here's my quick fix for this. You just need to call my-anki-cloze-dwim like anki-editor-cloze-dwim

(defun my-anki-cloze-arg ()
      "Return appropriate cloze arg of current anki entry"
      (interactive)
      (let ((index 1))
	(save-excursion
	  (goto-char (org-entry-beginning-position))
	  (while
	      (search-forward (format "{{c%d::" index) (org-entry-end-position) t)
	    (cl-incf index)
	    (goto-char (org-entry-beginning-position)))
	  index)))

(defun my-anki-cloze-dwim ()
  (interactive)
  (let ((current-prefix-arg (my-anki-cloze-arg)))
    (call-interactively 'anki-editor-cloze-dwim)
    )
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants