]> git.eshelyaron.com Git - emacs.git/commitdiff
Use timer accessors instead of aref/aset
authorMattias EngdegÄrd <mattiase@acm.org>
Thu, 25 Jul 2024 10:37:34 +0000 (12:37 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 27 Jul 2024 12:03:05 +0000 (14:03 +0200)
* 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
lisp/gnus/mail-source.el
lisp/play/gamegrid.el
lisp/progmodes/vhdl-mode.el
lisp/simple.el
lisp/time.el

index 52309a247c0b7b77fedff2dde3e00b046d359923..c237eeb52aff27c94e3932c7effbc323b469ff5a 100644 (file)
             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))
index fdafc29f7e82506d232aa7e12315e2365dc67f8e..64685490ab0da80a59bce3cc5f3990e0ceb00cd3 100644 (file)
@@ -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" ())
 
index 36c72c5cff7e5490d2b4e227146f70e97fad25f5..ec1f3f372fb8cdeb4ec6e18de965b1721e029898 100644 (file)
@@ -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
index 144bfa944d3e399c736c31688021db085489130b..22706be6bb57e212916899a7dbb297abd1d1a013 100644 (file)
@@ -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."
index 042133bb8e2d620c0c5e0b74d66a18a32deec03e..54a64e67c4d4992fbacec9d2cc0a145c6dcb1674 100644 (file)
@@ -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)
index b6f8de8fc4a12f3b293c8d97126bc19a902b4b7d..02007d890cbc031cc6969cc1cfd17a2bc675fec3 100644 (file)
@@ -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.