branch: elpa/jinja2-mode
commit 487b95f0d45b3def632c6114c95264f4111e4dd0
Merge: c262cace36 83eaa513b5
Author: Mounier Florian <[email protected]>
Commit: Mounier Florian <[email protected]>
Merge pull request #1 from amirouche/master
configurable indentation & jinja2-mode.el filename
---
jinja2.el => jinja2-mode.el | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/jinja2.el b/jinja2-mode.el
similarity index 92%
rename from jinja2.el
rename to jinja2-mode.el
index 9aabd26d88..dc1ca54a0a 100644
--- a/jinja2.el
+++ b/jinja2-mode.el
@@ -228,24 +228,25 @@
(defun jinja2-calculate-indent-backward (default)
"Return indent column based on previous lines"
(forward-line -1)
- (if (looking-at "^[ \t]*{% *end") ; Don't indent after end
- (current-indentation)
- (if (looking-at (concat "^[ \t]*{% *.*?{% *end" (regexp-opt
(jinja2-indenting-keywords))))
+ (let ((indent-width sgml-basic-offset) (default (sgml-indent-line-num)))
+ (if (looking-at "^[ \t]*{% *end") ; Don't indent after end
(current-indentation)
- (if (looking-at (concat "^[ \t]*{% *" (regexp-opt
(jinja2-indenting-keywords)))) ; Check start tag
- (+ (current-indentation) indent-width)
- (if (looking-at "^[ \t]*<") ; Assume sgml block trust sgml
- default
- (if (bobp)
- 0
- (jinja2-calculate-indent-backward default)))))))
-
+ (if (looking-at (concat "^[ \t]*{% *.*?{% *end" (regexp-opt
(jinja2-indenting-keywords))))
+ (current-indentation)
+ (if (looking-at (concat "^[ \t]*{% *" (regexp-opt
(jinja2-indenting-keywords)))) ; Check start tag
+ (+ (current-indentation) indent-width)
+ (if (looking-at "^[ \t]*<") ; Assume sgml block trust sgml
+ default
+ (if (bobp)
+ 0
+ (jinja2-calculate-indent-backward default))))))))
+
(defun jinja2-calculate-indent ()
"Return indent column"
(if (bobp) ; Check begining of buffer
0
- (let ((indent-width 2) (default (sgml-indent-line-num)))
+ (let ((indent-width sgml-basic-offset) (default (sgml-indent-line-num)))
(if (looking-at "^[ \t]*{% *e\\(nd\\|lse\\|lif\\)") ; Check close tag
(save-excursion
(forward-line -1)