[...]
1) Aptitude remembers intended actions, even if you change the package
states and/or configuration settings which prompted this behavior.
When in doubt, run "aptitude keep-all".
2) Aptitude tries to react immediately to changes in package states,
including the "automatically installed" flag. If you want to run
several successive (un)markauto commands to change/fix your system
then you have to use "--schedule-only" to keep aptitude from doing
something unintended halfway through the operation and "keep-all"
afterwards. Another helpful stop-gap measure in such cases is
-o aptitude::Keep-Unused-Pattern='~T'
[...]