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

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

[nongnu] elpa/lua-mode 086736c 168/468: #36 Don't continue lines on some


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode 086736c 168/468: #36 Don't continue lines on some keywords
Date: Thu, 5 Aug 2021 04:58:29 -0400 (EDT)

branch: elpa/lua-mode
commit 086736c56c569d546c5ada8c1e21908b58446dff
Author: Vedat Hallac <vedathallac@gmail.com>
Commit: Vedat Hallac <vedathallac@gmail.com>

    #36 Don't continue lines on some keywords
    
    Certain keywords in lua ca never be part of a multi-line expression.
    Check for these keywords in lua-is continuing-statement-p.
---
 lua-mode.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lua-mode.el b/lua-mode.el
index 4f79e82..ee3975d 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -859,6 +859,21 @@ previous one even though it looked like an 
end-of-statement.")
       ;; the control inside this function
       (re-search-forward lua-cont-bol-regexp line-end t))))
 
+(defconst lua-block-starter-regexp
+  (eval-when-compile
+    (concat
+     "\\(\\_<"
+     (regexp-opt '("do" "while" "repeat" "until" "if" "then"
+                   "else" "elseif" "end" "for" "local") t)
+     "\\_>\\)")))
+
+(defun lua-first-token-starts-block-p ()
+  "Returns true if the first token on this line is a block starter token."
+  (let ((line-end (line-end-position)))
+    (save-excursion
+      (beginning-of-line)
+      (re-search-forward (concat "\\s *" lua-block-starter-regexp) line-end 
t))))
+
 (defun lua-is-continuing-statement-p (&optional parse-start)
   "Return non-nil if the line continues a statement.
 More specifically, return the point in the line that is continued.
@@ -873,6 +888,7 @@ The criteria for a continuing statement are:
       (if parse-start (goto-char parse-start))
       (save-excursion (setq prev-line (lua-forward-line-skip-blanks 'back)))
       (and prev-line
+           (not (lua-first-token-starts-block-p))
            (or (lua-first-token-continues-p)
                (and (goto-char prev-line)
                     ;; check last token of previous nonblank line



reply via email to

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