aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Oteiza2015-10-13 14:19:18 -0400
committerMark Oteiza2015-10-13 14:25:35 -0400
commit18b0eb7f1cc16fe33f89c74d2497a6fcb4b863fd (patch)
treeebc0f8e1e4f3003902255ba4a6d21fb7511a03f0
parent6d6bf466477b004035a4314886e35214c6f8603b (diff)
downloademacs-18b0eb7f1cc16fe33f89c74d2497a6fcb4b863fd.tar.gz
emacs-18b0eb7f1cc16fe33f89c74d2497a6fcb4b863fd.zip
Fix error messages for when covers are not found.
The last change to mpc-format let the binding to file call mpc-file-local-copy with nil argument. Instead, employ if-let here so nil bindings don't result in needless computation and errors. * lisp/mpc.el: Require 'subr-x at compile time. * lisp/mpc.el (mpc-format): Use if-let.
-rw-r--r--lisp/mpc.el53
1 files changed, 27 insertions, 26 deletions
diff --git a/lisp/mpc.el b/lisp/mpc.el
index 21002ec5081..063a545da81 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -91,7 +91,9 @@
91;; UI-commands : mpc- 91;; UI-commands : mpc-
92;; internal : mpc-- 92;; internal : mpc--
93 93
94(eval-when-compile (require 'cl-lib)) 94(eval-when-compile
95 (require 'cl-lib)
96 (require 'subr-x))
95 97
96(defgroup mpc () 98(defgroup mpc ()
97 "Client for the Music Player Daemon (mpd)." 99 "Client for the Music Player Daemon (mpd)."
@@ -1008,31 +1010,30 @@ If PLAYLIST is t or nil or missing, use the main playlist."
1008 (substring time (match-end 0)) 1010 (substring time (match-end 0))
1009 time))))) 1011 time)))))
1010 (`Cover 1012 (`Cover
1011 (let* ((dir (file-name-directory 1013 (if-let ((dir (file-name-directory
1012 (mpc-file-local-copy (cdr (assq 'file info))))) 1014 (mpc-file-local-copy (cdr (assq 'file info)))))
1013 (covers '(".folder.png" "cover.jpg" "folder.jpg")) 1015 (covers '(".folder.png" "cover.jpg" "folder.jpg"))
1014 (cover (cl-loop for file in (directory-files dir) 1016 (cover (cl-loop for file in (directory-files dir)
1015 if (member (downcase file) covers) 1017 if (member (downcase file) covers)
1016 return (concat dir file))) 1018 return (concat dir file)))
1017 (file (with-demoted-errors "MPC: %s" 1019 (file (with-demoted-errors "MPC: %s"
1018 (mpc-file-local-copy cover))) 1020 (mpc-file-local-copy cover))))
1019 image) 1021 (let (image)
1020 ;; (debug) 1022 ;; (debug)
1021 (push `(equal ',dir (file-name-directory (cdr (assq 'file info)))) pred) 1023 (push `(equal ',dir (file-name-directory (cdr (assq 'file info)))) pred)
1022 (if (null file) 1024 (if (null size) (setq image (create-image file))
1023 ;; Make sure we return something on which we can 1025 (let ((tempfile (make-temp-file "mpc" nil ".jpg")))
1024 ;; place the `mpc-pred' property, as 1026 (call-process "convert" nil nil nil
1025 ;; a negative-cache. We could also use 1027 "-scale" size file tempfile)
1026 ;; a default cover. 1028 (setq image (create-image tempfile))
1027 (progn (setq size nil) " ") 1029 (mpc-tempfiles-add image tempfile)))
1028 (if (null size) (setq image (create-image file)) 1030 (setq size nil)
1029 (let ((tempfile (make-temp-file "mpc" nil ".jpg"))) 1031 (propertize dir 'display image))
1030 (call-process "convert" nil nil nil 1032 ;; Make sure we return something on which we can
1031 "-scale" size file tempfile) 1033 ;; place the `mpc-pred' property, as
1032 (setq image (create-image tempfile)) 1034 ;; a negative-cache. We could also use
1033 (mpc-tempfiles-add image tempfile))) 1035 ;; a default cover.
1034 (setq size nil) 1036 (progn (setq size nil) " ")))
1035 (propertize dir 'display image))))
1036 (_ (let ((val (cdr (assq tag info)))) 1037 (_ (let ((val (cdr (assq tag info))))
1037 ;; For Streaming URLs, there's no other info 1038 ;; For Streaming URLs, there's no other info
1038 ;; than the URL in `file'. Pretend it's in `Title'. 1039 ;; than the URL in `file'. Pretend it's in `Title'.