As part of my custom mode-line, I've included a feature that displays a countdown timer (timers are created using the chronos package) when it recognises that there is one running.
Works great, but the problem I have is that the mode-line only refreshes when I enter keypresses into Emacs. It will not update in the background (say I work in the browser for a bit but Emacs is still visible).
Is there any good way to force the mode-line to redisplay each second, so that the timer display stays up to date?
Relevant code
This is appended to the format-mode-line
list:
(if (>= (length chronos--timers-list) 2)
(list " timer|" (propertize (my-timer-display) 'face 'my-red-face) "| ")
"")
The my-timer-display
decides whether or not to show the timer. I think this might be the best place to get Emacs to start forcing redisplays.
(defun my-timer-display ()
"Return the lowest timer, avoiding the --now-- time, in the chronos timers list"
(if (string= (chronos--message (nth 0 (chronos--sort-by-expiry))) chronos-now-message)
(my-print-timer 1)
(my-print-timer 0)))
The my-print-timer
function referenced just returns the xth timer in the chronos timers list. I won't include it as I don't think it's relevant to the question.