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

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

[nongnu] elpa/lua-mode e610db4 060/468: lua-make-indentation-info-pair:


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode e610db4 060/468: lua-make-indentation-info-pair: readability refactoring
Date: Thu, 5 Aug 2021 04:58:08 -0400 (EDT)

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

    lua-make-indentation-info-pair: readability refactoring
---
 lua-mode.el | 83 ++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 44 insertions(+), 39 deletions(-)

diff --git a/lua-mode.el b/lua-mode.el
index f4d372a..0e0c9fc 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -619,45 +619,50 @@ The criteria for a continuing statement are:
 (defun lua-make-indentation-info-pair ()
   "This is a helper function to lua-calculate-indentation-info. Don't
 use standalone."
-  (cond ((string-equal found-token "function")
-         ;; this is the location where we need to start searching for the
-         ;; matching opening token, when we encounter the next closing token.
-         ;; It is primarily an optimization to save some searching time.
-         (cons 'absolute (+ (save-excursion (goto-char found-pos)
-                                            (current-column))
-                            lua-indent-level)))
-        ((or (string-equal found-token "{")
-             (string-equal found-token "("))
-         (save-excursion
-           ;; expression follows -> indent at start of next expression
-           (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))))
-        ;; closing tokens follow
-        ((string-equal found-token "end")
-         (save-excursion
-           (lua-goto-matching-block-token nil found-pos)
-           (if (looking-at "\\_<function\\_>")
-               (cons 'absolute
-                     (+ (current-indentation)
-                        (lua-calculate-indentation-block-modifier
-                         nil (point))))
-             (cons 'relative (- lua-indent-level)))))
-        ((or (string-equal found-token ")")
-             (string-equal found-token "}"))
-         (save-excursion
-           (lua-goto-matching-block-token nil found-pos)
-           (cons 'absolute
-                 (+ (current-indentation)
-                    (lua-calculate-indentation-block-modifier
-                     nil (point))))))
-        (t
-         (cons 'relative (if (nth 2 (match-data))
-                             ;; beginning of a block matched
-                             lua-indent-level
-                           ;; end of a block matched
-                           (- lua-indent-level))))))
+  (cond
+   ((string-equal found-token "function")
+    ;; this is the location where we need to start searching for the
+    ;; matching opening token, when we encounter the next closing token.
+    ;; It is primarily an optimization to save some searching time.
+    (cons 'absolute (+ (save-excursion (goto-char found-pos)
+                                       (current-column))
+                       lua-indent-level)))
+
+   ((or (string-equal found-token "{")
+        (string-equal found-token "("))
+    (save-excursion
+      ;; expression follows -> indent at start of next expression
+      (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))))
+
+   ;; closing tokens follow
+   ((string-equal found-token "end")
+    (save-excursion
+      (lua-goto-matching-block-token nil found-pos)
+      (if (looking-at "\\_<function\\_>")
+          (cons 'absolute
+                (+ (current-indentation)
+                   (lua-calculate-indentation-block-modifier
+                    nil (point))))
+        (cons 'relative (- lua-indent-level)))))
+
+   ((or (string-equal found-token ")")
+        (string-equal found-token "}"))
+    (save-excursion
+      (lua-goto-matching-block-token nil found-pos)
+      (cons 'absolute
+            (+ (current-indentation)
+               (lua-calculate-indentation-block-modifier
+                nil (point))))))
+
+   ('other-indentation-modifier
+    (cons 'relative (if (nth 2 (match-data))
+                        ;; beginning of a block matched
+                        lua-indent-level
+                      ;; end of a block matched
+                      (- lua-indent-level))))))
 
 
 (defun lua-calculate-indentation-info (&optional parse-start parse-end)



reply via email to

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