aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-04-10 09:17:27 -0400
committerStefan Monnier2013-04-10 09:17:27 -0400
commit15e54145b44fc4e0e69207d1dc2bfa12f4ed0eb4 (patch)
tree172ab6aac7f106023ef19983696cb3e247a643a4
parentb60e25d6bc17deb6b553afb2cebe96e79dfadab5 (diff)
downloademacs-15e54145b44fc4e0e69207d1dc2bfa12f4ed0eb4.tar.gz
emacs-15e54145b44fc4e0e69207d1dc2bfa12f4ed0eb4.zip
* lisp/mpc.el (mpc-proc): Add `restart' argument.
(mpc-proc-cmd): Use it. (mpc--status-timer-run): Also catch signals from `mpc-proc'. (mpc-status-buffer-show, mpc-tagbrowser-dir-toggle): Call `mpc-proc' less often.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/mpc.el33
2 files changed, 26 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 01887620250..9ca8db15ccd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12013-04-10 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * mpc.el (mpc-proc): Add `restart' argument.
4 (mpc-proc-cmd): Use it.
5 (mpc--status-timer-run): Also catch signals from `mpc-proc'.
6 (mpc-status-buffer-show, mpc-tagbrowser-dir-toggle): Call `mpc-proc'
7 less often.
8
12013-04-10 Masatake YAMATO <yamato@redhat.com> 92013-04-10 Masatake YAMATO <yamato@redhat.com>
2 10
3 * progmodes/sh-script.el: Implement `sh-mode' own 11 * progmodes/sh-script.el: Implement `sh-mode' own
diff --git a/lisp/mpc.el b/lisp/mpc.el
index 9d9da27f6da..ad7381bb4b7 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -320,10 +320,11 @@ defaults to 6600 and HOST defaults to localhost."
320 (if tmp (push (nreverse tmp) alists)) 320 (if tmp (push (nreverse tmp) alists))
321 (nreverse alists))) 321 (nreverse alists)))
322 322
323(defun mpc-proc () 323(defun mpc-proc (&optional restart)
324 (unless (and mpc-proc 324 (unless (and mpc-proc
325 (buffer-live-p (process-buffer mpc-proc)) 325 (buffer-live-p (process-buffer mpc-proc))
326 (not (memq (process-status mpc-proc) '(closed)))) 326 (not (and restart
327 (memq (process-status mpc-proc) '(closed)))))
327 (mpc--proc-connect mpc-host)) 328 (mpc--proc-connect mpc-host))
328 mpc-proc) 329 mpc-proc)
329 330
@@ -356,7 +357,7 @@ otherwise return immediately and call CALLBACK with no argument
356when the command terminates. 357when the command terminates.
357CMD can be a string which is passed as-is to MPD or a list of strings 358CMD can be a string which is passed as-is to MPD or a list of strings
358which will be concatenated with proper quoting before passing them to MPD." 359which will be concatenated with proper quoting before passing them to MPD."
359 (let ((proc (mpc-proc))) 360 (let ((proc (mpc-proc 'restart)))
360 (if (and callback (not (process-get proc 'ready))) 361 (if (and callback (not (process-get proc 'ready)))
361 (let ((old (process-get proc 'callback))) 362 (let ((old (process-get proc 'callback)))
362 (process-put proc 'callback 363 (process-put proc 'callback
@@ -491,10 +492,10 @@ to call FUN for any change whatsoever.")
491 (cancel-timer mpc--status-timer) 492 (cancel-timer mpc--status-timer)
492 (setq mpc--status-timer nil))) 493 (setq mpc--status-timer nil)))
493(defun mpc--status-timer-run () 494(defun mpc--status-timer-run ()
494 (when (process-get (mpc-proc) 'ready)
495 (condition-case err 495 (condition-case err
496 (with-local-quit (mpc-status-refresh)) 496 (when (process-get (mpc-proc) 'ready)
497 (error (message "MPC: %s" err))))) 497 (with-local-quit (mpc-status-refresh)))
498 (error (message "MPC: %s" err))))
498 499
499(defvar mpc--status-idle-timer nil) 500(defvar mpc--status-idle-timer nil)
500(defun mpc--status-idle-timer-start () 501(defun mpc--status-idle-timer-start ()
@@ -1177,14 +1178,15 @@ If PLAYLIST is t or nil or missing, use the main playlist."
1177 1178
1178(defun mpc-status-buffer-show () 1179(defun mpc-status-buffer-show ()
1179 (interactive) 1180 (interactive)
1180 (let* ((buf (mpc-proc-buffer (mpc-proc) 'status)) 1181 (let* ((proc (mpc-proc))
1181 (songs-buf (mpc-proc-buffer (mpc-proc) 'songs)) 1182 (buf (mpc-proc-buffer proc 'status))
1183 (songs-buf (mpc-proc-buffer proc 'songs))
1182 (songs-win (if songs-buf (get-buffer-window songs-buf 0)))) 1184 (songs-win (if songs-buf (get-buffer-window songs-buf 0))))
1183 (unless (buffer-live-p buf) 1185 (unless (buffer-live-p buf)
1184 (setq buf (get-buffer-create "*MPC-Status*")) 1186 (setq buf (get-buffer-create "*MPC-Status*"))
1185 (with-current-buffer buf 1187 (with-current-buffer buf
1186 (mpc-status-mode)) 1188 (mpc-status-mode))
1187 (mpc-proc-buffer (mpc-proc) 'status buf)) 1189 (mpc-proc-buffer proc 'status buf))
1188 (if (null songs-win) (pop-to-buffer buf) 1190 (if (null songs-win) (pop-to-buffer buf)
1189 (let ((_win (split-window songs-win 20 t))) 1191 (let ((_win (split-window songs-win 20 t)))
1190 (set-window-dedicated-p songs-win nil) 1192 (set-window-dedicated-p songs-win nil)
@@ -1692,13 +1694,14 @@ Return non-nil if a selection was deactivated."
1692 (mpc-event-set-point event) 1694 (mpc-event-set-point event)
1693 (let ((name (buffer-substring (line-beginning-position) 1695 (let ((name (buffer-substring (line-beginning-position)
1694 (line-end-position))) 1696 (line-end-position)))
1695 (prop (intern mpc-tag))) 1697 (prop (intern mpc-tag))
1696 (if (not (member name (process-get (mpc-proc) prop))) 1698 (proc (mpc-proc)))
1697 (process-put (mpc-proc) prop 1699 (if (not (member name (process-get proc prop)))
1698 (cons name (process-get (mpc-proc) prop))) 1700 (process-put proc prop
1699 (let ((new (delete name (process-get (mpc-proc) prop)))) 1701 (cons name (process-get proc prop)))
1702 (let ((new (delete name (process-get proc prop))))
1700 (setq name (concat name "/")) 1703 (setq name (concat name "/"))
1701 (process-put (mpc-proc) prop 1704 (process-put proc prop
1702 (delq nil 1705 (delq nil
1703 (mapcar (lambda (x) 1706 (mapcar (lambda (x)
1704 (if (string-prefix-p name x) 1707 (if (string-prefix-p name x)