unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* web-mode.el
@ 2012-06-11 22:24 Bois Francois-Xavier
  2012-06-12 11:37 ` web-mode.el Lennart Borgman
                   ` (3 more replies)
  0 siblings, 4 replies; 48+ messages in thread
From: Bois Francois-Xavier @ 2012-06-11 22:24 UTC (permalink / raw)
  To: emacs-devel

Dear Emacsians,

I've written web-mode.el, a major mode for PHP/HTML templates files.
It aims to natively indent and syntaxcolor according to the "context"
of (point) (which can be in an HTML part or in a PHP/JavaScript/CSS
bloc).
As it is my first experience with emacs lisp programming, I would be
really grateful to receive your feedbacks on any aspect of this mode
(core programming, function/var naming, conventions, etc.). For many
aspects, I wonder if I use hacks or correct ways to do the job (ex. I
look at the face name in my indent function to know if (point) is in a
comment or a string).
The mode is available here:
http://fxbois.free.fr/lisp/web-mode.el

I will also publish a web page which will look like this:
http://fxbois.free.fr/lisp/web-mode.html

Perhaps you also have comments about it.

I will release this mode on github after reading your comments/advices.

Thank you in advance.

François-Xavier Bois

ps: sorry for my poor english



^ permalink raw reply	[flat|nested] 48+ messages in thread
* Re: web-mode.el
@ 2012-06-14  0:33 Dmitry Gutov
  2012-06-14  1:49 ` web-mode.el Lennart Borgman
  2012-06-14  3:23 ` web-mode.el Stefan Monnier
  0 siblings, 2 replies; 48+ messages in thread
From: Dmitry Gutov @ 2012-06-14  0:33 UTC (permalink / raw)
  To: lennart.borgman; +Cc: cyd, emacs-devel

Lennart Borgman <lennart.borgman@gmail.com> writes:

 > On Wed, Jun 13, 2012 at 12:37 PM, Dmitry Gutov <dgutov@yandex.ru> wrote:
 >>
 >> Hi Chong,
 >>
 >>> Thanks, this looks interesting. The problem with nXhtml mode (and
 >>> php-mode) is that we've had a hell of a time trying to get the 
copyright
 >>> assignments to get them incorporated into Emacs, and at this point I've
 >>> given up.
 >>
 >> Is there a particular reason that multi-mode is not in the list?
 >>
 >> http://www.loveshack.ukfsn.org/emacs/multi-mode.el
 >>
 >> I reviewed the packages dealing with this problem recently, and this one
 >> looks most well-written, if probably outdated.
 >> And if we believe the copyright notice, copyright assignments are
 >> already in place. Provided it's a viable candidate, I might see what I
 >> can do to bring it up-to-date.
 >
 > Please see my comments about mumamo.el. It is not possible to write
 > something that works for all cases with the current Emacs. nXhtml
 > includes a rather large test-suite where you can see some of the
 > problems. It should be rather easy to change this test suite to run
 > with for example multi-mode.el. If you do that I think you will get a
 > better view of what works and what does not work.

I'll look at the tests, thanks.

 > 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'm also using narrowing during indentation, but some modes (like js)
use (widen) in indent-line-function. It should be somewhat fixable by
applying and removing syntax-table text property to text before the
chunk, but may make things even slower.

Anyway, you've seen the list of my immediate gripes about how MuMaMo
works for ERB, and I'm inclined to fault chunk detection and indentation
logic in your code rather than facilities provided by Emacs.

That's not to say that some sort of built-in support wouldn't help, of
course.

-- Dmitry



^ permalink raw reply	[flat|nested] 48+ messages in thread
* Re: web-mode.el
@ 2012-06-14 14:24 Dmitry Gutov
  2012-06-14 16:54 ` web-mode.el Lennart Borgman
  2012-06-14 17:28 ` web-mode.el Stefan Monnier
  0 siblings, 2 replies; 48+ messages in thread
From: Dmitry Gutov @ 2012-06-14 14:24 UTC (permalink / raw)
  To: monnier; +Cc: cyd, lennart.borgman, emacs-devel

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?

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).

2) sgml-indent-line calls sgml-parse-tag-backward, which does
(re-search-backward "[<>]"), finds "<" and performs simple regexp check.
Thus, <% if a < 3 %> breaks indentation on following lines, until first
closing tag.

So it's 3 built-in functions as candidates for special interaction
with new syntax-table value.

 > 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.

Did you mean to write "C code" in the first sentence?

As far as I can see, enhanced (forward-comment) won't help much with
indentation.

And crossing two boundaries won't necessarily mean that we're in a chunk
in the same mode (or we're limited to supporting only two modes in the
same buffer), so that means syntax-table values can't be trivial.
Cons cell (mode-above . mode-below), and related code will need
to consider movement direction?



^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2012-07-31  8:46 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
  -- 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-14 14:24 web-mode.el Dmitry Gutov
2012-06-14 16:54 ` web-mode.el Lennart Borgman
2012-06-15  3:24   ` web-mode.el Dmitry Gutov
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).