Skip to content

Commit d6a190e

Browse files
committed
add documentation about capture groups in patterns
1 parent 80d6283 commit d6a190e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ Examples:
7676
#:pattern '("^application/(x-)?(pdf)$" "^text/postscript$") ;; pdf and postscript files
7777
```
7878

79+
Patterns may also contain capture groups. You can use these capture groups in `#:program` and it's derivatives with `%1,%2,%3...`. For example:
80+
81+
``` scheme
82+
(assoc
83+
#:pattern "([0-9]+) - (.+)\.mp3"
84+
#:program 'notify-send 'Playing track number %1' 'Track name: %2'; mpv %f")
85+
;; Suppose you called `jaro "02 - From Scythe to Sceptre.mp3"`,
86+
;; It'll send a notification saying "Playing track number 2, Track name: From Scythe to Sceptre" then open it using mpv.
87+
```
88+
89+
Capture groups do not work when you use list of patterns instead of a single pattern.
90+
7991
### #:program
8092
The program to open with. This is required. This can either be a string or a list of strings. If it's a string, it will be run in a shell, like `/bin/sh`. If it's a list of strings, the program will be run directly. Before running, some substitution happens:
8193
- `%f` is replaced with given relative path, it will be the path that you called `jaro` with.

0 commit comments

Comments
 (0)