mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Revise pattern for Emacs modeline detection
This is a rewrite of the regex that handles Emacs modeline matching. The
current one is a little flaky, causing some files to be misclassified as
"E", among other things.
It's worth noting malformed modelines can still change a file's language
in Emacs. Provided the -*- delimiters are intact, and the mode's name is
decipherable, Emacs will set the appropriate language mode *and* display
a warning about a malformed modeline:
-*- foo-bar mode: ruby -*- # Malformed, but understandable
-*- mode: ruby--*- # Completely invalid
The new pattern accommodates this leniency, making no effort to validate
a modeline's syntax beyond readable mode-names. In other words, if Emacs
accepts certain errors, we should too.
This commit is contained in:
3
test/fixtures/Data/Modelines/seeplusplusEmacs10
vendored
Normal file
3
test/fixtures/Data/Modelines/seeplusplusEmacs10
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// -*- foo-bar mode: c++ -*-
|
||||
|
||||
"Malformed modeline, but still understood by Emacs to be C++."
|
||||
Reference in New Issue
Block a user