Commit abffa58
committed
Rewrite patterns for matching Vim/Emacs modelines
Both of the previous patterns had flawed handling of less obvious cases,
such as wrongly accepting invalid modelines, or failing to match grammar
that would otherwise be understood by Vim or Emacs.
Emacs:
* Boundaries now matched correctly to avoid matching "not-mode: nroff;"
* Invalid modelines like "-*- nroff; -*-" are now ignored
* Preceding variables containing asterisks are permitted
* Semicolons are no longer required to separate modes from variables
* Handling of malformed modelines better resembles Emacs's own behaviour
Vim:
* Version-specific modelines are now supported: "vim<200: ft=roff"
* Preceding whitespace is required before "vim/ex"
* Boolean options may now be listed before filetypes: "vi: noet ft=roff"
* Escaped backslashes are handled properly; "vim: s=foo\ ft=cpp ft=roff"1 parent f37fb6b commit abffa58
1 file changed
Lines changed: 14 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
46 | 54 | | |
47 | 55 | | |
48 | 56 | | |
| |||
0 commit comments