aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--doc/emms.texinfo10
-rw-r--r--lisp/emms-browser.el39
3 files changed, 41 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index 57bd8e3..eb6e5be 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
News since version 4.0:
- Change the default behavior of C-k in emms-playlist-mode.
+ - Covers can have several extensions. See
+ `emms-browser-covers-file-extensions'.
News since version 3.0:
diff --git a/doc/emms.texinfo b/doc/emms.texinfo
index bdba130..1bfc91b 100644
--- a/doc/emms.texinfo
+++ b/doc/emms.texinfo
@@ -1799,11 +1799,11 @@ Show all files that are not in the pending directory:
@section Displaying Covers
The browser will attempt to display cover images if they're
-available. By default it looks for images cover_small.jpg,
-cover_med.jpg, etc. Customize @var{emms-browser-covers} to use your
-own covers. Note that you'll probably want to resize your existing
-covers to particular sizes. Suggested sizes are 100x100 for small, and
-200x200 for medium.
+available. By default it looks for images @file{cover_small.jpg},
+@file{cover_med.jpg}, etc. Customize @var{emms-browser-covers} and
+@var{emms-browser-covers-file-extensions} to use your own covers. Note
+that you'll probably want to resize your existing covers to particular
+sizes. Suggested sizes are 100x100 for small, and 200x200 for medium.
Also, Emacs by default will jump around a lot when scrolling a buffer
with images. In order to prevent that, you can set
diff --git a/lisp/emms-browser.el b/lisp/emms-browser.el
index 271ac73..b6d00c4 100644
--- a/lisp/emms-browser.el
+++ b/lisp/emms-browser.el
@@ -332,7 +332,7 @@ view with lots of 1-track elements."
:type 'function)
(defcustom emms-browser-covers
- '("cover_small.jpg" "cover_med.jpg" "cover_large.jpg")
+ '("cover_small" "cover_med" "cover_large")
"*Control how cover images are found.
Can be either a list of small, medium and large images (large
currently not used), a function which takes a directory and one
@@ -341,6 +341,17 @@ path to the cover, or nil to turn off cover loading."
:group 'emms-browser
:type '(choice list function boolean))
+(defcustom emms-browser-covers-file-extensions
+ '("jpg" "jpeg" "png" "gif" "bmp")
+ "*File extensions accepted for `emms-browser-covers'.
+Should be a list of extensions as strings. Should be set before
+emms-browser is required."
+ :group 'emms-browser
+ :type '(repeat (string :tag "Extension")))
+
+(defconst emms-browser--covers-filename nil
+ "*List of potential cover art names.")
+
(defcustom emms-browser-default-covers nil
"*A list of default images to use if a cover isn't found."
:group 'emms-browser
@@ -1599,6 +1610,19 @@ included."
;; Album covers
;; --------------------------------------------------
+(defun emms-browser--build-cover-filename ()
+ "Build `emms-browser--covers-filename'.
+
+Based on from `emms-browser-covers' and
+`emms-browser-covers-file-extensions'."
+ (setq emms-browser--covers-filename
+ (mapcar (lambda (cover)
+ (if (file-name-extension cover)
+ (list cover)
+ (mapcar (lambda (ext) (concat cover "." ext))
+ emms-browser-covers-file-extensions)))
+ emms-browser-covers)))
+
(defun emms-browser-get-cover-from-album (bdata &optional size)
(assert (eq (emms-browser-bdata-type bdata) 'info-album))
(let* ((track1data (emms-browser-bdata-data bdata))
@@ -1608,6 +1632,8 @@ included."
(defun emms-browser-get-cover-from-path (path &optional size)
"Return a cover filename, if it exists."
+ (unless emms-browser--covers-filename
+ (emms-browser--build-cover-filename))
(unless size
(setq size 'medium))
(let* ((size-idx (cond
@@ -1620,10 +1646,13 @@ included."
(funcall emms-browser-covers (file-name-directory path) size))
((and (listp emms-browser-covers)
(nth size-idx emms-browser-covers))
- (concat (file-name-directory path)
- (nth size-idx emms-browser-covers))))))
- (if (and cover
- (file-readable-p cover))
+ (car (delq nil
+ (mapcar (lambda (cover)
+ (let ((coverpath
+ (concat (file-name-directory path) cover)))
+ (and (file-exists-p coverpath) coverpath)))
+ (nth size-idx emms-browser--covers-filename))))))))
+ (if (and cover (file-readable-p cover))
cover
;; no cover found, use default
(when emms-browser-default-covers