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:
Alhadis
2016-09-17 19:45:43 +10:00
parent 00efd6a463
commit 697380336c
5 changed files with 41 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
// -*- foo-bar mode: c++ -*-
"Malformed modeline, but still understood by Emacs to be C++."