aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJackson Ray Hamilton2015-03-22 08:22:29 -0700
committerJackson Ray Hamilton2015-03-22 20:47:43 -0700
commitf4c23f458367769ba9a701792fa5720e58827fb4 (patch)
tree6fe5febe6ecdc5edf8cef3af006e9af08d7079dd
parent70a8bbe4437abe9166ba5522437c70791869fc95 (diff)
downloademacs-f4c23f458367769ba9a701792fa5720e58827fb4.tar.gz
emacs-f4c23f458367769ba9a701792fa5720e58827fb4.zip
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.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/textmodes/sgml-mode.el23
-rw-r--r--test/indent/sgml-mode-attribute.html14
3 files changed, 41 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2fc318a3b89..1b8a4d3ce12 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12015-03-22 Jackson Ray Hamilton <jackson@jacksonrayhamilton.com>
2
3 * textmodes/sgml-mode.el (sgml-attribute-offset): New defcustom.
4 (sgml-calculate-indent): Use `sgml-attribute-offset' for attribute
5 indentation (bug#20161).
6
12015-03-22 Dmitry Gutov <dgutov@yandex.ru> 72015-03-22 Dmitry Gutov <dgutov@yandex.ru>
2 8
3 * json.el (json-decode-char0): Delete this alias. 9 * json.el (json-decode-char0): Delete this alias.
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 12d98c8238a..82666478d59 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -46,6 +46,25 @@
46 :type 'integer 46 :type 'integer
47 :group 'sgml) 47 :group 'sgml)
48 48
49(defcustom sgml-attribute-offset 0
50 "Specifies a delta for attribute indentation in `sgml-indent-line'.
51
52When 0, attribute indentation looks like this:
53
54 <element
55 attribute=\"value\">
56 </element>
57
58When 2, attribute indentation looks like this:
59
60 <element
61 attribute=\"value\">
62 </element>"
63 :version "25.1"
64 :type 'integer
65 :safe 'integerp
66 :group 'sgml)
67
49(defcustom sgml-xml-mode nil 68(defcustom sgml-xml-mode nil
50 "When non-nil, tag insertion functions will be XML-compliant. 69 "When non-nil, tag insertion functions will be XML-compliant.
51It is set to be buffer-local when the file has 70It is set to be buffer-local when the file has
@@ -1510,13 +1529,13 @@ LCON is the lexical context, if any."
1510 (`pi nil) 1529 (`pi nil)
1511 1530
1512 (`tag 1531 (`tag
1513 (goto-char (1+ (cdr lcon))) 1532 (goto-char (+ (cdr lcon) sgml-attribute-offset))
1514 (skip-chars-forward "^ \t\n") ;Skip tag name. 1533 (skip-chars-forward "^ \t\n") ;Skip tag name.
1515 (skip-chars-forward " \t") 1534 (skip-chars-forward " \t")
1516 (if (not (eolp)) 1535 (if (not (eolp))
1517 (current-column) 1536 (current-column)
1518 ;; This is the first attribute: indent. 1537 ;; This is the first attribute: indent.
1519 (goto-char (1+ (cdr lcon))) 1538 (goto-char (+ (cdr lcon) sgml-attribute-offset))
1520 (+ (current-column) sgml-basic-offset))) 1539 (+ (current-column) sgml-basic-offset)))
1521 1540
1522 (`text 1541 (`text
diff --git a/test/indent/sgml-mode-attribute.html b/test/indent/sgml-mode-attribute.html
new file mode 100644
index 00000000000..4cbec0af2c6
--- /dev/null
+++ b/test/indent/sgml-mode-attribute.html
@@ -0,0 +1,14 @@
1<element attribute="value"></element>
2
3<element
4 attribute="value">
5 <element
6 attribute="value">
7 </element>
8</element>
9
10<!--
11 Local Variables:
12 sgml-attribute-offset: 2
13 End:
14 -->