Local variables for editors

php.internals

Peter Kokot

8 years ago
Hello, I'm not sure if this has been discussed before, but I find these local variables in C, H and other files a bit strange and bloated: /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ Is there any chance to start omitting them and use a single .editorconfig file instead or is this something that is a must have in C projects of today? Thank you for some clarification on this :)
-- Peter Kokot

Peter Kokot

7 years ago
On Wed, 29 Nov 2017 at 22:53, Peter Kokot <peterkokot@gmail.com> wrote:
> > Hello, > > I'm not sure if this has been discussed before, but I find these local > variables in C, H and other files a bit strange and bloated: > > /* > * Local variables: > * tab-width: 4 > * c-basic-offset: 4 > * End: > * vim600: noet sw=4 ts=4 fdm=marker > * vim<600: noet sw=4 ts=4 > */ > > Is there any chance to start omitting them and use a single > .editorconfig file instead or is this something that is a must have in > C projects of today? > > Thank you for some clarification on this :)
Hello, I'm bumping this question since it was brought up also in the pull request for fixing the code style of the libmbfl [1]. Going through these editor settings: - tab-width: 4 is already set in the .editorconfig file - c-basic-offset: 4 is emacs setting for indentation level [2] - noet is setting for vim to not expand tabs to spaces - sw means setting the shift width in vim - ts means tabstop - fdm=marker means folding method [3] Since these are specific for the C code, we should instead set other ways of code style fixes methods for this task. For example, Clang format and Clang tidy can fix existing code quite nicely from what the settings they have available. And EditorConfig mostly can do all that what is set above - set the indentation style and its width. Not to mention that with the default Vim configuration (tested on latest Ubuntu), this doesn't work as it should anymore. So, the main question here, can we start removing these comment blocks from the *.c and *.h files together with the footer file [4]? [1] https://github.com/php/php-src/pull/3754 [2] https://www.emacswiki.org/emacs/IndentingC [3] http://vim.wikia.com/wiki/Folding [4] http://git.php.net/?p=php-src.git;a=blob;f=footer;hb=HEAD
-- Peter Kokot

Nikita Popov

7 years ago
On Sat, Jan 19, 2019 at 10:09 PM Peter Kokot <peterkokot@gmail.com> wrote:
> On Wed, 29 Nov 2017 at 22:53, Peter Kokot <peterkokot@gmail.com> wrote: > > > > Hello, > > > > I'm not sure if this has been discussed before, but I find these local > > variables in C, H and other files a bit strange and bloated: > > > > /* > > * Local variables: > > * tab-width: 4 > > * c-basic-offset: 4 > > * End: > > * vim600: noet sw=4 ts=4 fdm=marker > > * vim<600: noet sw=4 ts=4 > > */ > > > > Is there any chance to start omitting them and use a single > > .editorconfig file instead or is this something that is a must have in > > C projects of today? > > > > Thank you for some clarification on this :) > > Hello, I'm bumping this question since it was brought up also in the > pull request for fixing the code style of the libmbfl [1]. > > Going through these editor settings: > - tab-width: 4 is already set in the .editorconfig file > - c-basic-offset: 4 is emacs setting for indentation level [2] > - noet is setting for vim to not expand tabs to spaces > - sw means setting the shift width in vim > - ts means tabstop > - fdm=marker means folding method [3] > > Since these are specific for the C code, we should instead set other > ways of code style fixes methods for this task. For example, Clang > format and Clang tidy can fix existing code quite nicely from what the > settings they have available. And EditorConfig mostly can do all that > what is set above - set the indentation style and its width. Not to > mention that with the default Vim configuration (tested on latest > Ubuntu), this doesn't work as it should anymore. > > So, the main question here, can we start removing these comment blocks > from the *.c and *.h files together with the footer file [4]? > > [1] https://github.com/php/php-src/pull/3754 > [2] https://www.emacswiki.org/emacs/IndentingC > [3] http://vim.wikia.com/wiki/Folding > [4] http://git.php.net/?p=php-src.git;a=blob;f=footer;hb=HEAD >
I think it's okay to drop these. I'm using vim, but I don't think these variables ever did something for me. Nikita

Levi Morrison

7 years ago
On Wed, Nov 29, 2017 at 2:54 PM Peter Kokot <peterkokot@gmail.com> wrote:
> > Hello, > > I'm not sure if this has been discussed before, but I find these local > variables in C, H and other files a bit strange and bloated: > > /* > * Local variables: > * tab-width: 4 > * c-basic-offset: 4 > * End: > * vim600: noet sw=4 ts=4 fdm=marker > * vim<600: noet sw=4 ts=4 > */ > > Is there any chance to start omitting them and use a single > .editorconfig file instead or is this something that is a must have in > C projects of today? > > Thank you for some clarification on this :) > -- > Peter Kokot > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php
I use vim, and do not enable these per-file settings. I don't think any distributions enable them by default either. My opinion: I think we can get rid of them. I have used .editorconfig and .clang-tidy for other projects and liked it. I tried using it with tabs, and the experience seemed less polished but still worked.

Peter Kokot

7 years ago
Hello, On Tue, 22 Jan 2019 at 16:49, Levi Morrison <levim@php.net> wrote:
> > On Wed, Nov 29, 2017 at 2:54 PM Peter Kokot <peterkokot@gmail.com> wrote: > > > > Hello, > > > > I'm not sure if this has been discussed before, but I find these local > > variables in C, H and other files a bit strange and bloated: > > > > /* > > * Local variables: > > * tab-width: 4 > > * c-basic-offset: 4 > > * End: > > * vim600: noet sw=4 ts=4 fdm=marker > > * vim<600: noet sw=4 ts=4 > > */ > > > > Is there any chance to start omitting them and use a single > > .editorconfig file instead or is this something that is a must have in > > C projects of today? > > > > Thank you for some clarification on this :) > > -- > > Peter Kokot > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > I use vim, and do not enable these per-file settings. I don't think > any distributions enable them by default either. My opinion: I think > we can get rid of them. > > I have used .editorconfig and .clang-tidy for other projects and liked > it. I tried using it with tabs, and the experience seemed less > polished but still worked.
Thank you for both feedback. There is a pull request [1] prepared to remove these. It is split into several commits that did these in multiple steps for easier reviewing. Changes: - All footers (local variables blocks) removed since they don't provide anything drastically useful in most editors with default settings - Removed the so called Vim modeline in some *.phpt files to set the PHP syntax highlighting, because this functionality for *.phpt files specifically is not important. Most editors show the PHP syntax by default already neither the modelines wer synced across all of phpt files. For example // vim600: syn=php - The ext/ext_skel.php script also adjusted to not generate the footer with local variables. I have left two local variables/modelines: - in *.w32 files the modeline sets the syntax highlighting in some editors and on GitHub also: // vim:ft=javascript - In certain *.phpt files the modeline sets encodings which probably also don't work properly everywhere but for the documentation purposes I've left those in for now // vim: set encoding=cp936 Hoping that EditorConfig will also get improved with additional features over time here a bit. So, that's good to go in master branch in the next days? If not, let me know... Cheers. [1] https://github.com/php/php-src/pull/3757
-- Peter Kokot