diff options
author | William Xu <william.xwl@gmail.com> | 2009-11-27 21:54:46 +0800 |
---|---|---|
committer | William Xu <william.xwl@gmail.com> | 2009-11-27 21:54:46 +0800 |
commit | 90f3ed8450328cdf5677458bde6cab872f547461 (patch) | |
tree | 22658a189c0eb3b50d990e94fc0ce563fb163c1a /lisp | |
parent | e54c755ce0c2ef19bfcd4cdca995e4d2bc3b2703 (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')
-rw-r--r-- | lisp/emms-cue.el | 29 | ||||
-rw-r--r-- | lisp/emms-setup.el | 3 |
2 files changed, 30 insertions, 2 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 diff --git a/lisp/emms-setup.el b/lisp/emms-setup.el index c8cc2ae..a5bd504 100644 --- a/lisp/emms-setup.el +++ b/lisp/emms-setup.el @@ -143,7 +143,8 @@ on the edge." ;; setup (add-hook 'emms-player-started-hook 'emms-last-played-update-current) (emms-score 1) - (emms-playlist-limit 1)) + (emms-playlist-limit 1) + (add-to-list 'emms-info-functions 'emms-info-cueinfo)) ;;;###autoload (defun emms-default-players () |