From e5d73624023cb9bf0ec929985f35e935090b40f0 Mon Sep 17 00:00:00 2001 From: Holger Dürer Date: Sat, 12 Feb 2022 15:14:40 +0100 Subject: Fix the timers for auto-updating of relative timestamps. I have no idea how this ever worked, already the original commit (https://github.com/mooseyboots/mastodon.el/commit/746694f0ea75f5fa76739d49509836ccd67d7d65?utm_source=pocket_mylist) seems to have passed a time instead of seconds. The docs for `run-at-time` (https://www.gnu.org/software/emacs/manual/html_node/elisp/Timers.html) make it clear that this cannot work. Now we keep the absolute times but upon calling `run-at-time` we convert that to relative seconds from now. --- lisp/mastodon-tl.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 8921259..cdb4aa2 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1269,7 +1269,7 @@ is a no-op." ;; We need to re-schedule for an earlier time (cancel-timer mastodon-tl--timestamp-update-timer) (setq mastodon-tl--timestamp-update-timer - (run-at-time this-update + (run-at-time (time-to-seconds (time-subtract this-update (current-time))) nil ;; don't repeat #'mastodon-tl--update-timestamps-callback (current-buffer) nil))))))) @@ -1322,7 +1322,9 @@ from the start if it is nil." (copy-marker previous-timestamp)) ;; otherwise we are done for now; schedule a new run for when needed (setq mastodon-tl--timestamp-update-timer - (run-at-time mastodon-tl--timestamp-next-update + (run-at-time (time-to-seconds + (time-subtract mastodon-tl--timestamp-next-update + (current-time))) nil ;; don't repeat #'mastodon-tl--update-timestamps-callback buffer nil)))))))) @@ -1372,7 +1374,9 @@ JSON is the data returned from the server." update-function ,update-function) mastodon-tl--timestamp-update-timer (when mastodon-tl--enable-relative-timestamps - (run-at-time mastodon-tl--timestamp-next-update + (run-at-time (time-to-seconds + (time-subtract mastodon-tl--timestamp-next-update + (current-time))) nil ;; don't repeat #'mastodon-tl--update-timestamps-callback (current-buffer) @@ -1402,7 +1406,9 @@ Runs synchronously." ,update-function) mastodon-tl--timestamp-update-timer (when mastodon-tl--enable-relative-timestamps - (run-at-time mastodon-tl--timestamp-next-update + (run-at-time (time-to-seconds + (time-subtract mastodon-tl--timestamp-next-update + (current-time))) nil ;; don't repeat #'mastodon-tl--update-timestamps-callback (current-buffer) -- cgit v1.2.3