]> git.eshelyaron.com Git - emacs.git/commitdiff
Cancel proced auto update timer if no proced buffers are open
authorLaurence Warne <laurencewarne@gmail.com>
Tue, 15 Nov 2022 18:48:40 +0000 (18:48 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sun, 20 Nov 2022 11:44:10 +0000 (13:44 +0200)
* lisp/proced.el (proced-auto-update-timer): Cancel timer if no proced
buffers are open.

lisp/proced.el

index a6f1a717785276d734890559b59bd2668d2640f2..67c1cf48c1164c483d90fe2e52672b836a273875 100644 (file)
@@ -740,12 +740,18 @@ Proced buffers."
         "Type \\<proced-mode-map>\\[quit-window] to quit, \\[proced-help] for help")))))
 
 (defun proced-auto-update-timer ()
-  "Auto-update Proced buffers using `run-at-time'."
-  (dolist (buf (buffer-list))
-    (with-current-buffer buf
-      (if (and (eq major-mode 'proced-mode)
-               proced-auto-update-flag)
-          (proced-update t t)))))
+  "Auto-update Proced buffers using `run-at-time'.
+
+If there are no proced buffers, cancel the timer."
+  (unless (seq-filter (lambda (buf)
+                        (with-current-buffer buf
+                          (when (eq major-mode 'proced-mode)
+                            (when proced-auto-update-flag
+                              (proced-update t t))
+                            t)))
+                      (buffer-list))
+    (cancel-timer proced-auto-update-timer)
+    (setq proced-auto-update-timer nil)))
 
 (defun proced-toggle-auto-update (arg)
   "Change whether this Proced buffer is updated automatically.