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

Refine zetteldeft-generate-id to allow rapid unique ID generation #125

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

localauthor
Copy link
Contributor

@localauthor localauthor commented Nov 20, 2021

Fix #71

Adds a loop to check if ID is unavailable, incrementing ID until it is unique.

Avoids error message and the need to wait for time to change in order to create a unique ID.

@EFLS
Copy link
Owner

EFLS commented Nov 20, 2021

Ooh this is great, and looks like a neat solution too. Thanks for submitting, I'll try to take a closer look and merge soon

@EFLS
Copy link
Owner

EFLS commented Dec 14, 2021

Finally was able to take a look at this. Thanks, I've made some changes so the new code is included in zetteldeft.org (which zetteldeft.el is tangled from).

I'm still wondering about one edge case though: if a user has a zetteldeft-custom-id-function that generates text-based IDs rather than number-based IDs, the (1+ won't work. But then again, that's such an edge case that it might not be needed to take into account at this moment...

Adds a loop to check if ID is unavailable, incrementing ID until it is unique
Avoids error message and the need to wait for time to change in orer to
create a unique ID.
@localauthor
Copy link
Contributor Author

I accidentally pushed an update before I saw your changes to zetteldeft.org. I've added them back in a separate commit. Sorry about that.

The update accounts for the use of dashes in the default zetteldeft-id-format.

And I think you're right about edge cases. Perhaps best to consider them if/when anyone raises an issue.

@maw
Copy link
Contributor

maw commented Oct 12, 2022

I worked around the clashing ID problem by saying (setq zetteldeft-id-format "%Y-%m-%d-%H%M%S") but this is obviously better. (I also went through older notes and added 00 to make everything line up.)

An easy way to test this change, then, would be to temporarily use something ridiculously clash-prone, eg just "%Y-%m-%d".

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

Successfully merging this pull request may close these issues.

Generated IDs are not unique when multiple per minute are created
3 participants