[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode 2d00ec4 043/192: Properly indent multiline optio
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode 2d00ec4 043/192: Properly indent multiline optional parameter lists. |
Date: |
Sun, 29 Aug 2021 11:01:47 -0400 (EDT) |
branch: elpa/dart-mode
commit 2d00ec46053b90fe1df8992f8a70c43ae5350813
Author: Nathan Weizenbaum <nweiz@google.com>
Commit: Nathan Weizenbaum <nweiz@google.com>
Properly indent multiline optional parameter lists.
---
dart-mode.el | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/dart-mode.el b/dart-mode.el
index a7c7404..88f4136 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -194,6 +194,9 @@
(c-lang-defconst c-opt-postfix-decl-spec-kwds
dart '("native"))
+(push '(dart-brace-list-cont-nonempty . 0)
+ (get 'c-offsets-alist 'c-stylevar-fallback))
+
(defconst dart-c-style
'("java"
(c-basic-offset . 2)
@@ -202,7 +205,9 @@
(c-offsets-alist . ((arglist-intro . +)
(arglist-cont-nonempty . ++)
(statement-block-intro . dart-block-offset)
- (block-close . dart-block-offset))))
+ (block-close . dart-block-offset)
+ (dart-brace-list-cont-nonempty .
+ dart-brace-list-cont-nonempty-offset))))
"The default Dart styles.")
(c-add-style "dart" dart-c-style)
@@ -227,6 +232,20 @@ functions taking them as parameters essentially don't
exist."
(if (eq syntax 'block-close) c-basic-offset 0))
(if (eq syntax 'block-close) 0 '+)))))
+(defun dart-brace-list-cont-nonempty-offset (info)
+ "Indent a brace-list line in the same style as arglist-cont-nonempty.
+This could be either an actual brace-list or an optional parameter."
+ (destructuring-bind (syntax . anchor) info
+ ;; If we're in a function definition with optional arguments, indent as if
+ ;; the brace wasn't there. Currently this misses the in-function function
+ ;; definition, but that's probably acceptable.
+ (if (assq 'topmost-intro
+ (save-excursion (goto-char anchor) (c-guess-basic-syntax)))
+ '++
+ ;; Otherwise, we're in an actual brace list, in which case only indent
+ ;; once.
+ '+)))
+
(defun dart-in-block-p (syntax-guess)
"Return whether or not the immediately enclosing {} block is a code block.
The other option, of course, is a map literal.
@@ -286,10 +305,11 @@ SYNTAX-GUESS is the output of `c-guess-basic-syntax'."
(setq ad-return-value
`((,(case type
(arglist-intro 'brace-list-intro)
- ((arglist-cont arglist-cont-nonempty)
'brace-list-entry)
+ (arglist-cont 'brace-list-entry)
+ (arglist-cont-nonempty
'dart-brace-list-cont-nonempty)
(arglist-close 'brace-list-close))
- ,(cadr syntax))))
- t))))
+ ,(cadr syntax)))))
+ t)))
;; Handle map literal indentation
(when (and (memq type '(label statement-block-intro statement-cont
statement
- [nongnu] elpa/dart-mode ed80bc8 002/192: Set a bunch of CC-mode configuration vars., (continued)
- [nongnu] elpa/dart-mode ed80bc8 002/192: Set a bunch of CC-mode configuration vars., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 64eb399 003/192: Fix array literal indentation., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 91cc86c 005/192: Make "var" a typeless decl keyword., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 8098454 006/192: Initialize the syntax table., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 4e56274 013/192: Version 0.2., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 7e45699 018/192: Fix the Version header., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 2a66d38 020/192: Add more known bugs., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 51b9915 023/192: Fix optional argument fontification., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode f5097c0 027/192: Add a dart-mode-map., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 4232d23 041/192: Actually set the style when initializing the mode., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 2d00ec4 043/192: Properly indent multiline optional parameter lists.,
ELPA Syncer <=
- [nongnu] elpa/dart-mode b1ba925 045/192: arglist-intro should be ++., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode f16c1c1 047/192: Fix an odd indentation bug., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 147f554 063/192: Merge pull request #11 from hterkelsen/dartanalyzer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 89573d5 067/192: Use a pipe instead of a pty for the analysis server, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 35a794c 086/192: Add workaround for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=18845 (#40), ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9b11e8f 088/192: Another attempt at fixing byte compilation. (#42), ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 3a73a1f 090/192: Make dart-executable-path resilient to wrappers, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode b4e592f 098/192: Add more search commands, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode c172f19 106/192: Support completing multiple parameters, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 2b085f5 125/192: Do not fail if Flycheck is not available. (#52), ELPA Syncer, 2021/08/29