Skip to content

Commit

Permalink
Update modeline patterns to use github-linguist/linguist#5271
Browse files Browse the repository at this point in the history
  • Loading branch information
Alhadis committed Mar 13, 2021
1 parent b18cf7c commit d9c1baf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](http://semver.org).
[Unpublished]
------------------------------------------------------------------------
* __Added:__ Comment highlighting for interpreter directives (hashbangs)
* __Fixed:__ [Various inaccuracies][1] related to modeline matching

[1]: https://github.com/github/linguist/pull/5271



Expand Down
16 changes: 9 additions & 7 deletions grammars/emacs-lisp.cson
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ firstLineMatch: """(?x)
(?:$|\\s)
|
# Modeline
(?i:
(?:
# Emacs
-\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
emacs-lisp
(?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:emacs-lisp)
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s*set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*=
(?:emacs-lisp|elisp)
(?=\\s|:|$)
(?:(?:^|[ \\t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t]))
(?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:]
(?:filetype|ft|syntax)[ \\t]*=
(?i:emacs-lisp|elisp)
(?=$|\\s|:)
)
"""
patterns: [{
Expand Down
16 changes: 9 additions & 7 deletions grammars/muse.cson
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@ patterns: [{
end: "(?=A)B"
patterns: [include: "#main"]
}]
firstLineMatch: """(?ix)
firstLineMatch: """(?x)
# Emacs modeline
-\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
muse
(?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:muse)
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim modeline
(?:(?:\\s|^)vi(?:m[<=>]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*=
muse
(?=\\s|:|$)
(?:(?:^|[ \\t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t]))
(?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:]
(?:filetype|ft|syntax)[ \\t]*=
(?i:muse)
(?=$|\\s|:)
"""

repository:
Expand Down
8 changes: 4 additions & 4 deletions grammars/yasnippet.cson
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ fileTypes: [
"yasnippet"
"yas"
]
firstLineMatch: """(?xi)
firstLineMatch: """(?x)
# Emacs modeline
-\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
(?:yasnippet|snippet)
(?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:yasnippet|snippet)
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
"""

patterns: [{
Expand Down

0 comments on commit d9c1baf

Please sign in to comment.