]> git.eshelyaron.com Git - emacs.git/commitdiff
Have `sgml-attribute-offset' control SGML attribute indentation
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 22 Mar 2015 15:22:29 +0000 (08:22 -0700)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Mon, 23 Mar 2015 03:47:43 +0000 (20:47 -0700)
Fixes: debbugs:20161
* textmodes/sgml-mode.el (sgml-attribute-offset): New defcustom.
(sgml-calculate-indent): Use `sgml-attribute-offset' for attribute
indentation.

lisp/ChangeLog
lisp/textmodes/sgml-mode.el
test/indent/sgml-mode-attribute.html [new file with mode: 0644]

index 2fc318a3b89b9d73b563fe7d1b17760bd10c383b..1b8a4d3ce12b3f8569a9136c313ab887357bf479 100644 (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.
index 12d98c8238a0ae09abf8b001041c411b0e06cd90..82666478d5963b39d7a4e85e26a49d88a0366f09 100644 (file)
   :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
diff --git a/test/indent/sgml-mode-attribute.html b/test/indent/sgml-mode-attribute.html
new file mode 100644 (file)
index 0000000..4cbec0a
--- /dev/null
@@ -0,0 +1,14 @@
+<element attribute="value"></element>
+
+<element
+    attribute="value">
+  <element
+      attribute="value">
+  </element>
+</element>
+
+<!--
+    Local Variables:
+    sgml-attribute-offset: 2
+    End:
+  -->