From c4ab20eb5a0454438d96635b1c12f7b299e10579 Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Sun, 22 Mar 2015 08:22:29 -0700 Subject: [PATCH] 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. --- lisp/ChangeLog | 6 ++++++ lisp/textmodes/sgml-mode.el | 23 +++++++++++++++++++++-- test/indent/sgml-mode-attribute.html | 14 ++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 test/indent/sgml-mode-attribute.html diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2f9c430..ba95401 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2015-03-22 Jackson Ray Hamilton + + * textmodes/sgml-mode.el (sgml-attribute-offset): New defcustom. + (sgml-calculate-indent): Use `sgml-attribute-offset' for attribute + indentation. + 2015-03-21 Titus von der Malsburg * window.el (window-font-width, window-font-height) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 12d98c8..8266647 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -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: + + + + +When 2, attribute indentation looks like this: + + + " + :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 diff --git a/test/indent/sgml-mode-attribute.html b/test/indent/sgml-mode-attribute.html new file mode 100644 index 0000000..4cbec0a --- /dev/null +++ b/test/indent/sgml-mode-attribute.html @@ -0,0 +1,14 @@ + + + + + + + + -- 1.9.1