[Top][All Lists]

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

Re: web-mode.el

From: Dmitry Gutov
Subject: Re: web-mode.el
Date: Thu, 14 Jun 2012 06:13:58 +0400
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1

On 14.06.2012 5:49, Lennart Borgman wrote:
On Thu, Jun 14, 2012 at 2:33 AM, Dmitry Gutov<address@hidden>  wrote:

Lennart Borgman<address@hidden>  writes:

However it might not be worth the trouble. The real problem lies in
the Emacs C core. Parsing functions can currently not be stopped from
parsing things outside of the major mode chunk they belong too.
(mumamo.el goes a long way to try to address this problems as far as
possible. That makes the code quite complicated. A rewrite of the C
core makes things very simple. In addition to this rewrite of the
scheduling functions to add suitable tools for handling chunk finding
might be necessary, but that is much simpler.)=C2=A7

 From what I know, mmm-mode counteracts this problem effectively enough,
narrowing buffer to chunks during fontification, binding
font-lock-dont-widen to t, etc.

I am afraid that is a total misunderstanding. Narrowing etc does not
help because it does not affect all the functions involved.

I must've mixed it up with multi-mode. mmm-mode does not indeed call narrow-to-region there, and instead calls respective font-lock-fontify-region-function's with chunk start and end positions.


Anyway, you've seen the list of my immediate gripes about how MuMaMo
works for ERB, and I'm inclined to fault chunk detection

Chunk detection must logically be done from the start of the file. In
the first version of MuMaMo I tried to do chunk detection from
anywhere in the file. That worked for simple cases but not for more
complicated cases so I rewrote this several years ago.

I have no idea about what trouble you have had. Perhaps you could
describe them? (Maybe there are still pieces of code I have forgotten
to rewrite?)


and indentation logic in your code

Indentation is surpricingly hard actually. One problem is that you
have to do some language specific parsing (which the major mode
normally does). Another problem is getting this to work with chunks
and across chunks. There are several alternatives for this in
mumamo.el - and unfortunately I think there might some trouble there.

One important thing that I'm almost certain your code doesn't do is set indent-line-function in all chunks to the same value. This function, when called, should save (- (current-column) (current-indentation)) value, to restore it after indentation if it's positive. Then it should go (back-to-indentation), look in what chunk the point is now, and act accordingly.

I suspect you have been looking at some of the easier cases. Please
take a look at the test cases. There should be more, but I think I
have written test cases for some of the troublesome cases.

I posit that I've managed to make the examples from the bug above work better then they do with eruby-html-mumamo-mode, using lesser (I think?) amount of code. Nothing is perfect, of course, but all templates in my current projects I've tried yet have shown no problems.

reply via email to

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