You're editing a file that uses tabs for indentation; and
You run either format-all-buffer or format-all-region and the command exits with an error, with no changes to the buffer
Then point will be moved a little to the right (depending on your width of tab). Since there are no changes to the code, the expected result would be that point stays in same place.
The reason for that is the code adds the old value of current-column to point, but point and column are not equivalent, because column is based on the width of a given character. For example, when you move through a tab character, point increases by 1 but column will increase by 8 (or whichever is the configured width for tabs).
So I fixed that and added a note in the code.
minor: Changed point-at-eol to line-end-position and point-at-bol to line-beginning-position for consistency.
The current code has a bug where given that:
You're editing a file that uses tabs for indentation; and
You run either
format-all-buffer
orformat-all-region
and the command exits with an error, with no changes to the bufferThen point will be moved a little to the right (depending on your width of tab). Since there are no changes to the code, the expected result would be that point stays in same place.
The reason for that is the code adds the old value of current-column to point, but point and column are not equivalent, because column is based on the width of a given character. For example, when you move through a tab character, point increases by 1 but column will increase by 8 (or whichever is the configured width for tabs).
So I fixed that and added a note in the code.
minor: Changed
point-at-eol
toline-end-position
andpoint-at-bol
toline-beginning-position
for consistency.