lassik / emacs-format-all-the-code

Auto-format source code in many languages with one command
https://melpa.org/#/format-all
MIT License
611 stars 106 forks source link

Improve shell variant detection for shfmt #245

Open rolandmas opened 1 year ago

rolandmas commented 1 year ago

This adds a suffix to the filename passed to shfmt so it can use the default settings stored in .editorconfig even for shell scripts without an extension.

lassik commented 1 year ago

Thanks. A better approach is to always use -ln instead of using fake filenames.

lassik commented 1 year ago

I can write the code.

lassik commented 1 year ago

Wait, editorconfig. Isn't it supposed to be based on filename patterns only? So if you want to use editoconfig settings for foo, you have to write a [foo] section in the .editorconfig file?

rolandmas commented 1 year ago

Yes, correct. Which is why I needed to write a section for [.sh] and [.bash] in that file in order to save default settings for shfmt; and using -ln only doesn't cause shfmt to read these sections because it's based on filenames, hence the tweak in -filename.