all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Lennart Borgman <lennart.borgman@gmail.com>
Cc: cyd@gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: web-mode.el
Date: Fri, 15 Jun 2012 07:24:10 +0400	[thread overview]
Message-ID: <4FDAAADA.1030609@yandex.ru> (raw)
In-Reply-To: <CANbX366mXwtTNQr5+_TaSa_BJsA+b1kb6sgRzGOVytWUY3ZAjQ@mail.gmail.com>

On 14.06.2012 20:54, Lennart Borgman wrote:
> On Thu, Jun 14, 2012 at 4:24 PM, Dmitry Gutov<dgutov@yandex.ru>  wrote:
>> Stefan Monnier<monnier@iro.umontreal.ca>  writes:
>>>> 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 agree in principle. And since fontification of chunks can already be
>> done reliably enough (if not with best performance), I think indentation
>> function conventions would be more important. Shall we start with
>> collecting cases?
>
> I am not sure I agree. The way I have proposed to do it is to change
> the low level functions reading the buffer so that you can lie to them
> and say that the chunks in other major modes are just whitespace+line
> feeds. It would be reliable (I think), but it requires much effort so
> it still may not be worth it.

Fully isolating the chunks might not be the best course of action, even 
if it were not too hard to do.
For example, if we want to adjust indentation inside <% if %> <% end%> 
blocks, we need to be able to actually look inside them while we're in 
the primary mode chunk (between those two).

> I took a look at what I had done so far (it was some time ago now). I
> have not touched the C code. I have only made some changes in
> mumamo.el towards this goal.
>
> As Dmitry says, fontification is rather simple (but you have to be
> careful to make it fast). Indentation is harder.
>
> First of all I have tried to write down the logic to use. I have
> rewritten that part a few times. Even this was harder then I expected.
> You can see my current comments here in mumamo-indent-line-function-1
> (at line 7915 currently):
>
>    http://bazaar.launchpad.net/~nxhtml/nxhtml/main/view/head:/util/mumamo.el
>
> Second I have moved towards doing indentation the way it should have
> been done if the changes in the C code were done. I do this by copying
> the code to a mirror buffer, replacing everything in "other" chunks
> with whitespace+line feeds.
>
> It is easy to get things a bit wrong when you do this of course. I am
> not sure if the problem you have seen, Dmitry, is because (1) failed
> to copy correctly, (2) the idea is somehow buggy, or (3) I just did
> not implement all cases or did not finish implementing them.

I don't think I understand the code enough to answer that, but I'm 
inclined to fault implementation (not necessarily of the stage you 
described above). For example, one of the problems shows that 
indentation function behaves differently, depending on where inside the 
(same) line the point is.

As an aside, this bit from the docstring sounds not very useful, maybe 
even harmful:

"- However first non-empty line indentation in a chunk when going
in is special if prev-prev chunk is on same mumamo-depth and
have the same major mode. Then indent relative last non-empty
line in prev-prev chunk."

>> So far I have two problems without obvious solutions:
>>
>> 1) js-mode uses (widen) at the beginning of js-indent-line, and then calls
>> (syntax-ppss).
>
> There are several modes for javascript. And of course for html too;
> nxml-mode is one. Stopping nxml-mode from crossing the chunks
> boundaries is not easy.

js2-mode's indentation function is very similar to js-mode, since 
they're both derived from an javascript-mode. It doesn't work in 
multi-mode context, though, and while fixing that shouldn't be too hard, 
I'm not sure it's worth spending time on, because js2-mode's advantages 
over js-mode are most evident with larger files, not small snippets.

I have yet to look into using nxml as primary mode. Do you have any 
suggestions how that could be made easier?

>>> 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.
>
> I have tried to implement something like that in mumamo.el, but I
> think it is not working correctly anymore. Something might have
> changed since I did that.

Could you show where this is implemented?



  reply	other threads:[~2012-06-15  3:24 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14 14:24 web-mode.el Dmitry Gutov
2012-06-14 16:54 ` web-mode.el Lennart Borgman
2012-06-15  3:24   ` Dmitry Gutov [this message]
2012-06-16  1:43     ` web-mode.el Lennart Borgman
2012-06-16 13:19       ` web-mode.el Dmitry Gutov
2012-06-16 13:30         ` web-mode.el Lennart Borgman
2012-06-19  1:18           ` web-mode.el Dmitry Gutov
2012-06-19  1:56             ` web-mode.el Lennart Borgman
2012-06-19 16:04               ` web-mode.el Dmitry Gutov
2012-06-14 17:28 ` web-mode.el Stefan Monnier
2012-06-15  1:40   ` web-mode.el Dmitry Gutov
2012-06-16  6:17     ` web-mode.el Stefan Monnier
2012-06-16 10:55       ` web-mode.el Lennart Borgman
2012-06-16 13:27       ` web-mode.el Dmitry Gutov
2012-06-16 13:32         ` web-mode.el Lennart Borgman
2012-06-18  1:49         ` web-mode.el Stefan Monnier
2012-06-19  1:00           ` web-mode.el Dmitry Gutov
2012-06-19  3:09             ` web-mode.el Stefan Monnier
2012-06-19 10:39               ` web-mode.el Lennart Borgman
2012-06-20  2:01               ` web-mode.el Dmitry Gutov
2012-07-31  8:46                 ` web-mode.el Lennart Borgman
  -- strict thread matches above, loose matches on Subject: below --
2012-06-14  0:33 web-mode.el Dmitry Gutov
2012-06-14  1:49 ` web-mode.el Lennart Borgman
2012-06-14  2:13   ` web-mode.el Dmitry Gutov
2012-06-14  3:23 ` web-mode.el Stefan Monnier
2012-06-15  8:34   ` web-mode.el Vitalie Spinu
2012-06-15  9:23     ` web-mode.el Lennart Borgman
2012-06-15  9:41       ` web-mode.El Vitalie Spinu
2012-06-16  1:37         ` web-mode.El Lennart Borgman
2012-06-11 22:24 web-mode.el Bois Francois-Xavier
2012-06-12 11:37 ` web-mode.el Lennart Borgman
2012-06-12 13:23   ` web-mode.el Bois Francois-Xavier
     [not found]   ` <CAK1xyPN=7To8ZsznHdjhDO=pd_8MocAqWXzSSrFJNe=uHRwp9g@mail.gmail.com>
2012-06-12 13:24     ` web-mode.el Lennart Borgman
2012-06-12 13:45       ` web-mode.el Bois Francois-Xavier
2012-06-13  7:45 ` web-mode.el Chong Yidong
2012-06-13  8:39   ` web-mode.el Bois Francois-Xavier
2012-07-31  8:41     ` web-mode.el Steinar Bang
2012-06-13 10:36   ` web-mode.el Lennart Borgman
2012-06-13 10:49     ` web-mode.el Bois Francois-Xavier
2012-06-13 10:55       ` web-mode.el Lennart Borgman
2012-06-13 11:43         ` web-mode.el Bois Francois-Xavier
2012-06-13 11:52           ` web-mode.el Lennart Borgman
2012-06-13 12:30     ` web-mode.el Stefan Monnier
2012-06-13 12:37       ` web-mode.el Lennart Borgman
2012-06-13 10:37   ` web-mode.el Dmitry Gutov
2012-06-13 10:46     ` web-mode.el Lennart Borgman
2012-06-13 10:26 ` web-mode.el Dmitry Gutov
2012-06-13 14:18 ` web-mode.el Richard Riley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FDAAADA.1030609@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=cyd@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.