Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column numbers for --format emacs should start at 1 #276

Closed
jonas054 opened this issue Jun 14, 2013 · 9 comments
Closed

Column numbers for --format emacs should start at 1 #276

jonas054 opened this issue Jun 14, 2013 · 9 comments
Assignees

Comments

@jonas054
Copy link
Collaborator

When I run rubocop as a compilation within emacs and then use the (next-error) function to jump to offences, the cursor does not go to the right column. For column 0 it goes to the end of the line, and for all other column values it ends up one step too far to the left.

If this is the same for other users, I suggest we add 1 to the column number in the emacs formatter.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 14, 2013

That's odd. Columns in Emacs certainly start from 0.

@jonas054
Copy link
Collaborator Author

Well the displayed column numbers start at 0 in mine too (which is 23.1.1), but next-error behaves in this strange way. If emacs 24 behaves differently, we can just close this issue. I'm a late adopter, and should make the switch to 24 sometime soon.

@jonas054
Copy link
Collaborator Author

No, I get the same problem with emacs 24. Am I the only one?
emacs
Notice how the cursor is one step too far to the left.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 17, 2013

I guess you're right. Maybe we should count columns from 1 everywhere for consistency. Btw, @whitequark, why are line-numbers in Parser starting from 1 and column numbers starting from 0?

@whitequark
Copy link

Column numbers are used to highlight ranges, so they represent real ranges of indexes for the lines.

Reported line numbers on the other hand are not inherently bound to something real, like an actual line number, because you can specify starting line in the Source::Buffer constructor. (This is used to implement the eval family of functions, where starting line is a parameter.)

@jonas054
Copy link
Collaborator Author

I find it strange that emacs places the cursor as if column numbers would start at 1 while it displays them starting at 0. See how it says (21,24) on the status line while the location given by rubocop is 21:25.

If we are to adapt to this quirk, my choice would be to do it only in the emacs formatter. I don't know if people use --format emacs in other situations, e.g., from vi. In that case we might screw things up for them by changing offset.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 17, 2013

Well, the emacs format is pretty much the standard for all old-school text editors AFAIK :-) I'll do some further research on the subject when I have a bit of time.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 18, 2013

So, vim starts counting columns from 1 it would seem. Emacs's behaviour is extra strange because the command move-to-column (M-g TAB) starts counting from 0, but as you've noticed the column numbers from compilation mode are treated differently. IMO we should display everywhere(in all formatters) the column number(but continue to keep it internally as we do now), given this information.

@jonas054 Would you please take care of that?

@jonas054
Copy link
Collaborator Author

Yes. I'll add 1 to the column number in all formatters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants