[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode 61f334c 149/192: Improves indentation
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode 61f334c 149/192: Improves indentation |
Date: |
Sun, 29 Aug 2021 11:02:07 -0400 (EDT) |
branch: elpa/dart-mode
commit 61f334c3eb5f9038566994decbf5a1457b570541
Author: Brady Trainor <mail@bradyt.com>
Commit: Brady Trainor <mail@bradyt.com>
Improves indentation
- Depth is now calculated relative to previous non-empty line, rather
than absolute depth.
- If first character after indentation is a closing paren, move
forward counting closing parens until an opening paren or newline.
This handles cases like `),};` or `} else {`.
---
dart-mode.el | 46 +++++++++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/dart-mode.el b/dart-mode.el
index 4297cdd..b8b0829 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -312,17 +312,45 @@ Returns nil if `dart-sdk-path' is nil."
;;; Indentation support
+(defun dart-depth-of-line ()
+ (save-excursion
+ (back-to-indentation)
+ (let ((depth (car (syntax-ppss))))
+ (when (and (char-after)
+ (= (char-syntax (char-after)) ?\)))
+ (while (and (char-after)
+ (/= (char-syntax (char-after)) ?\()
+ (/= (char-after) ?\C-j))
+ (when (= (char-syntax (char-after)) ?\))
+ (setq depth (1- depth)))
+ (forward-char)))
+ depth)))
+
(defun dart-indent-line-function ()
- (let (pt)
+ (let ((curr-depth (dart-depth-of-line))
+ prev-line
+ prev-depth
+ prev-indent)
(save-excursion
- (back-to-indentation)
- (let ((depth (car (syntax-ppss))))
- (if (= (char-syntax (char-after)) ?\))
- (setq depth (1- depth)))
- (indent-line-to (* depth tab-width)))
- (setq pt (point)))
- (when (< (point) pt)
- (back-to-indentation))))
+ (beginning-of-line)
+ (catch 'done
+ (while t
+ (when (= (point) 1)
+ (throw 'done t))
+ (previous-line)
+ (unless (looking-at (rx (and bol (zero-or-more space) eol)))
+ (setq prev-line t)
+ (setq prev-indent (current-indentation))
+ (setq prev-depth (dart-depth-of-line))
+ (throw 'done t)))))
+ (save-excursion
+ (if prev-line
+ (indent-line-to (max 0 (+ prev-indent
+ (* (- curr-depth prev-depth)
+ tab-width))))
+ (indent-line-to 0)))
+ (when (< (current-column) (current-indentation))
+ (back-to-indentation))))
;;; Additional fontification support
- [nongnu] elpa/dart-mode 9c9a63e 130/192: Fix dart-format, (continued)
- [nongnu] elpa/dart-mode 9c9a63e 130/192: Fix dart-format, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1f27d03 119/192: Properly set up font-lock variables, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 6397b3d 115/192: Clean up the way the SDK is configured, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode e9cd33d 109/192: Use proper private name convention, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode a087c75 099/192: Add a result counter in search results, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 847707d 129/192: Require final newline, like dartfmt, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 570e58c 116/192: Refactor formatter support, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d4da484 126/192: Removes nil c-syntactic-context (#56), ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 7c28c58 131/192: Add Travis-CI and Cask, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode adef2a5 118/192: Be more resilient to server crashes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 61f334c 149/192: Improves indentation,
ELPA Syncer <=
- [nongnu] elpa/dart-mode 47dc5a0 146/192: Fixes flycheck in Windows, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 6e1c42f 156/192: Fontify string interpolation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d78c5c7 142/192: Bump version to 1.0.4, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1031016 141/192: Edit README to melpa rather than marmalade, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d3d3d7e 188/192: Add indentation tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode e94acb5 168/192: Fontify SCREAMING_CAPS words of length greater than two as constant, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode c51e750 163/192: Stop testing 24.3 on travis, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 735868e 154/192: Copy/paste multiline string syntax-propertize from python.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9ad52e8 158/192: Search for sdk from flutter if no dart on path, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode c568118 175/192: Move dart server code to a separate repo, ELPA Syncer, 2021/08/29