Stop running org-pomodoro-tick in quick succession #79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When Emacs is under load, the functions run by
run-at-time
can be delayed. This is particularly an issue for theorg-pomodoro-tick
function, because it runs every second. However, when therun-at-time
functions are finally run, they're all run at once, right after another. Now that I've enabled playing tick sounds, this is particularly annoying, because running all these hooks at once causes the tick sounds to be played right after each other.To alleviate this, I've done two things:
Add a
org-pomodoro-next-tick-time
variable. This is set to the beginning of the following second wheneverorg-pomodoro-tick
is run. Iforg-pomodoro-tick
is run multiple times in quick succession, only the first time will run the contents of the function, including the tick sounds and theorg-pomodoro-tick-hook
functions, until the beginning of the next second.Update the mode line and play the tick sounds before running the hooks. This ensures that long hook functions don't cause the tick sounds to play out of rhythm.