Refactor EmacsOutput to better handle SH and ST.