Next: , Previous: Browser Interface, Up: The Browser


20.2 Filtering Tracks

If you want to display a subset of your collection (such as a directory of 80s music, only avi files, etc.) then you can extend the Browser by defining “filters”.

Show everything:

     (emms-browser-make-filter "all" 'ignore)

Set "all" as the default filter:

     (emms-browser-set-filter (assoc "all" emms-browser-filters))

Show all files (no streamlists, etc):

     (emms-browser-make-filter
      "all-files" (emms-browser-filter-only-type 'file))

Show only tracks in one folder:

     (emms-browser-make-filter
      "80s" (emms-browser-filter-only-dir "~/Mp3s/80s"))

Show all tracks played in the last month:

     (emms-browser-make-filter
      "last-month" (emms-browser-filter-only-recent 30))

After executing the above commands, you can use M-x emms-browser-show-all, emms-browser-show-80s, etc to toggle between different collections. Alternatively you can use '<' and '>' to cycle through the available filters.

The second argument to make-filter is a function which returns t if a single track should be filtered. You can write your own filter functions to check the type of a file, etc.

Show only tracks not played in the last year:

     (emms-browser-make-filter "not-played"
      (lambda (track)
       (not (funcall (emms-browser-filter-only-recent 365) track))))

Show all files that are not in the pending directory:

     (emms-browser-make-filter
      "all"
      (lambda (track)
        (or
         (funcall (emms-browser-filter-only-type 'file) track)
         (not (funcall
               (emms-browser-filter-only-dir "~/Media/pending") track)))))