More code extracted into gedit-mode.