On Fri, Sep 19, 2014 at 1:45 PM, Hugues Evrard <hugues.evr...@inria.fr> wrote: > […] > However, such abstractions require the editor to know the structure of > language being edited. If this means having a parser for each language > under edition, then I think it's better to not have such abstractions. > Still, the information needed for syntax highlighting may be enough to > offer some basic abstractions, which may be obtained using regexp (maybe > regexps are already too heavy?): > - comments > - block of codes > - beginning and end of function definitions > - text between two matching "parenthesis" (same abstraction for > "(...)", "[...]", "{...}", etc)
I think that the biggest problem is that not all languages have these. Haskell doesn't really have “blocks of code” (although admittedly the monad notation…) nor does lisp. Instead they have expressions which are more tree like than list like. The nesting of code in C is shallower than in lisp which means different priorities for the movement and range operations for the different languages. On the other hand, some languages have features you do not cover. ML (and some others) have a powerful module system that requires more bindings than C. Lisp, ML, Haskell, Scala, Rust, &c. have pattern matches that are sort of like switches but not really. &c. All in all, I think that a high-level, language agnostic editor is very difficult. It might actually lead to IDEs and other such monsters that support a given list of languages but are actually a pain to use as a general tool. Note that some editors make it more or less easy to integrate a language specific tool-chain. (Acme is really good at that because of its handling of IO, its 9p interface, and the sam editing language. Vim is terrible and it takes mad geniuses like tpope to get descent filetype plugins.) Consider the merlin project for OCaml. They forked the language parser and typer to make a daemon that provides IDE-like features for editors to interact with. I think this design is simpler: editors to edit text, they talk to a server about line numbers and character offsets, the server understands these positions as meaningful code entities. Cheers, -- ______________ Raphaël Proust