Function: mpc-cmd-find
mpc-cmd-find is a byte-compiled function defined in mpc.el.gz.
Signature
(mpc-cmd-find TAG VALUE)
Documentation
Return a list of all songs whose tag TAG has value VALUE.
The songs are returned as alists.
Source Code
;; Defined in /usr/src/emacs/lisp/mpc.el.gz
(defun mpc-cmd-find (tag value)
"Return a list of all songs whose tag TAG has value VALUE.
The songs are returned as alists."
(or (gethash (cons tag value) mpc--find-memoize)
(puthash (cons tag value)
(cond
((eq tag 'Playlist)
;; Special case for pseudo-tag playlist.
(let ((l (condition-case nil
(mpc-proc-buf-to-alists
(mpc-proc-cmd (list "listplaylistinfo" value)))
(mpc-proc-error
;; "[50@0] {listplaylistinfo} No such playlist"
nil)))
(i 0))
(mapcar (lambda (s)
(prog1 (cons (cons 'Pos (number-to-string i)) s)
(incf i)))
l)))
((eq tag 'Search)
(mpc-proc-buf-to-alists
(mpc-proc-cmd (list "search" "any" value))))
((eq tag 'Directory)
(let ((entries
(mpc-proc-buf-to-alists
(mpc-proc-cmd (list "listallinfo" value)))))
;; Strip away the `directory' entries because our callers
;; currently don't know what to do with them.
(delq nil (mapcar (lambda (entry)
(if (eq (caar entry) 'directory)
nil entry))
entries))))
((string-match "|" (symbol-name tag))
(add-to-list 'mpc--find-memoize-union-tags tag)
(let ((tag1 (intern (substring (symbol-name tag)
0 (match-beginning 0))))
(tag2 (intern (substring (symbol-name tag)
(match-end 0)))))
(mpc-union (mpc-cmd-find tag1 value)
(mpc-cmd-find tag2 value))))
(t
(condition-case nil
(mpc-proc-buf-to-alists
(mpc-proc-cmd (list "find" (symbol-name tag) value)))
(mpc-proc-error
;; If `tag' is not one of the expected tags, MPD burps
;; about not having the relevant table. FIXME: check
;; the kind of error.
(error "Unknown tag %s" tag)
(let ((res ()))
(setq value (cons tag value))
(dolist (song (mpc-proc-buf-to-alists
(mpc-proc-cmd "listallinfo")))
(if (member value song) (push song res)))
res)))))
mpc--find-memoize)))