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

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

[nongnu] elpa/dart-mode f50a1cc 037/192: Properly indent after construct


From: ELPA Syncer
Subject: [nongnu] elpa/dart-mode f50a1cc 037/192: Properly indent after constructors with member lists.
Date: Sun, 29 Aug 2021 11:01:46 -0400 (EDT)

branch: elpa/dart-mode
commit f50a1ccb5fd90cc2e545af444b954e514aab92ef
Author: Nathan Weizenbaum <nweiz@google.com>
Commit: Nathan Weizenbaum <nweiz@google.com>

    Properly indent after constructors with member lists.
---
 dart-mode.el | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/dart-mode.el b/dart-mode.el
index f03e048..19c4cfa 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -36,7 +36,6 @@
 ;; * String interpolation isn't fontified as Dart.
 ;; * Methods and constructors without return types aren't fontified correctly.
 ;; * Untyped parameters aren't fontified correctly.
-;; * Member initializers tend to screw with indentation.
 
 ;;; Code:
 
@@ -152,6 +151,9 @@
 (c-lang-defconst c-before-label-kwds
   dart '("break" "continue"))
 
+(c-lang-defconst c-nonlabel-token-key
+  dart (concat (concat "\\s\(\\|" (c-lang-const c-nonlabel-token-key))))
+
 (c-lang-defconst c-inexpr-class-kwds
   dart nil)
 
@@ -306,8 +308,23 @@ SYNTAX-GUESS is the output of `c-guess-basic-syntax'."
   ;; out brace-list detection in our advice, we just never report being in a
   ;; bracelist there.
   (when (c-major-mode-is 'dart-mode)
-    (setq ad-return-value nil))
-  )
+    (setq ad-return-value nil)))
+
+(defadvice c-search-decl-header-end (around dart-search-decl-header-end 
activate)
+  (if (not (c-major-mode-is 'dart-mode))
+      (ad-do-it)
+    (let ((base (point)))
+      (while (and
+              (c-syntactic-re-search-forward "[;{=:]" nil 'move t t)
+              (c-end-of-current-token base))
+        (setq base (point)))
+      ;; If we hit :, we're in a member initialization list and we want to
+      ;; ignore = signs.
+      (when (= (char-before) ?:)
+        (while (and
+                (c-syntactic-re-search-forward "[;{]" nil 'move t t)
+                (c-end-of-current-token base))
+        (setq base (point)))))))
 
 
 ;;; Boilerplate font-lock piping



reply via email to

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