[issue3992] set/get use cases for 'env' and new 'set_env' magic

proposed fix for https://github.com/ipython/ipython/issues/3992
You're right, and this is an older version I did not intend to be in this diff.  On that subject, I'm having trouble preparing branches with minimal modifications because my editor is set up to clean trailing whitespace.  For most files this changes lots of lines.  What is the policy on this?  If it's ok, I'd prefer to submit branches with cleaned whitespace even if it means more frequent rebasing for me.  Thoughts?