-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C (and other languages?) mode hint matching is super fragile #2759
Labels
T: enhancement
Improvement of existing language features
Comments
deathaxe
added a commit
to deathaxe/sublime-packages
that referenced
this issue
Mar 21, 2021
Fixes sublimehq#2759 This commit... 1. sorts main header keys according to sublimehq#2430 2. adds or update `first_line_match` patterns to all appropriate syntax definitions in order to support emacs mode tags. Examples: // -*-c-*- // -*- c -*- // -*- mode: c -*- // -*- mode: c++; -*-
deathaxe
added a commit
to deathaxe/sublime-packages
that referenced
this issue
Mar 21, 2021
Fixes sublimehq#2759 This commit... 1. sorts main header keys according to sublimehq#2430 2. adds or update `first_line_match` patterns to all appropriate syntax definitions in order to support emacs mode tags. Examples: // -*-c-*- // -*- c -*- // -*- mode: c -*- // -*- mode: c++; -*-
deathaxe
added a commit
to deathaxe/sublime-packages
that referenced
this issue
Mar 21, 2021
Fixes sublimehq#2759 This commit... 1. sorts main header keys according to sublimehq#2430 2. adds or update `first_line_match` patterns to all appropriate syntax definitions in order to support emacs mode tags. Examples: // -*-c-*- // -*- c -*- // -*- mode: c -*- // -*- mode: c++; -*-
deathaxe
added a commit
that referenced
this issue
Oct 28, 2021
* [Common] Add or update emacs mode patterns Fixes #2759 This commit... 1. sorts main header keys according to #2430 2. adds or update `first_line_match` patterns to all appropriate syntax definitions in order to support emacs mode tags. Examples: // -*-c-*- // -*- c -*- // -*- mode: c -*- // -*- mode: c++; -*- * [ActionScript] Fix first line pattern * [ASP] Fix first line pattern Moves `-*- asp -*-` to HTML (ASP).sublime-syntax * [JSP] Add missing first line pattern * [Java] Revert first line pattern JSP is html like syntax and probably doesn't need or never sees such mode comment. * [ASP] Revert first line pattern HTML (ASP) won't probably see any such comment, thus removing it. * [All] Allow anything in front of emacs mode tag comments Sync with PR #2862 * [Haskell] Add shebang to first_line_match * [Lua] Add shebang to first_line_match * [ShellScript] Add DASH shebang * [PHP] Add minor version support in shebang Syncs modification from #2915 to add support for php executables such as php php7 php71 php7.1 php7.1.3 to `first_line_match`'s shebang/editorconfig pattern. * [Batch File] Add "@echo on" to first_line_match
Awesome! |
mitranim
pushed a commit
to mitranim/Packages
that referenced
this issue
Mar 25, 2022
* [Common] Add or update emacs mode patterns Fixes sublimehq#2759 This commit... 1. sorts main header keys according to sublimehq#2430 2. adds or update `first_line_match` patterns to all appropriate syntax definitions in order to support emacs mode tags. Examples: // -*-c-*- // -*- c -*- // -*- mode: c -*- // -*- mode: c++; -*- * [ActionScript] Fix first line pattern * [ASP] Fix first line pattern Moves `-*- asp -*-` to HTML (ASP).sublime-syntax * [JSP] Add missing first line pattern * [Java] Revert first line pattern JSP is html like syntax and probably doesn't need or never sees such mode comment. * [ASP] Revert first line pattern HTML (ASP) won't probably see any such comment, thus removing it. * [All] Allow anything in front of emacs mode tag comments Sync with PR sublimehq#2862 * [Haskell] Add shebang to first_line_match * [Lua] Add shebang to first_line_match * [ShellScript] Add DASH shebang * [PHP] Add minor version support in shebang Syncs modification from sublimehq#2915 to add support for php executables such as php php7 php71 php7.1 php7.1.3 to `first_line_match`'s shebang/editorconfig pattern. * [Batch File] Add "@echo on" to first_line_match
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you have a C file that doesn't have a C extension, sublime can still match it with an emacs-style mode hint.
It uses a regex here: https://github.com/sublimehq/Packages/blob/master/C%2B%2B/C.sublime-syntax#L8
first_line_match: "-[*]-( Mode:)? C -[*]-"
This is super fragile, and in fact is incorrect according to the emacs docs
Mode
should be lower case,C
could probably be lower case, and it's missing the;
, plus extra stuff after.This might work better:
(?i)-[*]- *(mode:)? *(c) *;?.*-[*]-
, though I don't know the flavour of regex used hereI don't use sublime, but use something that uses its syntax files (
bat
)Now I don't know why you'd write C files that don't have a .c or .cc extension, I was just made aware of this when trying to figure out why another script wasn't highlighting. It might be worth finding the languages where a
-[*]-
regex is used and fix them up.The text was updated successfully, but these errors were encountered: