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

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

[nongnu] elpa/lua-mode e498788 142/468: lua-calculate-indentation: add c


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode e498788 142/468: lua-calculate-indentation: add comments
Date: Thu, 5 Aug 2021 04:58:24 -0400 (EDT)

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

    lua-calculate-indentation: add comments
---
 lua-mode.el | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lua-mode.el b/lua-mode.el
index 2e2cbc1..540bd2b 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -985,8 +985,16 @@ to the left by the amount specified in lua-indent-level."
         (indent-amt 0))
     (save-excursion
       (let ((continuing-p (lua-is-continuing-statement-p)))
-        (or (lua-calculate-indentation-override)
-            (when (lua-forward-line-skip-blanks 'back)
+        (or
+         ;; when calculating indentation, do the following:
+         ;; 1. check, if the line starts with indentation-modifier (open/close 
brace)
+         ;;    and if it should be indented/unindented in special way
+         (lua-calculate-indentation-override)
+
+         ;; 2. otherwise, use indentation modifiers from previous line + it's 
own indentation
+         ;; 3. if previous line doesn't contain indentation modifiers, 
additionally check
+         ;;    if current line is a continuation line and add lua-indent-level 
if it is
+         (when (lua-forward-line-skip-blanks 'back)
               ;; the order of function calls here is important. block modifier
               ;; call may change the point to another line
               (let ((modifier
@@ -995,7 +1003,9 @@ to the left by the amount specified in lua-indent-level."
                        lua-indent-level
                      modifier)
                    (current-indentation))))
-            0)))))
+
+         ;; 4. if there's no previous line, indentation is 0
+         0)))))
 
 (defun lua-beginning-of-proc (&optional arg)
   "Move backward to the beginning of a lua proc (or similar).



reply via email to

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