Hi Petteri, Petteri Hintsanen <[email protected]> writes:
> New function emms-browser-get-track-field-extended uses albumartist, > originalyear and originaldate tags for grouping tracks in the browser. > It can be assigned to emms-browser-get-track-field-function. > --- > lisp/emms-browser.el | 56 > +++++++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 53 insertions(+), 3 deletions(-) > > diff --git a/lisp/emms-browser.el b/lisp/emms-browser.el > index 8a86bd2..1fc1182 100644 > --- a/lisp/emms-browser.el > +++ b/lisp/emms-browser.el > @@ -1,6 +1,6 @@ > ;;; emms-browser.el --- a track browser supporting covers and filtering > > -;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. > +;; Copyright (C) 2006, 2007, 2008, 2009, 2015 Free Software Foundation, Inc. > > ;; Author: Damien Elmes <[email protected]> > ;; Keywords: emms, mp3, mpeg, multimedia > @@ -419,6 +419,21 @@ Called once for each directory." > :group 'emms-browser > :type 'hook) > > +(defcustom emms-browser-prefer-albumartist nil > + "*Prefer albumartist tag. > +If non-nil, emms-browser-get-track-field-extended prefers > +albumartist tag over artist tag, if available." > + :group 'emms-browser > + :type 'boolean) Please make this t. I'd rather call the next EMMS v5 than hold back improvements. > +(defcustom emms-browser-prefer-originalyear nil > + "*Prefer originalyear and originaldate tags. > +If non-nil, emms-browser-get-track-field-extended prefers > +originalyear and originaldate tags over year and date tags, if > +available." > + :group 'emms-browser > + :type 'boolean) It’s not obvious that this should be off by default. Presumably, /if/ you have this tag, it should be used as long as the normal year tag is used as fallback . > +(defun emms-browser-get-track-field-extended (track type) > + "Return TYPE from TRACK. > +This function uses 'info-albumartist, 'info-originalyear, > +'info-originaldate and 'info-date symbols, if available for > +TRACK. > + > +If TYPE is 'info-year, 'info-date and 'info-originaldate are > +preferred over 'info-year and 'info-originalyear symbols. > + > +If emms-browser-prefer-albumartist is t, info-albumartist is > +preferred over info-artist. > + > +If emms-browser-prefer-originalyear is t, info-originalyear is > +preferred over info-year." IMO: This should be merged with emms-browser-get-track-field. As long as the preferred type of year and artist can be set there’s no reason to have two functions. > + (cond ((eq type 'info-artist) > + (or (when emms-browser-prefer-albumartist > + (emms-track-get track 'info-albumartist)) > + (emms-track-get track 'info-artist "misc"))) > + ((eq type 'info-year) > + (let ((date (or (when emms-browser-prefer-originalyear > + (or (emms-track-get track 'info-originaldate) > + (emms-track-get track 'info-originalyear))) > + (emms-track-get track 'info-date) > + (emms-track-get track 'info-year "misc")))) > + (emms-browser-extract-year-from-date date))) > + (t (emms-track-get track type "misc")))) > +(defun emms-browser-extract-year-from-date (date) > + "Try to extract year part from DATE. > +Return DATE if the year cannot be extracted." > + (or (nth 5 (parse-time-string date)) > + (when (string-match "^[ \t]*[0-9]\\{4\\}" date) Is there any reason for limiting only look a fields starting with the year? Can we trust that parse-time-string always catches arbitrary formats? Alternatively you could look for just 4 consecutive numbers, though this may lead to errors. As you prefer. > + (substring date (match-beginning 0) (match-end 0))) > + date)) > + > (defun emms-browser-get-track-field-use-directory-name (track type) > (if (eq type 'info-artist) > (emms-browser-get-artist-from-path > @@ -809,8 +859,8 @@ return an empty string." > tracknum))))) > (defun emms-browser-disc-number (track) > - "Return a string representation of a track number. > -The string will end in a space. If no track number is available, > + "Return a string representation of a disc number. > +The string will end in a space. If no disc number is available, > return an empty string." > (let ((discnum (emms-track-get track 'info-discnumber))) > (if (or (not (stringp discnum)) (string= discnum "0")) This is a probably a separate bug fix commit. Rasmus -- And I faced endless streams of vendor-approved Ikea furniture. . . _______________________________________________ Emms-help mailing list [email protected] https://lists.gnu.org/mailman/listinfo/emms-help
