# Modifying code formatting when editing

The motivation for this question is this post: https://tex.stackexchange.com/posts/94206/revisions

In one of recent edits, the editor decided to change the code formatting in a piece of lisp code. Since the code was not badly formatted before, I decided to rollback it, because I felt that code formatting style is a matter of personal preferences, there are many valid ways to do it and editor should not change it.

After some short discussion in the chat and coming to no conlusion, it was decided that more discussion is needed.

So the question is: Is it acceptable to edit the code formatting in a post by another user when the formatting is not bad and has no influence on the function of the code?

• Well the main reason for the edit seems to be the change in the code parser language which is always helpful if the code is not written in TeX because the code coloring hence the readability changes drastically. Probably while they are at it a few aesthetic touches are introduced to shorten. I wouldn't worry too much on such edits. daleif can also rollback if there is significant change. – percusse Jan 29 '13 at 1:28
• The format change was minimal here and has shortened the post, which is normally very good for this site. Also the OP will get notified about the edit and then can decide whether or not to keep it. – Martin Scharrer Jan 29 '13 at 8:47

## 4 Answers

I would say that it's up to the owner of the post to decide whether they feel editing the code formatting is okay or not, not a third party. When someone's answer is edited, they are notified and can make the call themselves. Maybe they think of the new code formatting as an improvement and are happy about it; if not they can undo the changes themselves.

• Thanks, I was going to post the same thing. – Martin Scharrer Jan 29 '13 at 8:44

I edited the code. The indentation was positively misleading, as nested functions are always indented further than the function they are nested in. Indeed, the original poster used this convention in most of their code, so clearly the incorrect indentation was in error.

I also moved the closing parentheses so that the code was in a more conventional lisp style. This may have been out of line, I won't do that again. However, on review it appears the indentation of the closing parens was haphazard before my edit.

If the original poster is following a clear coding convention, and a few lines out of a block are clearly breaking the intended convention, I see no reason not to add a few spaces to make the code formatting consistent with itself.

My apologies to the OP if I have in fact offended them. I will note that up to this point, OP has not expressed any problem with the edit, and may not have minded it in the first place.

• I obviously over-reacted and I apologise for that. I'm not sure if I should now do any more edits to that post, since it seems it cannot cause anything good. It would be probably better if you reverted it yourself (it's better to hit the "edit" button next to your version and save it instead of "revert" directly, since this preserves the edit history). Thanks. – yo' Jan 29 '13 at 19:49
• Re "I won't do that again.". The only thing I would suggest you might have done differently is to have been more specific in the comment on your edit. Perhaps "Formatted to code to a more consistent style". Also, at the moment your edits have to be approved by a higher-rep user so you should feel more freedom to edit, not less! Anyway, thanks for explaining here and clarifying the specific situation. – Loop Space Jan 30 '13 at 9:21

Going from the situation that provoked this, I'd like to point out the dangers of being the third man in. This is a well-known phenomenon from rugby: since a rugby match is essentially a pitched battle, it is often hard for a referee to see when a maul turns into a brawl and they might well miss the start of it and see only the retaliation or the third man in. Therefore, the third man in is actually the more likely to get sent off the pitch.

It is very easy to get offended on someone else's behalf. In such a circumstance I would advise caution. Rolling back the edit is only one of the options available. Chatting about it, flagging it, commenting on the post. These are all milder actions.

The other thing I'd say is to always act as if the original offender (assuming an offence has been committed) did so out of the best of motives.

Oh, one more thing. There is a difference between a one off occurrence and a serial editor. In the latter case it is worth gently taking them aside and asking them to desist (assuming that there is no real need for the edits to be made). But in the former then I think that the danger is of making a mountain out of a molehill.

IMHO, reindenting other people's code is a big no-no, unless the code is a complete mess. (Sometimes I am tempted to add linebreaks in those looooong horizontal scrollboxes, but refrain because, well, see my first sentence.)

This particular instance, however, has another angle: the edit added an apropriate language code, which clearly was an improvement. You even kept that after your rollback. So, in this case, I would've suggested to leave the edit for its contribution, and to re-edit to restore your preferred indention.

• I agree on the language tag, but it was easier to add it to the previous version. – yo' Jan 29 '13 at 0:19
• @tohecz Sure. But look at it from the point of the editor. He/she sees the rollback, and that you add a part of his/her contribution in your own edit. Some people might get annoyed by that. After all, some people are really after those badges ... – mafp Jan 29 '13 at 0:42
• I actually think there's a difference between formatting code to make it more readable on the site (especially inserting judicious line breaks to avoid horizontal scroll bars) and changing what might be thought of as a programming style. I think the former is perfectly acceptable, while the latter is not. – Alan Munn Jan 29 '13 at 2:00