Cancel proced auto update timer if no proced buffers are open

* lisp/proced.el (proced-auto-update-timer): Cancel timer if no proced
buffers are open.
This commit is contained in:
Laurence Warne 2022-11-15 18:48:40 +00:00 committed by Eli Zaretskii
parent 7b09ed28ba
commit 07705f5ddc

View 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.