I am planning in the long term to play with adding metadata imformation to x selections, and am looking at writing a gedit plugin as a testbed. So to get my bearings I have been playing with the reverse plugin, so that it will reverse just the selection if there is one, rather than the whole buffer. Fun.