[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: web-mode.el

From: Vitalie Spinu
Subject: Re: web-mode.el
Date: Fri, 15 Jun 2012 10:34:38 +0200
User-agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/23.3 (gnu/linux)

  >> Stefan Monnier <address@hidden>
  >> on Wed, 13 Jun 2012 23:23:54 -0400 wrote:

  >> I'm also using narrowing during indentation, but some modes (like js)
  >> use (widen) in indent-line-function. It should be somewhat fixable by

  > I don't think it's worthwhile trying to make a "multi-major-mode" that
  > works with any major mode, no matter what wicked thing it does.
  > So it's OK to impose a few conventions that the major mode needs
  > to obey.  The important and difficult part is to figure what those
  > conventions need to be.

I also think that multi-major-mode is too much work into a wrong
direction. Major mode with chunk switching modes is a dead end
also. Modes are becoming heavier and more complex, and one can never
know reliably what is happening during the initialization. Besides that,
this approach is extremely expensive. Mumamo has almost 10000 lines and
it doesn't look like it's the end of it.

Dave Love wrote his 400 lines multi-mode.el in 2003, which is based on
indirect buffers (http://www.loveshack.ukfsn.org/emacs/multi-mode.el).
It still needs tweaking, but it's lightening fast and doesn't require
mode swapping. It happened that I've started improving it here
(https://github.com/vitoshka/litprog) as part of a general literate
programing framework project a couple of weeks ago.

I bet a working *minor*-web-mode can be written in less than 100 lines
only by specifying chunk delimiters regexps and a mode detection

  > Of course, tweaking some parts of the C mode might help.  E.g. we could
  > maybe extend syntax-tables slightly so that chunk boundaries are marked
  > with a special syntax-table value which then makes forward-comment skip
  > over "other language" chunks, so that any indentation code which
  > consistently ignores comments would then work in multi-major-mode.

In litprog-mode.el chunk delimiters already marked as comments to avoid
issues with parse-partial-sexp (they even have a separate mode). I guess
this works well enough for most of the cases. To achieve full generality
one would need to mark whole "irrelevant" chunks as comments. For
example in js-mode buffer all html, php etc chunks are comments. In
html-mode buffer js, php are comments, etc. 

Dmitry suggested collecting test cases. That would be great for
comparing multi modes head to head. Where can I find really difficult


reply via email to

[Prev in Thread] Current Thread [Next in Thread]