Transition from modelines to EditorConfig

Sander Maijers S.N.Maijers at structure.systems
Sat Feb 24 16:50:27 UTC 2018


In order to maintain optimally readable code, and waste minimal amount 
of development time on manual routine text (re)formatting, LibreOffice 
requires clear text formatting (also, ‘code style’) guidelines. Ideally, 
these guidelines would not only be clear to contributors (assuming they 
are aware of them), but also be checkable and applicable automatically, 
i.e. be rules.

EditorConfig (http://editorconfig.org/) is standard configuration file 
format, that serves to specify basic text formatting rules. It was 
designed to partially fulfill the previously introduced requirement. It 
allows LibreOffice broad control over text formatting rules, and helps 
text editing software to then apply these rules before anything is 
committed. This all happens in a way transparent to and easy on 
contributors. IDE/editor support for EditorConfig is very complete at 
present, and works independent of platform conventions. EditorConfig 
fits in the larger picture as complement to language-specific text 
formatting rules, e.g. clang-format rules.

Currently, LibreOffice developers appear to use Vim modelines for this 
purpose, but quite choatically. For example, within a single source code 
file multiple modeline-style comments can be found, e.g. one Emacs-style 
(https://github.com/LibreOffice/core/blob/19a906f09688f06ee90cac2a50126aeba749a331/sw/source/filter/ascii/wrtasc.cxx#L1) 
and one vim-style 
(https://github.com/LibreOffice/core/blob/19a906f09688f06ee90cac2a50126aeba749a331/sw/source/filter/ascii/wrtasc.cxx#L200). 


Modeline-style methods for text formatting rules differ from 
EditorConfig in a number of ways. The differences are mainly down to 
weaknesses of modelines, as already convincingly argued in e.g. 
https://github.com/vim/vim/issues/2286#issue-271201325. I will add a few 
points. Classical Unix editor-specific configuration is not 
contributor-friendly. Note also that Vim modelines can increase security 
risk to developers 
(https://www.reddit.com/r/vim/comments/60jbww/disable_modeline_for_security_reasons/). 
Finally, modelines do nothing to control formatting of non-source code 
files such as CSV or plain text files.

I propose to:
- Decide on detailed text formatting guidelines.
- Implement the relevant part of these rules in one or more EditorConfig 
file(s).
- Phase out any other mechanisms for text formatting that is now covered 
by these EditorConfig files.

Please let me know what you think of this.


More information about the LibreOffice mailing list