Improve code commenting-out global config files
commit6018c523948e50f645af10f5338a56cda1eccf0b
authorJiří Techet <techet@gmail.com>
Fri, 24 Feb 2023 22:17:01 +0000 (24 23:17 +0100)
committerColomban Wendling <ban@herbesfolles.org>
Mon, 13 Mar 2023 13:40:44 +0000 (13 14:40 +0100)
tree62d40271acac741bbdf069ec6d947e7481d92fa8
parentae1f499e3b2fa108d749942008431ec1aaf0294b
Improve code commenting-out global config files

Right now, when a config file from Tools->Configuration Files is edited
for the first time, the global config file is taken and all lines in it are
commented-out. When modified, such a file is copied into the user's config
directory. The logic behind this is that the user typically wants to
modify just one or few config options while leaving the rest in the
default state.

However, commenting-out all lines is problemmatic. Consider for instance
the beginning of filetypes.common when all lines are commented-out by
the current code:

```
#~ # For complete documentation of this file, please see Geany's main documentation
#~ [styling]
#~ # use foreground;background;bold;italic or named_style,bold,italic
#~
#~ # used for filetype All/None
#~ #default=default
```

1. Already commented-out lines are commented out once more which is ugly
2. Sections are commented out. This is problematic because users don't
have to just comment-out the variable they want to modify, they must also
comment-out the section in which the variable is which is easy to forget.
3. Empty lines are commented out which is unnecessary

This patch goes through the config file line by line and keeps sections,
comments and empty lines unmodified so the result of the above example
is this:

```
# For complete documentation of this file, please see Geany's main documentation
[styling]
# use foreground;background;bold;italic or named_style,bold,italic

# used for filetype All/None
#default=default
```

The patch does this only for .conf filetype and uses the original code for
other file types.
src/ui_utils.c