branch: elpa/lua-mode
commit 52dcf7b09f2f6322fc42f97a72b7c213bd43a461
Merge: bba7fc0 612b1e7
Author: immerrr <[email protected]>
Commit: immerrr <[email protected]>
Merge pull request #35 from vhallac/fix-34
Merge in fix in comment indentation logic (#34)
---
lua-mode.el | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 267277e..4f79e82 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.
@@ -779,7 +790,8 @@ Returns final value of point as integer or nil if operation
failed."
(while t
(unless (eql (forward-line (if back -1 1)) 0) ;; 0 means success
(throw 'found nil))
- (unless (looking-at "\\s *\\(--.*\\)?$") ;; blank lua line
+ (unless (or (looking-at "\\s *\\(--.*\\)?$")
+ (lua-comment-or-string-p))
(throw 'found (point))))))
(eval-when-compile