branch: elpa/lua-mode
commit 6b48a94bb46722c916032d30212e7a8581a007f2
Author: Vedat Hallac <[email protected]>
Commit: Vedat Hallac <[email protected]>
Second part of the fix for #34
Indent closing lines of multi-line comments according to opening line.
---
lua-mode.el | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 277f955..bc95549 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -578,10 +578,21 @@ Return the amount the indentation changed by."
(if (and (lua-string-p) (not lua-indent-string-contents))
;; if inside string and strings aren't to be indented, return current
indentation
(current-indentation)
- ;; otherwise indent by lua-indent-level relative to the line where literal
starts
+ ;; Otherwise, indent as a comment
(save-excursion
- (goto-char (lua-get-multiline-start))
- (+ (current-indentation) lua-indent-level))))
+ (cond
+ ;; If it is the end of a multi-line comment, simply mirror the opening
+ ;; line's indent.
+ ((looking-at "\\s *\\(?:--\\)?\\]\\(?1:=*\\)\\]")
+ (re-search-backward (format "\\[%s\\["
+ (or (match-string-no-properties 1) ""))
+ (lua-get-multiline-start)
+ 'noerror)
+ (current-indentation))
+ ;; otherwise indent by lua-indent-level relative to the line where
literal starts
+ (t
+ (goto-char (lua-get-multiline-start)))
+ (+ (current-indentation) lua-indent-level)))))
(defun lua-find-regexp (direction regexp &optional limit ignore-p)
"Searches for a regular expression in the direction specified.