aboutsummaryrefslogtreecommitdiff
path: root/lisp/emms-cue.el
diff options
context:
space:
mode:
authorWilliam Xu <william.xwl@gmail.com>2009-11-27 21:54:46 +0800
committerWilliam Xu <william.xwl@gmail.com>2009-11-27 21:54:46 +0800
commit90f3ed8450328cdf5677458bde6cab872f547461 (patch)
tree22658a189c0eb3b50d990e94fc0ce563fb163c1a /lisp/emms-cue.el
parente54c755ce0c2ef19bfcd4cdca995e4d2bc3b2703 (diff)
emms-cue.el (emms-info-cueinfo): New function for retrieving track info.
- (emms-cue-next-track): Replace find-file-noselect with emms-insert-file-contents. - emms-setup.el: Add emms-info-cueinfo to emms-info-functions.
Diffstat (limited to 'lisp/emms-cue.el')
-rw-r--r--lisp/emms-cue.el29
1 files changed, 28 insertions, 1 deletions
diff --git a/lisp/emms-cue.el b/lisp/emms-cue.el
index 03d0b28..aefcafd 100644
--- a/lisp/emms-cue.el
+++ b/lisp/emms-cue.el
@@ -28,6 +28,7 @@
;;; Code:
(require 'emms-playing-time)
+(require 'emms-info)
(defun emms-cue-next ()
"Play next track from .cue file."
@@ -57,7 +58,8 @@ When PREVIOUS-P is t, get previous track info instead."
(name (emms-track-get track 'name))
(cue (concat (file-name-sans-extension name)".cue")))
(when (file-exists-p cue)
- (with-current-buffer (find-file-noselect cue)
+ (with-temp-buffer
+ (emms-insert-file-contents cue)
(save-excursion
(if previous-p
(goto-char (point-max))
@@ -88,6 +90,31 @@ When PREVIOUS-P is t, get previous track info instead."
"See `emms-cue-next-track'."
(emms-cue-next-track t))
+(defun emms-info-cueinfo (track)
+ "Add track information to TRACK.
+This is a useful element for `emms-info-functions'."
+ (when (and (eq 'file (emms-track-type track))
+ (string-match "\\.\\(ape\\|flac\\)\\'" (emms-track-name track)))
+ (let ((cue (concat (file-name-sans-extension (emms-track-name track))
+ ".cue")))
+ (when (file-exists-p cue)
+ (with-temp-buffer
+ (emms-insert-file-contents cue)
+ (save-excursion
+ (mapc (lambda (i)
+ (goto-char (point-min))
+ (when (let ((case-fold-search t))
+ (search-forward-regexp
+ (concat (car i) " \\(.*\\)") nil t 1))
+ (emms-track-set track
+ (cdr i)
+ (replace-regexp-in-string
+ "\\`\"\\|\"\\'" "" (match-string 1)))))
+ '(("performer" . info-artist)
+ ("title" . info-album)
+ ("title" . info-title)
+ ("rem date" . info-year)))))))))
+
(provide 'emms-cue)
;;; emms-cue.el ends here