GNU bug report logs - #14003
24.3.50; sgml-mode: support angle brackets inside jsp tags

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dgutov <at> yandex.ru>

Date: Wed, 20 Mar 2013 03:40:02 UTC

Severity: normal

Found in version 24.3.50

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14003 in the body.
You can then email your comments to 14003 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14003; Package emacs. (Wed, 20 Mar 2013 03:40:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dmitry Gutov <dgutov <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 20 Mar 2013 03:40:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; sgml-mode: support angle brackets inside jsp tags
Date: Wed, 20 Mar 2013 07:36:59 +0400
sgml-mode has some support for preprocessing tags.
When it sees tags with percent characters inside (<% hello! %>), it says
that the tag's type is `jsp'.

The templating engine may be different (e.g. ERB or EJS), but all of
these examples can have arbitrary code inside, including angle brackets,
usually serving as comparison operators.

Before revno:111900, only having "<" inside a `jsp' tag was a problem:
it broke indentation on the following lines, until a closing containing
tag. With the aforementioned revision, having either "<" or ">" inside a
`jsp' tag breaks string highlighting, because they changes the depth in
parens returned by (syntax-ppss).

So, the previously discussed general problem
(http://lists.gnu.org/archive/html/emacs-devel/2012-06/msg00238.html)
got worse in practice.

I think we can make it better in this specific case without solving it
in general, and doing it for html-mode would be a big win.

Roughly, I propose to add a rule in sgml-syntax-propertize-function that
would forcibly mark all angle brackets between <% and %> as punctuation
syntax. Testing it with

(with-silent-modifications
  (put-text-property (point) (1+ (point))
                     'syntax-table (string-to-syntax ".")))

seems to help both with highlighting and indentation.

Before I started writing this text, I had another approach in mind, but
this is something that I can probably do in mmm-mode instead, without
changing sgml-mode, by wrapping submodes' syntax-propertize-functions.
Still, doing it sgml-mode should be simpler.

Thoughts?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14003; Package emacs. (Tue, 26 Mar 2013 16:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 14003 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 14003 <at> debbugs.gnu.org
Subject: Re: bug#14003: 24.3.50;
	sgml-mode: support angle brackets inside jsp tags
Date: Tue, 26 Mar 2013 12:49:18 -0400
> Roughly, I propose to add a rule in sgml-syntax-propertize-function that
> would forcibly mark all angle brackets between <% and %> as punctuation
> syntax. Testing it with

Sounds good.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14003; Package emacs. (Mon, 01 Apr 2013 13:36:02 GMT) Full text and rfc822 format available.

Message #11 received at 14003 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 14003 <at> debbugs.gnu.org
Subject: Re: bug#14003: 24.3.50;
	sgml-mode: support angle brackets inside jsp tags
Date: Mon, 01 Apr 2013 09:32:03 -0400
> Before I started writing this text, I had another approach in mind, but
> this is something that I can probably do in mmm-mode instead, without
> changing sgml-mode, by wrapping submodes' syntax-propertize-functions.
> Still, doing it sgml-mode should be simpler.
> Thoughts?

I agree doing it in sgml-mode would be simpler.

I do think that multi-major-mode support should let us handle
comments/strings in a separate mode (text-mode, by default).   But I'm
not sure if current multi-major-mode packages are up to that task.


        Stefan




Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Mon, 01 Apr 2013 20:47:02 GMT) Full text and rfc822 format available.

Notification sent to Dmitry Gutov <dgutov <at> yandex.ru>:
bug acknowledged by developer. (Mon, 01 Apr 2013 20:47:02 GMT) Full text and rfc822 format available.

Message #16 received at 14003-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 14003-done <at> debbugs.gnu.org
Subject: Re: bug#14003: 24.3.50; sgml-mode: support angle brackets inside
	jsp tags
Date: Tue, 02 Apr 2013 00:43:28 +0400
On 01.04.2013 17:32, Stefan Monnier wrote:
>> Before I started writing this text, I had another approach in mind, but
>> this is something that I can probably do in mmm-mode instead, without
>> changing sgml-mode, by wrapping submodes' syntax-propertize-functions.
>> Still, doing it sgml-mode should be simpler.
>> Thoughts?
>
> I agree doing it in sgml-mode would be simpler.

I've thought about it some more, and looks like it would be incompatible 
with what mmm-mode is currently doing. One of the latest additions is 
the composite syntax-propertize-function:

https://github.com/purcell/mmm-mode/blob/master/mmm-region.el#L806

It iterates over the regions and calls syntax-propertize-function of 
each major mode, passing it the bounds of the region. So adding 
propertization of angle brackets to sgml-syntax-propertize-function 
won't help because it won't be called on submode regions.

Wrapping propertize-functions of the submodes with that logic should 
work fine, though. So I guess I'll just close this bug.

> I do think that multi-major-mode support should let us handle
> comments/strings in a separate mode (text-mode, by default).   But I'm
> not sure if current multi-major-mode packages are up to that task.

Eh, maybe? With some caveats, probably, but delineating subregions based 
on string/comment status should be doable with a custom matcher 
function. But it doesn't seem to solve any big problems, AFAICT.

Handling code regions nested inside interpolated regions in strings, 
which I've posted about in emacs-devel before, would be nice to have, 
but it's much less of an immediate problem, especially since nobody uses 
this syntax feature of Ruby in real code much.

Handling it via mmm-mode, at least, is also problematic, because the 
syntactic state carries between subregions. So the text inside a string 
subregion will still be highlighted as string:

https://github.com/purcell/mmm-mode/issues/25




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14003; Package emacs. (Wed, 03 Apr 2013 18:29:02 GMT) Full text and rfc822 format available.

Message #19 received at 14003-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 14003-done <at> debbugs.gnu.org
Subject: Re: bug#14003: 24.3.50;
	sgml-mode: support angle brackets inside jsp tags
Date: Wed, 03 Apr 2013 14:25:48 -0400
>> I agree doing it in sgml-mode would be simpler.
> I've thought about it some more, and looks like it would be incompatible
> with what mmm-mode is currently doing.  One of the latest additions is the
> composite syntax-propertize-function:
> https://github.com/purcell/mmm-mode/blob/master/mmm-region.el#L806
> It iterates over the regions and calls syntax-propertize-function of each
> major mode, passing it the bounds of the region.  So adding propertization of
> angle brackets to sgml-syntax-propertize-function won't help because it
> won't be called on submode regions.

If don't use mmm-mode, then it should work.

But indeed when you use mmm-mode to handle the <%...%> text, then it
should be mmm-mode's task to handle that problem.


        Stefan "not saying that it's easy for mmm-mode to handle the problem"




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 02 May 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 54 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.