Have `sgml-attribute-offset' control SGML attribute indentation

Fixes: debbugs:20161

* textmodes/sgml-mode.el (sgml-attribute-offset): New defcustom.
(sgml-calculate-indent): Use `sgml-attribute-offset' for attribute
indentation.
This commit is contained in:
Jackson Ray Hamilton 2015-03-22 08:22:29 -07:00
parent 70a8bbe443
commit f4c23f4583
3 changed files with 41 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2015-03-22 Jackson Ray Hamilton <jackson@jacksonrayhamilton.com>
* textmodes/sgml-mode.el (sgml-attribute-offset): New defcustom.
(sgml-calculate-indent): Use `sgml-attribute-offset' for attribute
indentation (bug#20161).
2015-03-22 Dmitry Gutov <dgutov@yandex.ru>
* json.el (json-decode-char0): Delete this alias.

View file

@ -46,6 +46,25 @@
:type 'integer
:group 'sgml)
(defcustom sgml-attribute-offset 0
"Specifies a delta for attribute indentation in `sgml-indent-line'.
When 0, attribute indentation looks like this:
<element
attribute=\"value\">
</element>
When 2, attribute indentation looks like this:
<element
attribute=\"value\">
</element>"
:version "25.1"
:type 'integer
:safe 'integerp
:group 'sgml)
(defcustom sgml-xml-mode nil
"When non-nil, tag insertion functions will be XML-compliant.
It is set to be buffer-local when the file has
@ -1510,13 +1529,13 @@ LCON is the lexical context, if any."
(`pi nil)
(`tag
(goto-char (1+ (cdr lcon)))
(goto-char (+ (cdr lcon) sgml-attribute-offset))
(skip-chars-forward "^ \t\n") ;Skip tag name.
(skip-chars-forward " \t")
(if (not (eolp))
(current-column)
;; This is the first attribute: indent.
(goto-char (1+ (cdr lcon)))
(goto-char (+ (cdr lcon) sgml-attribute-offset))
(+ (current-column) sgml-basic-offset)))
(`text

View file

@ -0,0 +1,14 @@
<element attribute="value"></element>
<element
attribute="value">
<element
attribute="value">
</element>
</element>
<!--
Local Variables:
sgml-attribute-offset: 2
End:
-->