4 ms·
It's really, really hard to make a completely correct mode based on regexes—just consider the challenge of writing a regex that correctly highlights the syntax
by mbrock 9y ago
It's really, really hard to make a completely correct mode based on regexes—just consider the challenge of writing a regex that correctly highlights the syntax of regex itself, which you need for JavaScript, Ruby, and lots of other languages.
Heredocs in shell, metaprogramming tricks in Ruby, reader extensions in Lisp, nested quotes, etc etc etc—I might be weird, but I feel like I run into these edge cases a lot, when editors think my parens are unbalanced when they're actually not, and so on.
Auto-indentation rarely formats things the way I want, too, and I very rarely need anything more advanced than shifting blocks in and out.
I also just find it a bit strange that we have culturally started to believe that editing code is nearly unthinkable without different colors everywhere!
- tomsmeding 9y agoI completely agree that highlighting code with regexps is almost useless, but if emacs is not capable of doing more than that (or its language modes usually do not do more than that), I think that emacs is at fault here, not syntax highlighting. In sublime text, for example, the syntax definitions are basically stack machines (if I'm not mistaken), and can therefore parse any context-free grammar. This is clearly powerful enough to handle all the edge cases you mention.
- mbrock 9y agoWell, that's cool.