Function: mpc--proc-filter

mpc--proc-filter is a byte-compiled function defined in mpc.el.gz.

Signature

(mpc--proc-filter PROC STRING)

Source Code

;; Defined in /usr/src/emacs/lisp/mpc.el.gz
(defun mpc--proc-filter (proc string)
  (mpc--debug "Receive \"%s\"" string)
  (with-current-buffer (process-buffer proc)
    (if (process-get proc 'ready)
        (if nil ;; (string-match "\\`\\(OK\n\\)+\\'" string)
            ;; I haven't figured out yet why I get those extraneous OKs,
            ;; so I'll just ignore them for now.
            nil
          (delete-process proc)
          (set-process-buffer proc nil)
          (pop-to-buffer (clone-buffer))
          (error "MPD output while idle!?"))
      (save-excursion
        (let ((start (or (marker-position (process-mark proc)) (point-min))))
          (goto-char start)
          (insert string)
          (move-marker (process-mark proc) (point))
          (beginning-of-line)
          (when (and (< start (point))
                     (re-search-backward mpc--proc-end-re start t))
            (process-put proc 'ready t)
            (unless (eq (match-end 0) (point-max))
              (error "Unexpected trailing text"))
            (let ((error-text (match-string 1)))
              (delete-region (point) (point-max))
              (let ((callback (process-get proc 'callback)))
                (process-put proc 'callback nil)
                (if error-text
                    (process-put proc 'mpc-proc-error error-text))
                (funcall callback)))))))))