* Bug in nxml-mode (indentation)?
@ 2007-12-17 21:56 Eric Lilja
2007-12-18 3:46 ` Mark A. Hershberger
0 siblings, 1 reply; 15+ messages in thread
From: Eric Lilja @ 2007-12-17 21:56 UTC (permalink / raw)
To: emacs-devel
Hello, I'm using GNU Emacs 23.0.50.1 (i386-mingw-nt5.1.2600) of
2007-12-17 on MINDCOOLER. I noticed a difference in how the old xml-mode
versus nxml-mode indents an xml-file where you have a tag that stretches
over several lines (hope I use the terminology correct here). Consider
this simple test file (hope the spaces are preserved in the post or this
will be a useless report):
<outer>
<p>This text stretches over several lines.
This text stretches over several lines.
This text stretches over several lines.
</p>
</outer>
This is the indentation you get with the old xml-mode (M-x xml-mode) and
you can see I'm using an offset of two spaces.
Now consider the indentation using nxml-mode:
<outer>
<p>This text stretches over several lines.
This text stretches over several lines.
This text stretches over several lines.
</p>
</outer>
Now this I don't like. The last two "This text stretches over several
lines" should be indented another step like in plain xml-mode I feel.
I'm just beginning with xml and my own xml-files usually don't look like
this but I do have to work with such files. Is the nxml-mode way of
indenting vs xml-mode in this particular example to be considered a bug?
If it is, let me know if you need any more information from me. Thanks!
- Eric
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-17 21:56 Bug in nxml-mode (indentation)? Eric Lilja
@ 2007-12-18 3:46 ` Mark A. Hershberger
2007-12-18 9:15 ` Eric Lilja
2007-12-21 0:41 ` Stefan Monnier
0 siblings, 2 replies; 15+ messages in thread
From: Mark A. Hershberger @ 2007-12-18 3:46 UTC (permalink / raw)
To: emacs-devel; +Cc: Eric Lilja
Eric Lilja <mindcooler@gmail.com> writes:
> Is the nxml-mode way of indenting vs xml-mode in this particular
> example to be considered a bug?
Space can be significant (i.e. can convey meaning) in XML and there is
no way to figure out what the space means just from the snippets you've
given. Depending on the application, the following XML could be
considered identical or completely different:
<foo>bar</foo>
or
<foo>
bar
</foo>
or
<foo>
bar
</foo>
If you want to adjust the indention of nxml-mode, look at
nxml-child-indent and nxml-attribute-indent. Unfortunately, I don't see
anything to adjust indenting of lines that just contain text.
If you want to look at adding this functionality, the best place to
start looks like it would be the function
nxml-compute-indent-from-previous-line.
--
http://hexmode.com/
GPG Fingerprint: 7E15 362D A32C DFAB E4D2 B37A 735E F10A 2DFC BFF5
The most beautiful experience we can have is the mysterious.
-- Albert Einstein, The World As I See it
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 3:46 ` Mark A. Hershberger
@ 2007-12-18 9:15 ` Eric Lilja
2007-12-18 9:38 ` Jason Rumney
2007-12-21 0:41 ` Stefan Monnier
1 sibling, 1 reply; 15+ messages in thread
From: Eric Lilja @ 2007-12-18 9:15 UTC (permalink / raw)
To: emacs-devel
Mark A. Hershberger wrote:
Thanks for the reply Mr Hershberger,
> Eric Lilja <mindcooler@gmail.com> writes:
>
>> Is the nxml-mode way of indenting vs xml-mode in this particular
>> example to be considered a bug?
>
> Space can be significant (i.e. can convey meaning) in XML and there is
> no way to figure out what the space means just from the snippets you've
> given. Depending on the application, the following XML could be
> considered identical or completely different:
Convey meaning? To whom? The parser? I had no idea. I just know that
xml-mode and nxml-mode indents the example file differently and I like
the old mode does better. Are you saying it affects validation and what
you get when you parse the file?
>
> <foo>bar</foo>
> or
> <foo>
> bar
> </foo>
> or
> <foo>
> bar
> </foo>
>
> If you want to adjust the indention of nxml-mode, look at
> nxml-child-indent and nxml-attribute-indent. Unfortunately, I don't see
> anything to adjust indenting of lines that just contain text.
>
> If you want to look at adding this functionality, the best place to
> start looks like it would be the function
> nxml-compute-indent-from-previous-line.
>
Well, since I'm not an elisp wizard I simply do not possess the know-how
to "fix" it. :( I just thought I should report it this finding.
(Actually, I have found another case where indentation differs and the
old xml-mode, to me, is more pleasing.)
Oh, and btw, you don't have CC me I read the list through my newsreader
(using gmane).
- Eric
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 9:15 ` Eric Lilja
@ 2007-12-18 9:38 ` Jason Rumney
2007-12-18 9:46 ` Eric Lilja
0 siblings, 1 reply; 15+ messages in thread
From: Jason Rumney @ 2007-12-18 9:38 UTC (permalink / raw)
To: Eric Lilja; +Cc: emacs-devel
Eric Lilja wrote:
> Convey meaning? To whom? The parser? I had no idea. I just know that
> xml-mode and nxml-mode indents the example file differently and I like
> the old mode does better. Are you saying it affects validation and
> what you get when you parse the file?
It won't affect validation as whitespace does not affect the validity of
the xml, but it will affect the result of evaluating the XPath
expression //foo/text(). Both behaviours are bugs if the text is being
indented without the user explicitly indenting it, the default should be
to leave the text unindented. Many applications will normalize
whitespace before using the text, but that is outside of the XML
parser's scope.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 9:38 ` Jason Rumney
@ 2007-12-18 9:46 ` Eric Lilja
2007-12-18 10:23 ` Jason Rumney
0 siblings, 1 reply; 15+ messages in thread
From: Eric Lilja @ 2007-12-18 9:46 UTC (permalink / raw)
To: emacs-devel
Jason Rumney wrote:
> Eric Lilja wrote:
>> Convey meaning? To whom? The parser? I had no idea. I just know that
>> xml-mode and nxml-mode indents the example file differently and I like
>> the old mode does better. Are you saying it affects validation and
>> what you get when you parse the file?
>
> It won't affect validation as whitespace does not affect the validity of
> the xml, but it will affect the result of evaluating the XPath
> expression //foo/text(). Both behaviours are bugs if the text is being
> indented without the user explicitly indenting it, the default should be
> to leave the text unindented. Many applications will normalize
> whitespace before using the text, but that is outside of the XML
> parser's scope.
Thanks Jason, that complicates things for sure even though I do not know
what XPath is yet. Ideally then one should be able to configure how a
file is indented without having to move things manually. I wish I was
the person who could deliver that. :( But how should a file be indented
for this XPath-thing to do its work correctly? Not at all or depending
on other parameters? I don't like that it is dependent on the
indentation level, heh.
- Eric
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 9:46 ` Eric Lilja
@ 2007-12-18 10:23 ` Jason Rumney
2007-12-18 10:52 ` Eric Lilja
2007-12-18 20:10 ` Lennart Borgman (gmail)
0 siblings, 2 replies; 15+ messages in thread
From: Jason Rumney @ 2007-12-18 10:23 UTC (permalink / raw)
To: Eric Lilja; +Cc: emacs-devel
Eric Lilja wrote:
> But how should a file be indented for this XPath-thing to do its work
> correctly? Not at all or depending on other parameters?
The text enclosed within an element should not be indented at all,
unless the user explicitly says so, or the user is using some
specialization of nxml-mode, such as xhtml-mode, where it is known that
the application will normalize whitespace.
Elements and attributes can be indented as normal, as whitespace is not
significant there.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 10:23 ` Jason Rumney
@ 2007-12-18 10:52 ` Eric Lilja
2007-12-18 11:29 ` Jason Rumney
2007-12-18 20:10 ` Lennart Borgman (gmail)
1 sibling, 1 reply; 15+ messages in thread
From: Eric Lilja @ 2007-12-18 10:52 UTC (permalink / raw)
To: emacs-devel
Jason Rumney wrote:
> Eric Lilja wrote:
>
> The text enclosed within an element should not be indented at all,
> unless the user explicitly says so, or the user is using some
> specialization of nxml-mode, such as xhtml-mode, where it is known that
> the application will normalize whitespace.
>
> Elements and attributes can be indented as normal, as whitespace is not
> significant there.
What about the case when you open two tags on the same line. Here's an
example file, first indented using xml-mode and then with nxml-mode:
xml-mode:
<outermost>
<firstinner><secondinner>Some Text
</secondinner>
Some more text
</firstinner>
</outermost>
nxml-mode:
<outermost>
<firstinner><secondinner>Some Text
</secondinner>
Some more text
</firstinner>
</outermost>
To me, the nxml-mode version looks weird indeed. The closing
</secondinner> is not indented at all for one thing. But as I said, I'm
new at this so I'm just reporting things that might be useful
information to someone.
I wish I could set a flag that makes the indentation not care about
xpath/xquery and indent like the old xml-mode. :)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 10:52 ` Eric Lilja
@ 2007-12-18 11:29 ` Jason Rumney
2007-12-18 12:55 ` Eric Lilja
2007-12-18 20:59 ` Edward O'Connor
0 siblings, 2 replies; 15+ messages in thread
From: Jason Rumney @ 2007-12-18 11:29 UTC (permalink / raw)
To: Eric Lilja; +Cc: emacs-devel
Eric Lilja wrote:
> I wish I could set a flag that makes the indentation not care about
> xpath/xquery and indent like the old xml-mode. :)
It's nothing to do with XPath or XQuery, they are just ways of
addressing information in the document. In text blocks within XML,
whitespace is significant.
However, I've tried it myself now, and nothing seems to be indented
without an explicit command from the user. So there doesn't seem to be
any harm in making the indentation behaviour give the most aesthetically
pleasing results.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 11:29 ` Jason Rumney
@ 2007-12-18 12:55 ` Eric Lilja
2007-12-18 20:59 ` Edward O'Connor
1 sibling, 0 replies; 15+ messages in thread
From: Eric Lilja @ 2007-12-18 12:55 UTC (permalink / raw)
To: emacs-devel
Jason Rumney wrote:
> Eric Lilja wrote:
>> I wish I could set a flag that makes the indentation not care about
>> xpath/xquery and indent like the old xml-mode. :)
>
> It's nothing to do with XPath or XQuery, they are just ways of
> addressing information in the document. In text blocks within XML,
> whitespace is significant.
>
> However, I've tried it myself now, and nothing seems to be indented
> without an explicit command from the user. So there doesn't seem to be
> any harm in making the indentation behaviour give the most aesthetically
> pleasing results.
Yes, that would be very nice indeed. I would love being able to use
nxml-mode exclusively so I can master it properly and still have it
indent the way I like for xml-files where indentation is only to be
aesthetically pleasing. Do you have any comments on the indentation made
my nxml-mode in my second example?
OT: Now if only my new laptop would appear so I can try out gnu/linux on
it... (it came to my city during the night then got sent to another one?!)
- Eric
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 11:29 ` Jason Rumney
2007-12-18 12:55 ` Eric Lilja
@ 2007-12-18 20:59 ` Edward O'Connor
2007-12-18 21:53 ` Eric Lilja
1 sibling, 1 reply; 15+ messages in thread
From: Edward O'Connor @ 2007-12-18 20:59 UTC (permalink / raw)
To: emacs-devel
Jason Rumney wrote:
> So there doesn't seem to be any harm in making the indentation
> behaviour give the most aesthetically pleasing results.
For what it's worth, nxml-mode's current indentation behavior is, to me,
more aesthetically pleasing than that of xml-mode.
--
Edward O'Connor
hober0@gmail.com
Ense petit placidam sub libertate quietem.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 20:59 ` Edward O'Connor
@ 2007-12-18 21:53 ` Eric Lilja
2007-12-21 2:05 ` Edward O'Connor
0 siblings, 1 reply; 15+ messages in thread
From: Eric Lilja @ 2007-12-18 21:53 UTC (permalink / raw)
To: emacs-devel
Edward O'Connor wrote:
> Jason Rumney wrote:
>
>> So there doesn't seem to be any harm in making the indentation
>> behaviour give the most aesthetically pleasing results.
>
> For what it's worth, nxml-mode's current indentation behavior is, to me,
> more aesthetically pleasing than that of xml-mode.
>
>
Even as it appears in my second example? Well, it doesn't matter, the
ideal solution I'm hoping for is to have both ways available and maybe
the option to control the rules in detail as one can in other modes,
like CC Mode.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 21:53 ` Eric Lilja
@ 2007-12-21 2:05 ` Edward O'Connor
0 siblings, 0 replies; 15+ messages in thread
From: Edward O'Connor @ 2007-12-21 2:05 UTC (permalink / raw)
To: emacs-devel
Eric Lilja wrote:
>>> So there doesn't seem to be any harm in making the indentation
>>> behaviour give the most aesthetically pleasing results.
>>
>> For what it's worth, nxml-mode's current indentation behavior is, to me,
>> more aesthetically pleasing than that of xml-mode.
>
> Even as it appears in my second example?
Well, consider nxml-mode's behavior with this:
<p>
This is a test of the emergency broadcast system. <span>This is
only a test. in the case of an actual emergency, something
interesting would happen now.</span>
</p>
Essentially, "newline after start tag" tells nxml to treat that element
as block-level, whereas "element content immediately after start tag"
tells nxml to treat that element as inline-level. At least in the cases
of Atom, RSS, and XHTML, this heuristic pretty much nails the desired
behavior. In this example, do you really want line 2 of the paragraph to
be indented more than lines 1 and 3?
--
Edward O'Connor
hober0@gmail.com
Ense petit placidam sub libertate quietem.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 10:23 ` Jason Rumney
2007-12-18 10:52 ` Eric Lilja
@ 2007-12-18 20:10 ` Lennart Borgman (gmail)
1 sibling, 0 replies; 15+ messages in thread
From: Lennart Borgman (gmail) @ 2007-12-18 20:10 UTC (permalink / raw)
To: Jason Rumney; +Cc: Eric Lilja, emacs-devel
Jason Rumney wrote:
> Eric Lilja wrote:
>> But how should a file be indented for this XPath-thing to do its work
>> correctly? Not at all or depending on other parameters?
>
> The text enclosed within an element should not be indented at all,
> unless the user explicitly says so, or the user is using some
> specialization of nxml-mode, such as xhtml-mode, where it is known that
> the application will normalize whitespace.
(I guess you mean nxhtml-mode which is derived from nxml-mode.)
But just to be sure: Are you saying that in XHTML files the whitespace
extent in the text parts (that part that is shown in a web browser) is
significant (even though the web browser does not care much about it)?
If so, what should a confused editor do?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-18 3:46 ` Mark A. Hershberger
2007-12-18 9:15 ` Eric Lilja
@ 2007-12-21 0:41 ` Stefan Monnier
2007-12-21 4:05 ` Mark A. Hershberger
1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2007-12-21 0:41 UTC (permalink / raw)
To: Mark A. Hershberger; +Cc: Eric Lilja, emacs-devel
>> Is the nxml-mode way of indenting vs xml-mode in this particular
>> example to be considered a bug?
> Space can be significant (i.e. can convey meaning) in XML and there is
> no way to figure out what the space means just from the snippets you've
> given. Depending on the application, the following XML could be
> considered identical or completely different:
> <foo>bar</foo>
> or
> <foo>
> bar
> </foo>
> or
> <foo>
> bar
> </foo>
But this problem you bring up is about whether to auto-indent or not,
not about *how* to auto-indent. I.e. it's unrelated to the OP's problem.
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Bug in nxml-mode (indentation)?
2007-12-21 0:41 ` Stefan Monnier
@ 2007-12-21 4:05 ` Mark A. Hershberger
0 siblings, 0 replies; 15+ messages in thread
From: Mark A. Hershberger @ 2007-12-21 4:05 UTC (permalink / raw)
To: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> Is the nxml-mode way of indenting vs xml-mode in this particular
>>> example to be considered a bug?
>
>> Space can be significant (i.e. can convey meaning) in XML and there is
>> no way to figure out what the space means just from the snippets you've
>> given.
>
> But this problem you bring up is about whether to auto-indent or not,
> not about *how* to auto-indent. I.e. it's unrelated to the OP's problem.
I was just pointing out that there was no reason to consider it a bug.
Unless you think that different XML modes indenting differently is a
bug. That is, afaik, there is no canonical XML indention.
--
http://hexmode.com/
GPG Fingerprint: 7E15 362D A32C DFAB E4D2 B37A 735E F10A 2DFC BFF5
My happiness grows in direct proportion to my acceptance, and in
inverse proportion to my expectations. -- Michael J. Fox
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2007-12-21 4:05 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-17 21:56 Bug in nxml-mode (indentation)? Eric Lilja
2007-12-18 3:46 ` Mark A. Hershberger
2007-12-18 9:15 ` Eric Lilja
2007-12-18 9:38 ` Jason Rumney
2007-12-18 9:46 ` Eric Lilja
2007-12-18 10:23 ` Jason Rumney
2007-12-18 10:52 ` Eric Lilja
2007-12-18 11:29 ` Jason Rumney
2007-12-18 12:55 ` Eric Lilja
2007-12-18 20:59 ` Edward O'Connor
2007-12-18 21:53 ` Eric Lilja
2007-12-21 2:05 ` Edward O'Connor
2007-12-18 20:10 ` Lennart Borgman (gmail)
2007-12-21 0:41 ` Stefan Monnier
2007-12-21 4:05 ` Mark A. Hershberger
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.