emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master f4c23f4: Have `sgml-attribute-offset' control SGML


From: Jackson Ray Hamilton
Subject: [Emacs-diffs] master f4c23f4: Have `sgml-attribute-offset' control SGML attribute indentation
Date: Mon, 23 Mar 2015 03:49:12 +0000

branch: master
commit f4c23f458367769ba9a701792fa5720e58827fb4
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

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

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2fc318a..1b8a4d3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-22  Jackson Ray Hamilton  <address@hidden>
+
+       * 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  <address@hidden>
 
        * json.el (json-decode-char0): Delete this alias.
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:
+
+  <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
index 0000000..4cbec0a
--- /dev/null
+++ b/test/indent/sgml-mode-attribute.html
@@ -0,0 +1,14 @@
+<element attribute="value"></element>
+
+<element
+    attribute="value">
+  <element
+      attribute="value">
+  </element>
+</element>
+
+<!--
+    Local Variables:
+    sgml-attribute-offset: 2
+    End:
+  -->



reply via email to

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