I made some changes to my WordPress install to make it easier to post code in comments. You can now post code by enclosing it in <code> or <pre>. You still have to escape <, >, and & as <, >, and &, but you no longer have to worry about wrapping, indentation, and smart quotes.
Making these changes was harder than I expected.
Allowing <pre> tags
wp-includes/kses.php to allow
<pre> tags. I will have to do this again every time I reinstall WordPress.
Preserving spacing and avoiding smart quotes
I installed Preserve code formatting. I edited it to only touch comments (I had already turned off formatting and texturizing for posts using Text Control). I also edited it to not try to escape HTML, because I consider that incorrect and because it was doing so in a way that caused > to be double-escaped.
I edited styles.css to make the rule for
code also apply to
pre, and added
text-align: left; white-space: pre;
to that rule.