Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't know that I can do justice to the idea, since I'm no bundle-writing expert, but see http://manual.macromates.com/en/language_grammars.html for the details.

The basic advance over something like an Emacs-Lisp package is that he built a declarative system (based on context-dependent regexps) for handling arbitrary languages, rather than making you write all the code to do so from scratch.

And he built things in such a way as to be able to handle languages nested inside other language contexts (e.g., Ruby inside HTML).

Couple that with a pretty powerful templating facility, and you have something that advances the state of the art.

I don't think anyone else has really taken as fresh a look at text editing for a long time.



rather than making you write all the code to do so from scratch

Emacs does not make you do this. (setf font-lock-keywords '(("some-regexp" . whatever-face-you-want-that-to-be) ...)). There are several other forms that font-lock understands, including custom functions that do highlighting.

Emacs also has something called the "syntax table", which allows you to declare what comments and string literals look like. Emacs can then use this information to syntax highlight those elements, and not do other syntax highlighting inside them.

cperl-mode uses this combination of features to correctly highlight nearly 99% of Perl constructions correctly. (Keep in mind that Perl and C++ have the dubious honor of not being parseable with a formal grammar, so it is somewhat impressive that syntax annotations + regexps is enough to do a good job.)


A little bit of meta-commentary.

I find it amusing that people are downmodding this post that contains correct information. There is no editorializing here; just information about how the syntax-highligting works, and my experience with working on a major mode for a very complicated language (using said tools).

If you must downmod, downmod the parent which contains untrue FUD.


Yes, I apologize for my sloppy statement.

I realize Emacs does a lot of the work for you. It's just that I've worked with some of these mode packages over the years and have been impressed with the complexity they embody and the size of the code involved.

Textmate seems to avoid most of that complexity with its declarative system, and still give you syntax highlighting and auto-indenting, etc.


This is mostly because authors can't resist the urge to also do something "interesting" in addition to "just" syntax highlighting. imenu support for example. (imenu is "tags without a tags table" for one file.)

If you look at cperl-mode, for example, syntax highlighting and indentation support is only a small part of its line count. The rest is things like auto-documentation of core features, including 100s of lines of documentation strings for Perl core functions.


That's very cool.

I will check how syntax highlighting is implemented in Emacs to check if something like this can be done and learn some Lisp in the process.

I keep hearing people state their love for TextMate but since I don run OSX and there is no Linux version, I am out of luck.

They could use their rewrite to make it compilable against GNUStep...


It's been (well, is in the process of being) done - http://redcareditor.com/

It's already useable, if you can deal with the pain of the installation process.


I keep hearing people state their love for TextMate but since I don run OSX and there is no Linux version, I am out of luck.

I would not worry too much about this. Assuming you are willing to use Google and edit your .emacs file, Emacs can do everything TextMate can. It also has the potential to do many things that TextMate can't. (I don't see Slime for TextMate.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: