From: "Drew Adams" <drew.adams@oracle.com>
To: "'Lennart Borgman \(gmail\)'" <lennart.borgman@gmail.com>
Cc: 'Emacs Devel' <emacs-devel@gnu.org>
Subject: RE: Indentation contest nxml vs xml-mode
Date: Thu, 6 Mar 2008 14:21:28 -0800 [thread overview]
Message-ID: <00da01c87fd8$6c881420$0600a8c0@us.oracle.com> (raw)
In-Reply-To: <47D0679F.5000001@gmail.com>
> ***** xml-mode
> <outermost>
> <inner1><inner2>
> <inner3>Duh</inner3>
> </inner2>
> </inner1>
> </outermost>
>
> ***** nxml-mode
> <outermost>
> <inner1><inner2>
> <inner3>Duh</inner3>
> </inner2>
> </inner1>
> </outermost>
IMO, neither is great (both are ugly and confusing). I've never seen XML
indented like either of those (except when it wasn't formatted at all).
FWIW, I use this:
<outermost>
<inner1><inner2>
<inner3>Duh</inner3>
</inner2>
</inner1>
</outermost>
IOW: 1. Align opening and closing tags. 2. Indent just enough so that nested
tags start after the </ of their parent.
Why? Because (1) you need to be able to easily find corresponding tags and
(2) XML is verbose, so the less indentation the better. You could indent
only one space, but I think it's more readable with two.
Another possibility is what we (most of us) use in Lisp - avoid starting
lines with closing tags:
<outermost>
<inner1><inner2>
<inner3>Duh</inner3></inner2></inner1>
<inner1>some more</inner1></outermost>
That can also work well in some contexts.
I present lots of XML in doc everyday. I haven't found anything more
readable than just indenting two spaces and aligning the corresponding
element tags. I also align attributes. But I never, ever introduce or change
significant whitespace, such as that within a text() node, if I can avoid
it. For example, I never indent the text here:
<foo>some text that is too
long for a printed line</foo>
That should never be changed by automatic indentation to, say, this:
<foo>some text that is too
long for a printed line</foo>
or this:
<foo>some text that is too
long for a printed line
</foo>
or anything else - it should not be changed at all. If the representation
(e.g. HTML or PDF doc) can't reasonably let it wrap naturally (without,
e.g., introducing a scroll bar), then a single newline is best, with no
indentation. Readers will get the idea that it represents wrapped text and
it really isn't split at all.
I mention this because there was some question here a while back about it.
Indentation (e.g. pretty-printing) should avoid changing significant
whitespace.
HTH.
next prev parent reply other threads:[~2008-03-06 22:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-06 18:41 Indentation contest nxml vs xml-mode Lennart Borgman (gmail)
2008-03-06 18:50 ` Drew Adams
2008-03-06 21:52 ` Lennart Borgman (gmail)
2008-03-06 22:21 ` Drew Adams [this message]
2008-03-06 22:38 ` Lennart Borgman (gmail)
2008-03-07 3:31 ` Drew Adams
2008-03-06 22:18 ` Jason Rumney
2008-03-06 22:34 ` Lennart Borgman (gmail)
2008-03-07 3:31 ` Drew Adams
2008-03-07 0:28 ` Miles Bader
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='00da01c87fd8$6c881420$0600a8c0@us.oracle.com' \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=lennart.borgman@gmail.com \
/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 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).