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

rust-mode: default to conventional indentation variable tab-width value #6222

Closed
mcandre opened this issue May 3, 2013 · 11 comments
Closed

Comments

@mcandre
Copy link

mcandre commented May 3, 2013

To configure indentation width in rust-mode, the Emacs user modifies rust-indent-unit, as in (setq rust-indent-unit 4). This works, but it's nicer, more idiomatic, and more compatible with other Emacs modes to base the rust-indent-unit variable off of tab-width, and use a rust-mode-hook to customize tab-width rather than set rust-indent-unit globally.

@emberian
Copy link
Member

emberian commented Aug 5, 2013

@mcandre the rust-mode has been rewritten, and should respect this. Closing (pipe up if you disagree)

@emberian emberian closed this as completed Aug 5, 2013
@pnkfelix
Copy link
Member

pnkfelix commented Aug 7, 2013

The current rust-mode.el is using default-tab-width, but I think tab-width would be better. (In particular, one can assign a buffer-local value totab-width, which has been useful when I want to use 4-space tabs for Rust code, but 8-space tabs for Makefiles.)

@pnkfelix pnkfelix reopened this Aug 7, 2013
pnkfelix added a commit to pnkfelix/rust that referenced this issue Aug 11, 2013
@brson
Copy link
Contributor

brson commented Aug 12, 2013

Can't we use 4 spaces by default, since that is the Rust coding convention? The current situation forces everybody to override the tab width.

@pnkfelix
Copy link
Member

part of #8793

@andersk
Copy link
Contributor

andersk commented Aug 28, 2013

Yeah, this seems wrong. Emacs has separate tab-width and indent-level variables for a reason. Tabs are always displayed as 8 spaces by a variety of programs, but most programmers and style guides prefer 4 spaces or 2 spaces for indentation levels, and one should not have to override the width of a Tab character to a nonstandard value to comply with this preference. No other major mode uses tab-width to control indentation levels—I don’t know where the reporter heard otherwise. (You can make tab-width control indentation levels if you really want to, e.g. (defvaralias 'c-basic-offset 'tab-width), but this does not happen by default.)

@pnkfelix
Copy link
Member

At this point, the emacs mode was revised (after I reopened this ticket, and maybe even after I wrote pnkfelix/rust@b6848f5 ); see SHA: 3596f66 which adds the customizable varaible rust-indent-offset, which should be customizable and so one does not need to modify default-tab-width

So I will just close this, I think customizing rust-indent-offset should be fine for this.

@andersk
Copy link
Contributor

andersk commented Aug 28, 2013

Alright, the customizability is there. Should I open another issue for changing the default to 4, like I expect most programmers will want? (Or is that more controversial than I expect?)

@pnkfelix
Copy link
Member

@andersk: I won't object.

@andersk
Copy link
Contributor

andersk commented Aug 28, 2013

#8830.

@adrianbrink
Copy link

Is there a way to set rust-mode to always use tabs instead of spaces?

@andersk
Copy link
Contributor

andersk commented Apr 5, 2017

@adrianbrink You can customize rust-indent-offset to equal tab-width and indent-tabs-mode to t.

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

7 participants