Lexikos/AutoHotkey_L — pull request #27 by fincs (2014-04-13 13:45:15+00:00)
Title: v2: Make OnExit/OnClipboardChange accept a function

This idea is from my [v2 wish list](http://ahkscript.org/boards/viewtopic.php?f=37&t=2475), and since you didn't seem to disagree with it and I wanted to familiarise myself with the v2 codebase, I decided to implement it. Here are the details:

- Removed OnExit (command) and OnClipboardChange (label).
- Introduced OnExit() and OnClipboardChange(), the syntax is similar to that of OnMessage():

`OnExit/OnClipboardChange(["FuncNameOrReference"])`

The function returns the old function (if it had been set). Calling it with an empty string as the parameter will remove the handler.
- An OnExit function can receive a single (optional) argument which replaces A_ExitReason.
- If the OnExit function returns true, the Exit sequence is aborted, otherwise the script ends normally. For convenience, ExitApp retains its special OnExit-bypassing behaviour inside an OnExit function.
- An OnClipboardChange function can receive a single (optional) argument which contains the value (0/1/2) which in v1.x was stored in A_EventInfo.

Benefits:
- It is now possible to dynamically set the OnClipboardChange routine, much like it was with OnExit and OnMessage before.
- It is now possible to retrieve the current active OnExit and OnClipboardChange function, allowing users to chain several of them.
- One less built-in variable to support and document.

As always, I may have screwed something up; in that case please let me know.