diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2014-04-06 09:08:00 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2014-04-06 09:08:00 -0400 |
commit | 0beb7fb72378b007f67e729d34727f99b38faff3 (patch) | |
tree | a5d5d6cb03b0fb0495541424db19ddc762e1db6a /lisp/mpc.el | |
parent | 50ea0f87d6e13642ae3851e3516a5e716a39584b (diff) | |
download | emacs-0beb7fb72378b007f67e729d34727f99b38faff3.tar.gz emacs-0beb7fb72378b007f67e729d34727f99b38faff3.tar.bz2 emacs-0beb7fb72378b007f67e729d34727f99b38faff3.zip |
* lisp/mpc.el (mpc--status-timer-run): Disable timer if not displayed.
(mpc--status-idle-timer-run): Use mpc--status-timer-run.
Diffstat (limited to 'lisp/mpc.el')
-rw-r--r-- | lisp/mpc.el | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/mpc.el b/lisp/mpc.el index 921b5fc8b89..d89231e81b9 100644 --- a/lisp/mpc.el +++ b/lisp/mpc.el @@ -491,9 +491,13 @@ to call FUN for any change whatsoever.") (cancel-timer mpc--status-timer) (setq mpc--status-timer nil))) (defun mpc--status-timer-run () - (with-demoted-errors "MPC: %s" + (with-demoted-errors "MPC: %S" (when (process-get (mpc-proc) 'ready) - (with-local-quit (mpc-status-refresh))))) + (let* ((buf (mpc-proc-buffer (mpc-proc) 'status)) + (win (get-buffer-window buf t))) + (if (not win) + (mpc--status-timer-stop) + (with-local-quit (mpc-status-refresh))))))) (defvar mpc--status-idle-timer nil) (defun mpc--status-idle-timer-start () @@ -518,10 +522,8 @@ to call FUN for any change whatsoever.") ;; client starts playback, we may get a chance to notice it. (run-with-idle-timer 10 t 'mpc--status-idle-timer-run)))) (defun mpc--status-idle-timer-run () - (when (process-get (mpc-proc) 'ready) - (with-demoted-errors "MPC: %s" - (with-local-quit (mpc-status-refresh)))) - (mpc--status-timer-start)) + (mpc--status-timer-start) + (mpc--status-timer-run)) (defun mpc--status-timers-refresh () "Start/stop the timers according to whether a song is playing." |