Scripting hooks allows CotEditor scripts to be executed on certain events. The following events are available with CotEditor:
document opened: after you opened the file and then the contents was loadeddocument saved: after you saved the file and then the contents was stored
See CotEditor Event Handler suite section on AppleScript Dictionary for further information.