[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode d6dc6fb 406/468: Don't add "continuation line" in
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode d6dc6fb 406/468: Don't add "continuation line" indentation inside parentheses/brackets |
Date: |
Thu, 5 Aug 2021 04:59:18 -0400 (EDT) |
branch: elpa/lua-mode
commit d6dc6fbb9c64ba8e0b1bf6cdb47de28dc77fe465
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Don't add "continuation line" indentation inside parentheses/brackets
Continuation lines are required in
x = foo_bar() +
baz_qux()
to clarify that the statement continues after the end of line implicitly. In
the case when the expression is parenthesized
x = (foo_bar() +
baz_qux())
It is not necessary, because parentheses show the boundaries explicitly.
---
lua-mode.el | 14 +++++---
test/indentation-tests/continuation-lines.lua | 49 +++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index e275cdb..e659aae 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1328,17 +1328,21 @@ The criteria for a continuing statement are:
* the last token of the previous line is a continuing op,
OR the first token of the current line is a continuing op
-"
+* the expression is not enclosed by a parenthesis"
(let ((prev-line nil))
(save-excursion
(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
- (lua-last-token-continues-p)))))))
+ (and (or (lua-first-token-continues-p)
+ (save-excursion (and (goto-char prev-line)
+ ;; check last token of previous
nonblank line
+ (lua-last-token-continues-p))))
+ (not (member (car-safe (condition-case nil
(lua-backward-up-list)
+ (scan-error nil)))
+ ;; XXX: can we also add "{" here?
+ '("(" "["))))))))
(defun lua-make-indentation-info-pair (found-token found-pos)
"Create a pair from FOUND-TOKEN and FOUND-POS for indentation calculation.
diff --git a/test/indentation-tests/continuation-lines.lua
b/test/indentation-tests/continuation-lines.lua
index e329d36..66e26a0 100644
--- a/test/indentation-tests/continuation-lines.lua
+++ b/test/indentation-tests/continuation-lines.lua
@@ -86,7 +86,56 @@ x = foo(123,
qux,
quux)
+-- does not indent binary operators inside parentheses: alignment 1
+
+x = (very_very_very_long_name() +
+ another_very_very_very_long_name())
+
+-- does not indent binary operators inside parentheses: alignment 2
+
+x = (very_very_very_long_name()
+ + another_very_very_very_long_name())
+
+-- does not indent binary operators inside parentheses: indentation 1
+
+x = (
+ very_very_very_long_name() +
+ another_very_very_very_long_name()
+ )
+
+-- does not indent binary operators inside parentheses: indentation 2
+
+x = (
+ very_very_very_long_name()
+ + another_very_very_very_long_name()
+ )
+
+-- does not indent binary operators inside brackets: alignment 1
+
+x = t[very_very_very_long_name() +
+ another_very_very_very_long_name()]
+
+-- does not indent binary operators inside brackets: alignment 2
+
+x = t[very_very_very_long_name()
+ + another_very_very_very_long_name()]
+
+-- does not indent binary operators inside brackets: indentation 1
+
+x = [
+ very_very_very_long_name() +
+ another_very_very_very_long_name()
+ ]
+
+-- does not indent binary operators inside brackets: indentation 2
+
+x = [
+ very_very_very_long_name()
+ + another_very_very_very_long_name()
+ ]
+
-- XFAIL: indentation in block-intros: while
+
while
foo do
a = a + 1
- [nongnu] elpa/lua-mode aee46da 367/468: added lua-indent-nested-block-content-align var, (continued)
- [nongnu] elpa/lua-mode aee46da 367/468: added lua-indent-nested-block-content-align var, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8503e16 370/468: travis: specify language=minimal explicitly, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c7c3aaa 377/468: Set comint-prompt-regexp locally in process buffer, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 52cc3e4 378/468: Merge pull request #154 from immerrr/set-comint-prompt-regexp-locally-in-process-buf, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0f7f010 383/468: Fix typo, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 505896f 386/468: added tests for lua-indent-nested-block-content-align and lua-indent-close-paren-align, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0cf8000 387/468: add lua-indent-close-paren-align to README.md, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 2a8b58b 390/468: Silence byte-compiler, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1f596a9 392/468: Merge pull request #161 from tarsiiformes/lexical, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0781d83 404/468: Merge pull request #175 from immerrr/add-lua-backward-up-list-command, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d6dc6fb 406/468: Don't add "continuation line" indentation inside parentheses/brackets,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode ed01d35 071/468: Implement proper syntax-status querying: improve precision a lot, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0a1e915 262/468: bug fixes for show/hide process buffer, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6315591 265/468: indentation-test: extend unary op test cases, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6c4f7cb 251/468: lua-default-command-switches: declare buffer-local with make-variable-buffer-local, not make-local-variable, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9117cfc 269/468: Makefile: add tryout target to start editing test.lua, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 2453e37 272/468: Makefile: account EMACS env variable in 'tryout' target, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3e8d475 275/468: Fixed broken local variable assignments, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1d804f6 279/468: Drop pre-Emacs23 support macros, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d6f7e0b 287/468: lua-documentation-function: New custom variable., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode f2e5c4b 299/468: Merge pull request #90 from Schnouki/lua53, Philip Kaludercic, 2021/08/05