all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuri Khan <yurivkhan@gmail.com>
To: nyraghu27132@gmail.com, Emacs developers <emacs-devel@gnu.org>
Subject: Re: nXML mode maintenance and enhancement
Date: Wed, 23 May 2018 21:18:55 +0700	[thread overview]
Message-ID: <CAP_d_8XYPP75oBLqzXbJcvZMX5dE_05TPqi6RdW+b5AnJanvWg@mail.gmail.com> (raw)
In-Reply-To: <87603e4lhz.fsf@gmail.com>

On Wed, May 23, 2018 at 7:15 PM N. Raghavendra <nyraghu27132@gmail.com>
wrote:

> 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).

     <html>
     <head>
       <title>Test</title>
     </head>
     <body>
     <p>Lorem ipsum dolor sit amet,
     consectetur wgah’nagl fhtagn.</p>
     </body>
     </html>

* 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).

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

     but:

     <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>.

     <dl>
     <dt>Apple</dt>
       <dd>A type of fruit.</dd>
       <dd>A computer company.</dd>
     <dt>Banana</dt>
       <dd>Another type of fruit.</dd>
     </dl>

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

> 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	other threads:[~2018-05-23 14:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 12:14 nXML mode maintenance and enhancement N. Raghavendra
2018-05-23 14:18 ` Yuri Khan [this message]
2018-05-23 14:48   ` N. Raghavendra
2018-05-23 15:15     ` Yuri Khan
2018-05-23 17:15       ` N. Raghavendra
2018-05-23 16:12 ` Stefan Monnier
2018-05-23 17:34   ` N. Raghavendra
2018-05-23 17:49     ` Stefan Monnier

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP_d_8XYPP75oBLqzXbJcvZMX5dE_05TPqi6RdW+b5AnJanvWg@mail.gmail.com \
    --to=yurivkhan@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=nyraghu27132@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 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.