Skip to content

Commit

Permalink
Huge improvements to the app/playlist program
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauan committed Feb 19, 2012
1 parent c0b9624 commit 387b145
Show file tree
Hide file tree
Showing 6 changed files with 317 additions and 101 deletions.
3 changes: 2 additions & 1 deletion 04 parameters.arc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

(mac parameterize (parms . body)
`(%no:#%parameterize ,(pair %.ac-all.parms)
,@%.ac-all.body))
;; TODO: function for this pattern...?
,@(%.ac-all %.nilify.body)))

(mac make-w/ (x)
`(mac ,(sym:string "w/" x) (v . body)
Expand Down
4 changes: 2 additions & 2 deletions 05 paths.arc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@

(def todir (x)
(zap string x)
;; TODO: last
(if (is (x:- len.x 1) #\/)
;; TODO: last
(if (or empty.x (is (x:- len.x 1) #\/))
x
(string x "/")))

Expand Down
8 changes: 4 additions & 4 deletions 06 import.arc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
;(load:string %.exec-dir "lib/04 namespaces.arc")


(parameter debug? t)
(parameter debug? nil)

(redef debug args
(when debug?
(apply prn (intersperse " " args))))
(apply prn args))) ;(intersperse " " )


(parameter import-dirs (list cwd
Expand Down Expand Up @@ -47,8 +47,8 @@
(fn (path name)
(let path abspath.path
(if import-cache.path
(debug " skipping:" name)
(do (debug " loading: " name)
(debug " skipping: " name)
(do (debug " loading: " name)
(= import-cache.path t)
(w/import-loading t load.path)))))))

Expand Down
45 changes: 39 additions & 6 deletions app/playlist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ It will then store those .xspf playlists in the "Playlists" folder.
The S-expression Playlist Format
================================

All playlists are composed of two or more S-expressions. The only required
S-expressions are `title` and `playlist`:
All playlists are composed of one or more S-expressions. The only required
S-expression is `title`. The playlist can then optionally include files via
either the `include` or `playlist` expressions. Here's an example of a simple
playlist:

(title "foo")

Expand Down Expand Up @@ -58,16 +60,17 @@ There are three error conditions:
3. If a pattern does not match any file, an error will be raised.


To create a playlist, simply create a new file in the "Templates" folder and
place the two required S-expressions inside the file: that's it! Now just run
the program as specified in "How to run".
To create a playlist, simply create a new file in the "Templates" folder,
place a `title` expression inside the file, then add an `include` or
`playlist` expression (or both): that's it! Now just run the program as
specified in "How to run".


Including other playlists
=========================

If you wish to combine multiple different playlists into a single one, you can
use the `include` S-expression:
use the `include` S-expression at the top level:

(include "bar"
"qux")
Expand All @@ -76,6 +79,35 @@ The above will find the playlists "bar" and "qux" and include them into the
current playlist. If any of the included playlists do not exist, a warning
will be displayed.

It is also possible to *selectively* include only parts of another playlist by
using the `w/playlist` form:

(playlist
(w/playlist "foo"
"qux"
"corge")

(w/playlist "bar"
"nou"
"yes"))

The above will include the files "qux" and "corge" from the "foo" playlist, in
addition to the "nou" and "yes" files from the "bar" playlist. Just like
normal file matching, you can use sub-strings when adding files from a
playlist.

One caveat when including files from another playlist: the program will always
correctly include files regardless of what order the templates are loaded in.
But the program can't handle infinite loops:

(title "foo")
(include "bar")

(title "bar")
(include "foo")

The above two playlists will cause the program to never terminate.


Limiting the scope of a pattern
===============================
Expand All @@ -100,6 +132,7 @@ S-expression, you can use the `w/folder` S-expression:
"foo"
"bar"
"qux")

(w/folder "other/path/to"
"foo"
"bar"
Expand Down
Loading

0 comments on commit 387b145

Please sign in to comment.