I've prepared a patch to add this feature (see attached file). Since this is my first contribution to this project (and also my first time sending a patch via email), it's possible I've made some mistakes along the way. Any feedback is appreciated.