Igor Sosa Mayor <[email protected]> writes:
Hello,
I think there is a problem because filter factories are expected
to take
some value. Otherwise they aren't really factories. They are just
filters.
Registering a factory is all that is necessary to make it
available. You then
have to create a filter from that factory. In this case there is
only one that
you can create.
It is perhaps better to let the played-within factory accept nil
as a value
which would be never. Except that causes all sorts of problems
because
It's an exception, math doesn't work with nil.
I think the best never filter would be to use an inverted
played-within with
a large number. like 3650. ie. 10 years.
The played since filters are a bit strange. If you have a very big
library
you can easily end up with most or all of it in your results.
Here is how filters are made in code. They can be done
interactively on the
stack. The first two I pasted directly from emms-filters.el.
There are some duplicates because there are multiple ways to write
them.
"Not played since" is the only negated filter factory in the
system.
I threw in some extras from my Emacs config so you could see how
more complex filters are built from other filters.
The multi-filter factory is defined solely by filter names
arranged with and, or and not..
Also the names for the factories are given when they are
registered and are human readable rather than Elisp variable
names. Filter names are the same way. They are registered
upon creation and put into the filter lists.
This is how to make a bunch of filters at once.
You can also do one at a time with the non-plural version
of the same function. As you create them keep in mind
that they are composable, you can combine them later
as you are using them.
;; The fields are:
;; Factory-name New-filter-name factory args...
(emms-filters-make-filters
'(("Played since" "Played in the last month" 30)
("Not played since" "Not played since a year" 365)
("Played since" "Played in the last year" 365)
("Not played since" "Never played" 7300)
("played since" "Played since forever" 7300) ;; Not a filter
really.
("Multi-filter"
"Not played in the last year"
((:not "Played in the last year")))
("Multi-filter"
"Not played in a month"
((:not "Played in the last month")))
;; An alternative way to write a Never played filter.
("Multi-filter"
"Never played"
((:not "Played since forever")))
;; Notice the year range factory takes two years.
("Year range" "1900-1929" 1900 1929)
("Year range" "1929-1937" 1929 1937)
("Year range" "1937-1942" 1937 1942)
("Year range" "1940-1946" 1940 1946)
("Year range" "1946-1958" 1946 1958)
("Year range" "1958-" 1958 3000)
("Directory" "tangotunes" "tangotunesflac")
("Genre" "Vals" "vals")
("Genre" "Tango" "tango")
("Genre" "Milonga" "milonga")
("Genre" "Condombe" "condombe")
("Genre" "Foxtrot" "foxtrot")
;; In tango, we often dance milonga, condombe and foxtrot
;; in the same way.
("Multi-filter"
"Milonga+"
(("Milonga" "Condombe")))
("Multi-filter"
"Milonga++"
(("Milonga+" "Foxtrot")))
("Multi-filter"
"1937-1946"
(("1937-1942" "1940-1946")))
("Multi-filter"
"Vals | milonga"
(("Vals" "Milonga")))
("Multi-filter"
"Vals 1900-1929"
(("Vals") ("1900-1929")))
("Multi-filter"
"Not vals"
((:not "Vals")))
("Multi-filter"
"Vals or milonga 1900-1937"
(("Vals" "Milonga")
("1900-1929" "1929-1937")))
))
I hope that helps. This is how filters are made in code.
You can find all the default ones in emms-filters.el. I kept
them to a minimum because everyone has their own ways of looking
at their music, and not all music libraries are alike.
I have a few filters in my config, but you have the most
interesting
ones just above.
This is also documented in the EMMS manual.
Have a nice evening.
Erica
Hi Erica,
(defun emms-filters-make-filter-has-played ()
"Show only tracks that have been played."
#'(lambda (track)
(emms-track-get track 'last-played nil)))
(emms-filters-register-filter-factory "Has played"
'emms-filters-make-filter-has-played
'())
thanks a lot for the filter and for the explanation. It is
really easier
as I thought (and as I was trying to achieve it...).
Nevertheless, I
have a very simple and basic question: how is this code supposed
to
work? In the sense: where should I put this code? If I put it in
my
emms-conf.el I do not get any factory "Has played" in the filter
menu...
Sorry for the basic question.
Many thanks in advance.
Igor