Bug 475078 - Improve mode detection for special files
Summary: Improve mode detection for special files
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 23.08.1
Platform: Arch Linux Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-01 07:41 UTC by Eric Armbruster
Modified: 2023-10-02 19:27 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Armbruster 2023-10-01 07:41:32 UTC
STEPS TO REPRODUCE
1. Open a file such as /etc/pacmand.d/mirrorlist on Arch

OBSERVED RESULT
Mode is detected as normal -> I cannot use toggle comment to uncomment stuff, which is a minor annoyance without changing the mode to something more appropriate


EXPECTED RESULT
I am wondering what the best approach is to improve this. Options include:

1. Keep a curated list of special files. This needs to be updated constantly and I guess there will be lots of files... so this doesn't sound like a great plan.
2. Improve the toggle comment for the normal mode to guess the comment symbol based on what's in the file. Doesn't sound great either.

What do you think?



SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Waqar Ahmed 2023-10-01 11:10:47 UTC
For this we have https://docs.kde.org/stable5/en/kate/katepart/config-variables.html that can be specified per file / per dir
Comment 2 Eric Armbruster 2023-10-01 11:53:06 UTC
Not a huge fan of adding this every time I install a new machine. Is there a file I could add this to so Kate is shipped with this?
Comment 3 Waqar Ahmed 2023-10-01 12:08:41 UTC
Don't understand your question.

But besides the above, you can modify/add a highlighting file which will detect the correct mode for the given file.

I don't think we can offer a better solution than this.

As for your first suggestion; We already keep such a filelist. That's how we are able to recall any document specific changes that are made. This file is called katemodelist or katemodeconfig or something like that. You can copy this file to new machines if you like
Comment 4 Bug Janitor Service 2023-10-01 12:55:13 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/555
Comment 5 Bug Janitor Service 2023-10-02 08:20:15 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/556
Comment 6 Eric Armbruster 2023-10-02 18:59:10 UTC
Git commit 1723675aa292387fbf30c03cdfaa6fb17c968745 by Eric Armbruster.
Committed on 02/10/2023 at 10:11.
Pushed by cullmann into branch 'master'.

Set mode for more config file endings

This sets TOML as mode for .conf,.cfg,.cf,.cnf,.ini and for .rc files.
For .cfg,.ini INI is preferred.

XML mode is still set for *ui.rc files.

See https://en.wikipedia.org/wiki/Configuration_file#Configuration_files_and_operating_systems

M  +1    -1    autotests/repository_test_base.cpp
M  +1    -1    data/syntax/ini.xml
M  +3    -2    data/syntax/toml.xml
M  +1    -1    data/syntax/xml.xml

https://invent.kde.org/frameworks/syntax-highlighting/-/commit/1723675aa292387fbf30c03cdfaa6fb17c968745
Comment 7 Eric Armbruster 2023-10-02 19:27:01 UTC
Git commit edf7eae1f7cbd1da2e52c8421aeff522032d3cae by Eric Armbruster.
Committed on 02/10/2023 at 10:19.
Pushed by cullmann into branch 'kf5'.

Set mode for more config file endings

This sets TOML as mode for .conf,.cfg,.cf,.cnf,.ini and for .rc files.
For .cfg,.ini INI is preferred.

XML mode is still set for *ui.rc files.

See https://en.wikipedia.org/wiki/Configuration_file#Configuration_files_and_operating_systems


(cherry picked from commit 1723675aa292387fbf30c03cdfaa6fb17c968745)

M  +1    -1    autotests/repository_test_base.cpp
M  +1    -1    data/syntax/ini.xml
M  +3    -2    data/syntax/toml.xml
M  +1    -1    data/syntax/xml.xml

https://invent.kde.org/frameworks/syntax-highlighting/-/commit/edf7eae1f7cbd1da2e52c8421aeff522032d3cae