Are changes made by scripts added to the undo/redo stacks?
Yes and no. The individual changes are added to the undo/redo stack. The script programmer is responsible for how the user may view this. For example, if you make numerous changes to a document, each change will be a single “undo”. If you want the entire script to be undone in a single operation, you must do something like make all of the changes on a copy then copy and paste the changes back to the original document. An example of this can be seen in the Sortlines example (see the section on design for how undo was handled in this script).