[pacman-dev] script spaces/tabs, modelines, etc.
Since I've been working on the makepkg script a decent amount, I noticed it had no vim modeline. I also noticed that many of the other scripts do not have a modeline, others are inconsistant, and the abs script actually has 2: $ grep vim * abs:# vim: set ft=sh ts=2 sw=2 abs:# vim: set ts=2 noet: gensync:# vim: set ts=2 sw=2 noet: rankmirrors:# vim: set ts=4 sw=4 sta et sts ai: The rankmirrors one is going to be a bit different because it is a python script, but should we standardize some sort of thing for the bash/sh scripts? Right now the makepkg script is starting to turn into an interesting mix of tabs and spaces, especially if someone uses a ts size different than 4. Here is my take on the situation: 1. Update the modeline for abs- ft should be detected anyway, and no need for two modelines. 2. Standardize the inclusion of the modeline used by the gensync script across all bash scripts included with pacman. It makes sense to have one standard and this seems to be the one most readily available for scripting. Always place this modeline as the last line of the file. If spacing/tabs is a no-no here, I apologize. :) -Dan
On 12/18/06, Dan McGee <dpmcgee@gmail.com> wrote:
Since I've been working on the makepkg script a decent amount, I noticed it had no vim modeline. I also noticed that many of the other scripts do not have a modeline, others are inconsistant
Yeah, I blame myself for not fixing that before, as I dont care too much about spacing (vim handles it nicely for me, anyway). Judd prefers ts=2 sw=2 noet (which is the gensync one you mentioned). As for python, seeing as 4 spaces is the PEP recommended way of doing it, I'd say we use "ts=2 sw=2 et". I'll leave this open for a bit, to see if anyone has any opinions before I fix up all the spacing.
Sounds good. It came up when I was taking a look at FS#2978 because I had to do some long indents of existing code and I noticed how it was starting to look really weird in the diffs. Speaking of that, I have taken a look at the following issues in makepkg and either already threw patches up here or hopefully will soon: #2978- add a 'repackage' option to makepkg #3289- look at ftp return code (btw, I added a line to remove a file there...I don't know if that is always necessary because sometimes wget can continue successfully. However, the fact that the return codes are not standardized makes it tough to know whether this situation applies) #5021- removing info and doc files from non-usr locations -Dan
2006/12/18, Dan McGee <dpmcgee@gmail.com>:
Sounds good. It came up when I was taking a look at FS#2978 because I had to do some long indents of existing code and I noticed how it was starting to look really weird in the diffs.
Speaking of that, I have taken a look at the following issues in makepkg and either already threw patches up here or hopefully will soon: #2978- add a 'repackage' option to makepkg #3289- look at ftp return code (btw, I added a line to remove a file there...I don't know if that is always necessary because sometimes wget can continue successfully. However, the fact that the return codes are not standardized makes it tough to know whether this situation applies) #5021- removing info and doc files from non-usr locations
Ehm... I'm not a vim user, so I don't know exactly what ts=2 sw=2 noet means, but... personally I never use tabs because of thouse indenting issues, so I want to ask [silly] question: why to use tabs at all? why not to indent with space chars only? -- Roman Kyrylych (Роман Кирилич)
Ehm... I'm not a vim user, so I don't know exactly what ts=2 sw=2 noet means, but...
personally I never use tabs because of thouse indenting issues, so I want to ask [silly] question: why to use tabs at all? why not to indent with space chars only? Here is my take, and this is where you have ridiculous no-win debates on the subject. Tabs should be used for structuring your syntax, such as in loops and conditional statements. If you use spaces only, you are making everyone that reads your code abide by your particular
This means that tabstops (ts) are set to equal the width of 2 spaces, and shiftwidth (sw) is also set to 2 spaces. It is a bit harder to explain the difference between these two things, but for most purposes you set them to the same value. The 'no expand tab' (noet) setting keeps tabs as tabs and does not convert them to spaces. preference (2 spaces, 4, 8, etc). With tabs anyone is free to change the default (which is also an assumption made by spaces that a tab is always x characters). To sum up my position, and at least what seems to be the position of the current pacman codebase with already existing modelines: tabs are used for indenting, spaces are used for spacing. -Dan
2006/12/18, Dan McGee <dpmcgee@gmail.com>:
Ehm... I'm not a vim user, so I don't know exactly what ts=2 sw=2 noet means, but...
This means that tabstops (ts) are set to equal the width of 2 spaces, and shiftwidth (sw) is also set to 2 spaces. It is a bit harder to explain the difference between these two things, but for most purposes you set them to the same value. The 'no expand tab' (noet) setting keeps tabs as tabs and does not convert them to spaces.
Thanks for the info. :)
personally I never use tabs because of thouse indenting issues, so I want to ask [silly] question: why to use tabs at all? why not to indent with space chars only? Here is my take, and this is where you have ridiculous no-win debates on the subject. Tabs should be used for structuring your syntax, such as in loops and conditional statements. If you use spaces only, you are making everyone that reads your code abide by your particular preference (2 spaces, 4, 8, etc). With tabs anyone is free to change the default (which is also an assumption made by spaces that a tab is always x characters).
To sum up my position, and at least what seems to be the position of the current pacman codebase with already existing modelines: tabs are used for indenting, spaces are used for spacing.
I agree with your position (I hope there wiill be no contributors that will mix tabs and spaces for indenting). But aren't there problems with diffs? -- Roman Kyrylych (Роман Кирилич)
On 12/18/06, Roman Kyrylych <roman.kyrylych@gmail.com> wrote:
I agree with your position (I hope there wiill be no contributors that will mix tabs and spaces for indenting). But aren't there problems with diffs?
As far as I'm concerned, I don't mind borked diffs due to spacing, assuming it's only a few lines. Typically, patches containing around 20 or so lines of changes, I merge manually anyway, as it gives me a change to see if I like all the changes.
On 12/18/06, Dan McGee <dpmcgee@gmail.com> wrote:
To sum up my position, and at least what seems to be the position of the current pacman codebase with already existing modelines: tabs are used for indenting, spaces are used for spacing.
Yeah, these holy-war things are always silly, but my stance is actually the opposite: I prefer spaces 100% of the time - my code should look how I want it to look 8). But I'm just putting that out there. We'll stick with judd's guidelines for this stuff (FTR, I also dislike same-line {, and that's part of the guideline too).
2006/12/18, Aaron Griffin <aaronmgriffin@gmail.com>: FTR, I also
dislike same-line {, and that's part of the guideline too). That's what I do too: for (...) { ... }
:) -- Roman Kyrylych (Роман Кирилич)
participants (3)
-
Aaron Griffin
-
Dan McGee
-
Roman Kyrylych