sminez / ad

an adaptable text editor
https://crates.io/crates/ad-editor
MIT License
265 stars 9 forks source link

Add plumbing #23

Closed sminez closed 2 months ago

sminez commented 2 months ago

Please describe the change / addition you'd like to see made

The ability to pre-define plumbing rules for default "Load" behaviour is an important part of what makes acme so powerful. On plan 9 the plumber was a separate program and it played a central role in linking together different parts of the system. At least to start with for ad, I think it would be simpler to have ad also play the role of the plumber.

Config file format

This is the default plumbing config that comes with plan9port/ and is a nice example of the sorts of plumbing rules that you can end up with for acme / plan 9. (This is an example with several custom plumbing rules).

To start with I'm not going to worry about setting up the proper plumbing ports interface used by plan 9's plumber (see the paper below) but that should be easy to extend in the future as a non-breaking change to the config file format. As and when we get to that stage, having the plumber as its own daemon process is probably the correct thing to do as it needs to be present for potentially many programs to interact with.

http://man.cat-v.org/plan_9_3rd_ed/6/plumb is the man page for how the plumbing rules look within plan 9 and for the most part I think that's the design to follow.

Some example rules:

# URLs go to web browser
type is text
data matches $protocol://$domain$file
plumb to web
plumb start window webbrowser $0

# .h files are looked up in /sys/include and passed to edit/sam
type is text
data matches '([a-zA-Z0-9]+\.h)('$addr')?'
arg isfile /sys/include/$1
data set $file
attr add addr=$3
plumb to edit
plumb start window sam $file

Is this a feature you have seen in other text editors?

This is a key feature of acme. See: