jed-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: small problem with indentation in xmlmode


On Mon, Feb 28, 2005 at 02:24:54PM +0100, Joachim Schmitz wrote:
> <tal:block metal:fill-slot="main"
> 	     tal:define="item options/item;
> 	     form_url     string:${request/URL1};
> 	     fields options/fields;
> 	     conference options/conference">
> 	     <div>
>     ^<div should actually be here
>     <span tal:condition="item" tal:content="conference/title" />
>       ^<span should actually be here
>   </div>
>     ^</div> should actually be here
> 
> this only happens after a multiline attributes value. Can you give me a 
> hint where to change this ?

Since it's valid for XML attributes to contain an unescaped '>' the
indentation routine can't consider a tag ended when it sees one, but
needs to check whether it's inside a string. This is done with the 
jed library function parse_to_point(), which has been configured to
not consider multi-line strings in xmlmode. The latter '"' is
therefore considered to start a new string, and the '>' that should
end the start-tag is ignored.

The "solutions" that I can see are:
  * Add a newline after the end of the multi-line attribute, before
    the '>'.
  * Use single quotes instead of double quotes.
  * Remove the single-line restriction by removing the '|0x80' from
    the call to set_syntax_flags(). (But beware, this is likely to
    have some unintended results if double quotes are used for things
    other than attribute delimiters).
  * Also consider '>' in attributes as ending the tag (patch attached). 
    This will obviously cause problems if you have raw '>':s in the
    attributes.
  * Add some sort of ad hoc detection for this situation. Maybe
    something along the lines of (untested):
    
    if (parse_to_point() == 0 or
        (parse_to_point() == -1 and 
         (blooking_at("\">") or blooking_at("\"/>"))))
    
    in the same place that the attached patch modifies (the last 
    switch case for state == 2).
  
All of these are pretty unsatisfactory as generic solutions, but maybe
one of them is acceptable to you.

-- 
Juho Snellman
diff -u -r1.1 xmlmode.sl
--- xmlmode.sl  31 May 2003 03:16:26 -0000      1.1
+++ xmlmode.sl  28 Feb 2005 17:51:49 -0000
@@ -207,7 +211,7 @@
            {   () = right(1);
                % If the '>' wasn't inside a string, we end the 
                % element
-               if (parse_to_point() == 0) {
+               if (parse_to_point() == 0 or parse_to_point() == -1) {
                    state = 3;
                    if (what_line() == row) {
                        ind = ind-(1-closing_tag);

[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]