# to update: cat $HOME/plumbing | 9p write plumb/rules

editor = acme

#git commit messages
type is text
data matches 'commit ([0-9a-f]+)'
plumb start rc -c 'cd '$wdir'; git show '$1' >[2=1] | plumb -i -d edit -a ''action=showdata filename=/'$1''''

# OCaml error messages: example: in file "foo/bar.ml", line 155, characters 30-62
type is text
data matches '.*[Ff]ile "([^"]+)", line ([0-9]+), characters ([0-9]+)-([0-9]+).*'$nl'?'
arg isfile $1
data set $file
attr add addr=$2-#0+#$3,$2-#0+#$4
plumb to edit
plumb client $editor

# OCaml error messages: example: File "tests/dune", line 2, characters 7-22:
type is text
data matches '.*[Ff]ile "([^"]+)", lines ([0-9]+)-([0-9]+).*'$nl'?'
arg isfile $1
data set $file
attr add addr=$2,$3
plumb to edit
plumb client $editor

# postscript/pdf/dvi go to page but not over the a plumb port
# the port is here for reference but is unused
type is text
data matches '[a-zA-Z¡-￿0-9_\-./]+'
data matches '([a-zA-Z¡-￿0-9_\-./]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI)'
arg isfile      $0
plumb to postscript
plumb start zathura $file

# urls go to web browser
type is text
data matches '(https?|ftp|file|gopher|mailto|news|nntp|telnet|wais|prospero)://[a-zA-Z0-9_@\-]+([.:][a-zA-Z0-9_@\-]+)*/?[a-zA-Z0-9_?,%#~&/\-+=]+([:.][a-zA-Z0-9_?,%#~&/\-+=\(\)]+)*'
plumb to web
plumb start sockedsurf $0

# html/htm files go to web browser
type is text
data matches '[.a-zA-Z¡-￿0-9_\-]([.a-zA-Z¡-￿0-9_/\-]*[a-zA-Z¡-￿0-9_/\-])\.html?'
arg isfile      $0
data set        file://$file
plumb to web
plumb start sockedsurf $data

# websites with common, known TLDs go to web browser
type is text
data matches '[.a-zA-Z0-9\-]+\.(org|com|net|fr|co.uk|org.uk)(/[.a-zA-Z0-9/\-]*)?'
plumb to web
plumb start sockedsurf $0

# image files go to sxiv
type is text
data matches '([a-zA-Z¡-￿0-9_\-./]+)\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|bit|png|PNG)'
arg isfile      $0
plumb to image
plumb start 9 sxiv $file

#various text files go to editor
type is text
data matches 'Makefile|mkfile|README|INSTALL|PKGBUILD|LICENSE|\.gitignore|\..*rc'
arg isfile      $0
data set        $file
plumb to edit
plumb client $editor

#various files (by extension) go to editor
type is text
data matches '([a-zA-Z0-9_\-./]+)\.(txt|diff|patch|ml|mli|mly|mll|c|h|pdc|tex)'
arg isfile      $0
data set        $file
plumb to edit
plumb client $editor

include basic
