[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode c9f5e92 483/495: Fix indentation of chained dangli
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode c9f5e92 483/495: Fix indentation of chained dangling selectors. |
Date: |
Sat, 7 Aug 2021 09:06:14 -0400 (EDT) |
branch: elpa/go-mode
commit c9f5e9289529eefdaa5c6e987e0e7e923777a2ae
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>
Fix indentation of chained dangling selectors.
foo.
bar.
baz
Now indents properly as
foo.
bar.
baz
Fix by treating period as an operator so it is taken into account by
go--continuation-line-indents-p. Period isn't technically a Go
operator, but it can be a dangling operator as far as go-mode is
concerned.
Fixes #346.
Closes: #347 [via git-merge-pr]
---
go-mode.el | 13 ++++++++-----
test/testdata/indentation_tests/dangling_operator.go | 5 +++++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index e0ba615..b4d6d12 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -994,23 +994,26 @@ is done."
indent
(+ indent (current-indentation))))))
-(defconst go--operator-chars "*/%<>&\\^+\\-|=!,"
+(defconst go--operator-chars "*/%<>&\\^+\\-|=!,."
"Individual characters that appear in operators.
-Comma is included because it is sometimes a dangling operator, so
-needs to be considered by `go--continuation-line-indents-p'")
+Comma and period are included because they can be dangling operators, so
+they need to be considered by `go--continuation-line-indents-p'")
(defun go--operator-precedence (op)
"Go operator precedence (higher binds tighter).
-Comma gets the default 0 precedence which is appropriate because commas
-are loose binding expression separators."
+Comma and period are present because they can be dangling
+operators that affect indentation, although they aren't
+technically operators."
(cl-case (intern op)
+ (\. 7) ; "." in "foo.bar", binds tightest
(! 6)
((* / % << >> & &^) 5)
((+ - | ^) 4)
((== != < <= > >=) 3)
(&& 2)
(|| 1)
+ (, 0) ; loose binding expression separator
(t 0)))
(defun go--flow-block-p ()
diff --git a/test/testdata/indentation_tests/dangling_operator.go
b/test/testdata/indentation_tests/dangling_operator.go
index a1749c7..549a301 100644
--- a/test/testdata/indentation_tests/dangling_operator.go
+++ b/test/testdata/indentation_tests/dangling_operator.go
@@ -284,6 +284,11 @@ lol` +
},
}
+ foo.
+ bar.
+ baz.
+ qux
+
return 123,
456
}
- [nongnu] elpa/go-mode 7248358 462/495: Fontify type names in type switch statements, (continued)
- [nongnu] elpa/go-mode 7248358 462/495: Fontify type names in type switch statements, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4fabba6 464/495: Small fix for fontification of array types, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 656590a 463/495: Fontify qualified composite literal types., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d304565 474/495: Fix signature fontification after comments., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e9b9c0e 473/495: Add some fontification faces for go-dot-mod-mode., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4acf733 468/495: Fully fontify type and const decls., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode dac200f 469/495: Fix font locking in nested signatures., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode fa2162b 475/495: Fix "nil" fontification in type switch clause., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7ce031c 481/495: Allow disabling variable font locking., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e10d677 478/495: indent: fix func literals in dangling lines, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c9f5e92 483/495: Fix indentation of chained dangling selectors.,
ELPA Syncer <=
- [nongnu] elpa/go-mode fdf46fe 492/495: Fix go.mod fontification., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e8eea7f 487/495: Fix fontification of multiline type switch clauses., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2f2910c 223/495: fix end-of-defun for function with inline struct/interface arguments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f1adac0 230/495: switch versioning to semver, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d9f0bee 232/495: add variable to customize godef command, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3da268f 285/495: README: improve description of new functions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9047fcd 238/495: add a menu, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 466e188 239/495: add `go-play-browse-function', ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8c13a82 240/495: match identifiers, not type names, when highlighting struct literal, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 775c77a 241/495: immediately store match data in go-unused-imports-lines, ELPA Syncer, 2021/08/07