emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/lua-mode bbab5a6 253/468: Don't anchor arglist continuatio


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode bbab5a6 253/468: Don't anchor arglist continuation to block openers
Date: Thu, 5 Aug 2021 04:58:48 -0400 (EDT)

branch: elpa/lua-mode
commit bbab5a683ef195f6d4a004317a4c5bf21d498921
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>

    Don't anchor arglist continuation to block openers
    
    E.g.:
    
        somefunc({
                 ^
                 don't align next line to this brace
---
 lua-mode.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lua-mode.el b/lua-mode.el
index 4c09e3d..487c4cc 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1210,13 +1210,15 @@ use standalone."
 
    ;; block openers
    ((member found-token (list "{" "(" "["))
-        (save-excursion
-          ;; expression follows -> indent at start of next expression
-       ;; Last token on the line -> simple relative indent
-          (if (and (not (search-forward-regexp "[[:space:]]--" 
(line-end-position) t))
-                (search-forward-regexp "[^[:space:]]" (line-end-position) t))
-           (cons 'absolute (1- (current-column)))
-         (cons 'relative lua-indent-level))))
+    (save-excursion
+      (let ((found-bol (line-beginning-position)))
+        (forward-comment (point-max))
+        ;; If the next token is on this line and it's not a block opener,
+        ;; the next line should align to that token.
+        (if (and (zerop (count-lines found-bol (line-beginning-position)))
+                 (not (looking-at lua-indentation-modifier-regexp)))
+            (cons 'absolute (current-column))
+          (cons 'relative lua-indent-level)))))
 
    ;; These are not really block starters. They should not add to indentation.
    ;; The corresponding "then" and "do" handle the indentation.



reply via email to

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