-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Fix various oversights in modeline regexes #5271
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alhadis
added a commit
to file-icons/atom
that referenced
this pull request
Mar 12, 2021
The capitalisation of "prolog" is left intact to assert case-insensitive comparison of language names (i.e., we don't care that Vim's Prolog mode is actually lowercase).
Alhadis
added a commit
to Alhadis/YASR
that referenced
this pull request
Mar 12, 2021
Alhadis
added a commit
to Alhadis/language-etc
that referenced
this pull request
Mar 12, 2021
Also, fix a copy+paste error in the gitattributes(5) grammar.
Alhadis
added a commit
to Alhadis/language-grammars
that referenced
this pull request
Mar 12, 2021
Alhadis
added a commit
to Alhadis/language-fontforge
that referenced
this pull request
Mar 12, 2021
Alhadis
added a commit
to Alhadis/language-viml
that referenced
this pull request
Mar 12, 2021
Alhadis
added a commit
to Alhadis/language-gn
that referenced
this pull request
Mar 12, 2021
Alhadis
added a commit
to Alhadis/language-apl
that referenced
this pull request
Mar 12, 2021
Alhadis
added a commit
to Alhadis/language-roff
that referenced
this pull request
Mar 13, 2021
Alhadis
added a commit
to Alhadis/language-emacs-lisp
that referenced
this pull request
Mar 13, 2021
Alhadis
added a commit
to Alhadis/language-webassembly
that referenced
this pull request
Mar 13, 2021
Alhadis
added a commit
to Alhadis/language-sed
that referenced
this pull request
Mar 13, 2021
Alhadis
added a commit
to Alhadis/language-texinfo
that referenced
this pull request
Mar 13, 2021
lildude
approved these changes
Mar 19, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 😍 I'm surprised we've gone for so long without anyone noticing 🤭
Alhadis
added a commit
to Lukasa/language-restructuredtext
that referenced
this pull request
Aug 6, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a handful of oversights and behavioural discrepancies with the regular expressions used by our modeline strategy (detailed below).
Description
Whilst reviewing #4138, I recommended
[ \t]
be used instead of[:blank:]
. However, I didn't think to check if the submitter applied the changes correctly. Only recently did I notice Vim's modeline regex had an erroneous[^\\[ \t]]
(which should have been[^\\ \t]
instead).Realising there might be other things I missed, I recently took the time to double-check both regexes and verify their behaviour matches that of Emacs and Vim. Among the things I found were:
:help modeline
says that modelines must be prefixed by “the stringvi:
,vim:
,Vim:
orex:
”. Mixed-case prefixes likevIM:
orViM:
don't work, soVIM_MODELINE
shouldn't be flagged as case-insensitive.Vim
orvim
.Our current pattern allows
vi>600: ft=ruby
and# ex>600: ft=ruby
, neither of which actually work in Vim.This was due to
\s
being used instead of[ \t]
. An embarrassing habit I've picked up from years of writing TextMate grammars is to assume\s
only matches horizontal whitespace, instead of line-breaks as well. Ergo, something like this (obviously) shouldn't match:So Ruby's insidious treatment of
.
meant that.*?
also matched newlines, which it logically shouldn't. I resolved this by unsetting multiline mode with(?-m)
.vim: set … :
.A trivial issue that probably won't ever surface in practice; fixed by updating classes to use
\r\n
instead of just\n
.(Template removed as it doesn't apply)