From 843c1142e82f2f350737f4a5088d03c1478f5235 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Thu, 25 Jul 2024 12:37:34 +0200 Subject: [PATCH] Use timer accessors instead of aref/aset * lisp/emacs-lisp/timer-list.el (list-timers): * lisp/gnus/mail-source.el (mail-source-start-idle-timer): * lisp/play/gamegrid.el (gamegrid-set-timer): * lisp/progmodes/vhdl-mode.el (vhdl-run-when-idle): * lisp/simple.el (analyze-text-conversion): * lisp/time.el (display-time-event-handler): Use timer accessors. (cherry picked from commit e56e4b345a25194bc7adb83523e8d886b718c9fa) --- lisp/emacs-lisp/timer-list.el | 12 +++++------- lisp/gnus/mail-source.el | 5 ++--- lisp/play/gamegrid.el | 6 +----- lisp/progmodes/vhdl-mode.el | 2 +- lisp/simple.el | 3 +-- lisp/time.el | 4 ++-- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/lisp/emacs-lisp/timer-list.el b/lisp/emacs-lisp/timer-list.el index 52309a247c0..c237eeb52af 100644 --- a/lisp/emacs-lisp/timer-list.el +++ b/lisp/emacs-lisp/timer-list.el @@ -41,23 +41,21 @@ nil `[ ;; Idle. ,(propertize - (if (aref timer 7) " *" " ") + (if (timer--idle-delay timer) " *" " ") 'help-echo "* marks idle timers" 'timer timer) ;; Next time. ,(propertize - (let ((time (list (aref timer 1) - (aref timer 2) - (aref timer 3)))) + (let ((time (timer--time timer))) (format "%12s" (format-seconds "%dd %hh %mm %z%,1ss" (float-time - (if (aref timer 7) + (if (timer--idle-delay timer) time (time-subtract time nil)))))) 'help-echo "Time until next invocation") ;; Repeat. - ,(let ((repeat (aref timer 4))) + ,(let ((repeat (timer--repeat-delay timer))) (cond ((numberp repeat) (propertize @@ -73,7 +71,7 @@ (let ((cl-print-compiled 'static) (cl-print-compiled-button nil) (print-escape-newlines t)) - (cl-prin1-to-string (aref timer 5))) + (cl-prin1-to-string (timer--function timer))) 'help-echo "Function called by timer")])) (append timer-list timer-idle-list))) (tabulated-list-print)) diff --git a/lisp/gnus/mail-source.el b/lisp/gnus/mail-source.el index fdafc29f7e8..64685490ab0 100644 --- a/lisp/gnus/mail-source.el +++ b/lisp/gnus/mail-source.el @@ -954,9 +954,8 @@ See the Gnus manual for details." ;; Since idle timers created when Emacs is already in the idle ;; state don't get activated until Emacs _next_ becomes idle, we ;; need to force our timer to be considered active now. We do - ;; this by being naughty and poking the timer internals directly - ;; (element 0 of the vector is nil if the timer is active). - (aset mail-source-report-new-mail-idle-timer 0 nil))) + ;; this by being naughty and poking the timer internals directly. + (setf (timer--triggered mail-source-report-new-mail-idle-timer) nil))) (declare-function display-time-event-handler "time" ()) diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el index 36c72c5cff7..ec1f3f372fb 100644 --- a/lisp/play/gamegrid.el +++ b/lisp/play/gamegrid.el @@ -493,11 +493,7 @@ convert to an Emacs image-spec instead") (defun gamegrid-set-timer (delay) (if gamegrid-timer - (timer-set-time gamegrid-timer - (list (aref gamegrid-timer 1) - (aref gamegrid-timer 2) - (aref gamegrid-timer 3)) - delay))) + (timer-set-time gamegrid-timer (timer--time gamegrid-timer) delay))) (defun gamegrid-kill-timer () (if gamegrid-timer diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el index 144bfa944d3..22706be6bb5 100644 --- a/lisp/progmodes/vhdl-mode.el +++ b/lisp/progmodes/vhdl-mode.el @@ -2341,7 +2341,7 @@ Ignore byte-compiler warnings you might see." (if (fboundp 'start-itimer) (start-itimer "vhdl-mode" function secs repeat t) ;; explicitly activate timer (necessary when Emacs is already idle) - (aset (run-with-idle-timer secs repeat function) 0 nil))) + (setf (timer--triggered (run-with-idle-timer secs repeat function)) nil))) (defun vhdl-warning-when-idle (&rest args) "Wait until idle, then print out warning STRING and beep." diff --git a/lisp/simple.el b/lisp/simple.el index 042133bb8e2..54a64e67c4d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -11098,8 +11098,7 @@ seconds." (if timer ;; The timer is already running. See if it's due to expire ;; within the next five seconds. - (let ((time (list (aref timer 1) (aref timer 2) - (aref timer 3)))) + (let ((time (timer--time timer))) (unless (<= (time-convert (time-subtract time nil) 'integer) 5) diff --git a/lisp/time.el b/lisp/time.el index b6f8de8fc4a..02007d890cb 100644 --- a/lisp/time.el +++ b/lisp/time.el @@ -239,8 +239,8 @@ would give mode line times like `94/12/30 21:07:48 (UTC)'." (timer display-time-timer) ;; Compute the time when this timer will run again, next. (next-time (timer-relative-time - (list (aref timer 1) (aref timer 2) (aref timer 3)) - (* 5 (aref timer 4)) 0))) + (timer--time timer) + (* 5 (timer--repeat-delay timer)) 0))) ;; If the activation time is not in the future, ;; skip executions until we reach a time in the future. ;; This avoids a long pause if Emacs has been suspended for hours. -- 2.39.5