emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112261: * lisp/mpc.el (mpc-proc): Ad


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112261: * lisp/mpc.el (mpc-proc): Add `restart' argument.
Date: Wed, 10 Apr 2013 09:17:27 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 112261
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2013-04-10 09:17:27 -0400
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/mpc.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-04-09 17:31:17 +0000
+++ b/lisp/ChangeLog    2013-04-10 13:17:27 +0000
@@ -1,3 +1,11 @@
+2013-04-10  Stefan Monnier  <address@hidden>
+
+       * 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.
+
 2013-04-10  Masatake YAMATO  <address@hidden>
 
        * progmodes/sh-script.el: Implement `sh-mode' own

=== modified file 'lisp/mpc.el'
--- a/lisp/mpc.el       2013-03-29 14:23:24 +0000
+++ b/lisp/mpc.el       2013-04-10 13:17:27 +0000
@@ -320,10 +320,11 @@
     (if tmp (push (nreverse tmp) alists))
     (nreverse alists)))
 
-(defun mpc-proc ()
+(defun mpc-proc (&optional restart)
   (unless (and mpc-proc
                (buffer-live-p (process-buffer mpc-proc))
-               (not (memq (process-status mpc-proc) '(closed))))
+               (not (and restart
+                         (memq (process-status mpc-proc) '(closed)))))
     (mpc--proc-connect mpc-host))
   mpc-proc)
 
@@ -356,7 +357,7 @@
 when the command terminates.
 CMD can be a string which is passed as-is to MPD or a list of strings
 which will be concatenated with proper quoting before passing them to MPD."
-  (let ((proc (mpc-proc)))
+  (let ((proc (mpc-proc 'restart)))
     (if (and callback (not (process-get proc 'ready)))
         (let ((old (process-get proc 'callback)))
           (process-put proc 'callback
@@ -491,10 +492,10 @@
     (cancel-timer mpc--status-timer)
     (setq mpc--status-timer nil)))
 (defun mpc--status-timer-run ()
-  (when (process-get (mpc-proc) 'ready)
     (condition-case err
-        (with-local-quit (mpc-status-refresh))
-      (error (message "MPC: %s" err)))))
+      (when (process-get (mpc-proc) 'ready)
+        (with-local-quit (mpc-status-refresh)))
+    (error (message "MPC: %s" err))))
 
 (defvar mpc--status-idle-timer nil)
 (defun mpc--status-idle-timer-start ()
@@ -1177,14 +1178,15 @@
 
 (defun mpc-status-buffer-show ()
   (interactive)
-  (let* ((buf (mpc-proc-buffer (mpc-proc) 'status))
-         (songs-buf (mpc-proc-buffer (mpc-proc) 'songs))
+  (let* ((proc (mpc-proc))
+         (buf (mpc-proc-buffer proc 'status))
+         (songs-buf (mpc-proc-buffer proc 'songs))
          (songs-win (if songs-buf (get-buffer-window songs-buf 0))))
     (unless (buffer-live-p buf)
       (setq buf (get-buffer-create "*MPC-Status*"))
       (with-current-buffer buf
         (mpc-status-mode))
-      (mpc-proc-buffer (mpc-proc) 'status buf))
+      (mpc-proc-buffer proc 'status buf))
     (if (null songs-win) (pop-to-buffer buf)
       (let ((_win (split-window songs-win 20 t)))
         (set-window-dedicated-p songs-win nil)
@@ -1692,13 +1694,14 @@
   (mpc-event-set-point event)
   (let ((name (buffer-substring (line-beginning-position)
                                 (line-end-position)))
-        (prop (intern mpc-tag)))
-    (if (not (member name (process-get (mpc-proc) prop)))
-        (process-put (mpc-proc) prop
-                     (cons name (process-get (mpc-proc) prop)))
-      (let ((new (delete name (process-get (mpc-proc) prop))))
+        (prop (intern mpc-tag))
+        (proc (mpc-proc)))
+    (if (not (member name (process-get proc prop)))
+        (process-put proc prop
+                     (cons name (process-get proc prop)))
+      (let ((new (delete name (process-get proc prop))))
         (setq name (concat name "/"))
-        (process-put (mpc-proc) prop
+        (process-put proc prop
                      (delq nil
                            (mapcar (lambda (x)
                                      (if (string-prefix-p name x)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]