[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nXML mode maintenance and enhancement

From: Yuri Khan
Subject: Re: nXML mode maintenance and enhancement
Date: Wed, 23 May 2018 21:18:55 +0700

On Wed, May 23, 2018 at 7:15 PM N. Raghavendra <address@hidden>

> I would like to help with the maintenance and enhancement of nXML mode.
> Here are some things which may be considered:

> 1. Make indentation in nXML mode compatible with that in the official
>     SGML mode, and in the unofficial PSGML mode; the latter indentation
>     styles are arguably more natural, and followed by projects like the
>     FreeBSD Documentation Project.  I had stumbled across this problem
>     recently, as in
>     https://lists.gnu.org/archive/html/help-gnu-emacs/2018-05/msg00009.html

There is not and cannot be One True Way to indent XML, for all users and
uses of nXML.

XML formats are used for text markup languages such as XHTML and DocBook;
configuration files; and various data files. The indentation rules in
‘nxml-indent-line’ are very much oriented towards data files — as in, “add
a level of indentation for every unclosed opening tag; remove a level of
indentation for every closing tag opened elsewhere, independent of the
actual tag names”. I am not well acquainted with PSGML, but I suspect that
it is is more text-markup-oriented.

What I would like is a way to specify indentation rules depending on the
XML schema, so that I could use one set of rules for XHTML, another for
DocBook, a third one for FictionBook 2, and a default set for all other
types of XML documents.

I sort-of can do that now. This involves: hooking ‘rng-schema-change-hook’;
in the hook function, looking at ‘rng-current-schema’ to see if its ‘caddr’
is "html"; and, if so, pointing ‘indent-line-function’ at my own function
that pretty much has to reimplement the whole of ‘nxml-indent-line’ from
scratch, in about 250 lines of Elisp.

Maybe the first step would be to identify specific indentation rules people
want, and provide building blocks for those.

To give an example of things I customize *for the html schema only*:

* Do not increase indentation level inside <html>, <body>, any inline
elements, and any elements with flow content model (defined by enumerating
all their tag names).

     <p>Lorem ipsum dolor sit amet,
     consectetur wgah’nagl fhtagn.</p>

* Do increase indentation level inside a few select flow-content elements
such as <li>.

* Increase indentation level inside mixed content model elements (also
defined by enumeration) if and only if they contain block elements
(determined as no text following the opening tag on the same line).

       <p>Paragraph 1 of quote</p>
       <p>Paragraph 2 of quote</p>


     <blockquote>Lorem ipsum
     dolor sit amet</blockquote>

* Increase indentation level of a <dd> immediately following a <dt>…</dt>,
and decrease indentation level of a <dt> immediately following a <dd>…</dd>.

       <dd>A type of fruit.</dd>
       <dd>A computer company.</dd>
       <dd>Another type of fruit.</dd>

* Never attempt to reindent inside <style>, <script>, <pre>, <code> and

> 2. Addition of features in PSGML mode, e.g,

>     b) Support for processing instructions such as, e.g.,

>        <?PSGML ELEMENT foo nofill=t>

>        which specify that a `foo' element should not be disturbed when
>        filling a region; this is useful if one wants to fill a buffer
>        containing verbatim elements such as program listings.

Better to have this controlled by a customizable variable, so as not to
litter the document text with Emacs/nXML-specific instructions. Again, this
variable should be keyed by schema, and contain a list of element tag names
inside which filling is undesirable.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]