EditorMacroScript: Refactor and use "Register" procedure

git-svn-id: http://svn.freepascal.org/svn/lazarus/trunk@42195 4005530d-fff6-0310-9dd1-cebe43e6787f
codetools: fixed freeing scanner

git-svn-id: http://svn.freepascal.org/svn/lazarus/trunk@42196 4005530d-fff6-0310-9dd1-cebe43e6787f