help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: nXML mode indentation


From: Yuri Khan
Subject: Re: nXML mode indentation
Date: Tue, 08 May 2018 04:55:35 +0000

On Tue, May 8, 2018 at 11:34 AM N. Raghavendra <nyraghu27132@gmail.com>
wrote:

> > I request help regarding indentation of text that is directly inside
> > elements in nXML mode.
> I am trying to follow the XML style guidelines of the FreeBSD
> Documentation Project,


https://www.freebsd.org/doc/en_US.ISO8859-1/books/fdp-primer/writing-style-guide.html#writing-style-indentation

> and I would indeed like to use nXML mode.

> It looks like `nxml-compute-indent-from-previous-line' in nxml-mode.el
> is relevant, but I can't see how to modify or advise it.

I have customized indentation in nXML for XHTML documents. The exact
indentation rules I use are not relevant to your case but here’s how I
activate it.

See the documentation on ‘indent-line-function’ and the source of
‘nxml-indent-line’ for implementation details.

(defun yk-xhtml-indent-line ()
   "Indent the current line suitably for XHTML."
   <my custom indentation rules>)

(defun yk-xhtml-indent--maybe-enable ()
   "Set the current buffer’s indentation function
to `yk-xhtml-indent-line' if the current schema is “html”."
   (pcase (caddr rng-current-schema)
     ("html" (setq-local indent-line-function 'yk-xhtml-indent-line))))

(with-eval-after-load 'nxml-mode
   (add-hook 'nxml-mode-hook 'yk-xhtml-indent--maybe-enable))



reply via email to

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