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

Make "Detect indentation type/width from file" the ddefault #3565

Open
cousteaulecommandant opened this issue Sep 28, 2023 · 3 comments
Open

Comments

@cousteaulecommandant
Copy link
Contributor

cousteaulecommandant commented Sep 28, 2023

Regardless of personal preference of tabs vs spaces, I think "Detect indentation type/width from file" should be enabled by default.

I really dislike opening a file and finding a mix of tabs and spaces in it, especially when the file gets later opened on another code editor (or web interface) where a tab has a different width (e.g. 8 spaces instead of 4) and every line gets a different width, all because developers A and B had different settings in their respective editors when creating the file. Similarly for indentation width; opening a file that uses 2 spaces for indentation and then having Geany start adding 4 spaces by default will lead to inconsistent indentation.

I think that the feature to auto-detect indentation type and width works pretty well in Geany, and should be the default (which users can of course override if that's their preference). This would make Geany not contribute to mixing up indentation types.

(This came to my mind when some user complained about tabs being the default instead of spaces, and needing to manually set that preference every time. I think that enabling auto-detection would at least help with preexisting files, so that's half the battle won.)

PS: Wasn't this feature the default back in the day?

@elextr
Copy link
Member

elextr commented Sep 28, 2023

Well "width" is only detected if the indent is spaces.

Detecting the indent type is a heuristic based on the most common indent in the file, so that means scanning the file, not so good for huge files. And being a heuristic it can be wrong, although medium sized files where most of the indent is the same should work. But detecting per file means it might find different settings for different files in the project. Particularly when somebody else has added content with the wrong indents, so detection can wrongly preserve that error.

That is why these settings can be set in the project file too, the intention is that you adapt each project file to the requirements of the specific project, then all files in the project remain consistent and can't have the heuristic get the wrong setting for some files in the project.

Tabs are the default because Geany uses tabs, no correspondence will be entered into ;-)

PS: Wasn't this feature the default back in the day?

According to git it has been false since 0.19 which was as far as I bothered to look back.

@cousteaulecommandant
Copy link
Contributor Author

that means scanning the file, not so good for huge files.

Good point; I didn't think of that.
I suppose that one easy way out is to only scan the first N lines (1000 or so); if that is not enough you could just say that the heuristics failed. (And for tabs vs spaces, the number of lines scanned could be even less.) This limit could be different if you explicitly select Document > Indentation type/width > Detect from document.

Tabs are the default because Geany uses tabs, no correspondence will be entered into ;-)

Sounds reasonable. There had to be a default, and I guess tabs are as good as any other.

According to git it has been false since 0.19 which was as far as I bothered to look back.

No idea... been using Geany since around 2008 or so.

@elextr
Copy link
Member

elextr commented Sep 28, 2023

No idea... been using Geany since around 2008 or so.

Ok, detect indent seems to have been released in 0.13 Feb 2008 with a default false. (Version control never forgets :-)

My (admittedly quick) search of issues did not turn up rampaging hoards of users demanding detect from file be the default, so I'm not sure it should be changed, it might provoke rampaging hoards of users wanting it reverted.

For religious issues like indentation its probably better to have it enforced because as I said, detecting per file is not really correct, its usually the project (the user one, not the Geany one) that decides which religion is used for the whole project so there should be no need to detect per file. Just a pity there is no agreed way of detecting per project.

Or of course we could hard code the holy grail, 4 spaces (my indent religion), and be done with it :-)

Tabs were a good idea when coding was ed on clattering teletypes and disks were 100k, not now we have Geany that can count indent spaces and disks of several T bytes, and as for two spaces, what is this? Emacs? [end rant]

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

2 participants