Closed c1-g closed 1 year ago
This looks like an useful feature!
One concern is that you're also adding the cloze hole ID, I think it would be better to use org-fc-update
for this.
Cloze cards keep track of the next hole ID in a headline property and org-fc-update
makes sure this ID is used for the new hole and the property is updated.
E.g. if you start with a card {{foo}@0} {{bar}@1}
, delete the first hole foo {{bar}@1}
, then add a new hole, foo {{bar}@1} {{baz}}
, from my understanding your code would give the new hole ID 1 whereas org-fc-update
would use ID 2.
(Unless he ID passed in as a prefix argument, but I don't see where this would be useful).
And thing-at-point
requires thingatpt
which might need to be loaded at the beginning of the file.
I'm only using this command to make cloze before running org-fc-type-cloze-init
so I don't understand the use case you've just described. Another thing to point out, this command has a really simple mechanism to determine the hole index by counting regexp I'm not sure on how to extend it to cover your example.
I guess not indexing the hole at all and just insert "{{" and "}}" to enclose the region then add some logic to call org-fc-update
when the entry has been initialized as a flashcard at the end seems like a more flexible option.
On thingatpt
, I don't think we have to load the whole library just to use a function. So we would be better off just using forward-word
and backward-word
to get the bound of a word at point.
I made some changes to use org-fc-update
as you've described. Now it doesn't index holes by default unless given a prefix argument and it uses only the bounds-of-thing-at-point
function of thingatpt
since the function will probably be better than any thing I come up with. I use declare-function
for this so no need to load the library.
Added (require 'thingatpt)
in case declare-function
isn't enough.
Sorry for taking so long to get to this, I've made merged this into the develop branch and made some changes.
For now, the function is called org-fc-type-cloze-dwim
so it's consistent with the file it's defined in.
There are some cases where marking cloze holes (without IDs) is useful for other card types
and once that's implemented, the function can be moved and renamed.
Hi @c1-g, I got a bit distracted by some other changes to org-fc but now I'm in the process of merging completed parts into the main branch. I'd like to credit you for this feature, is it alright for you if I mention you in the Changelog?
This is a command that helps me quickly make clozes.