[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 63fbbf27bf 326/500: Improve indentation of closin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 63fbbf27bf 326/500: Improve indentation of closing parentheses. |
Date: |
Sat, 29 Jan 2022 08:27:18 -0500 (EST) |
branch: elpa/nix-mode
commit 63fbbf27bf2cecc6739a6503484871079b989a37
Author: Jakub Piecuch <j.piecuch96@gmail.com>
Commit: Jakub Piecuch <j.piecuch96@gmail.com>
Improve indentation of closing parentheses.
---
nix-mode.el | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index ba858594a0..792501ae95 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -574,6 +574,14 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(smie-backward-sexp)))
'("{" ",")))
+(defun nix-smie--eol-p ()
+ "Whether there are no tokens after point on the current line."
+ (let ((eol (line-end-position)))
+ (save-excursion
+ (forward-comment (point-max))
+ (or (eobp)
+ (< eol (point))))))
+
(defun nix-smie--indent-close ()
"Align close paren with opening paren."
(save-excursion
@@ -582,9 +590,13 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(condition-case nil
(progn
(backward-sexp 1)
- ;; Align to the first token on the line containing
- ;; the opening paren.
- (current-indentation))
+ ;; If the opening paren is not the last token on its line,
+ ;; and it's either '[' or '{', align to the opening paren's
+ ;; position. Otherwise, align its line's anchor.
+ (if (and (memq (char-after) '(?\[ ?{))
+ (not (save-excursion (forward-char) (nix-smie--eol-p))))
+ (current-column)
+ (nix-smie--anchor)))
(scan-error nil)))))
(defun nix-smie--indent-exps ()
- [nongnu] elpa/nix-mode 082a25ba7d 227/500: Add more default packages in nix.el, (continued)
- [nongnu] elpa/nix-mode 082a25ba7d 227/500: Add more default packages in nix.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b98c1083a0 234/500: nix-shell-file not risky, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 9fb4e16c9f 233/500: Setup global-nix-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 161e7ae4d2 237/500: Cleanup nix-instantiate, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c1b1982ea7 239/500: Fix nix-instantiate.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1b15a6e583 252/500: Merge pull request #46 from matthewbauer/develop, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1e53bed4d4 299/500: Move the logic for indentation of first line of file, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 79a3715c3d 303/500: Improve handling of 'in' after a hanging 'let'., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 6e4f66de1d 317/500: Add all-packages.nix test case, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode f938aeaeb6 324/500: Fix buggy implementation of nix-smie--anchor., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 63fbbf27bf 326/500: Improve indentation of closing parentheses.,
ELPA Syncer <=
- [nongnu] elpa/nix-mode b12aeada41 334/500: Don’t use smie-indent-line when nix-mode-use-smie is nil, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e5abdd41e4 352/500: add json-mode dependency, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ab49f46754 027/500: Redo keymap, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 81e8c3dea6 032/500: cleanup formatting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 09d40e95e2 037/500: Skip braces with hanging indents, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode f29d9865e4 055/500: Fixup hanging indents., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 55ed31214a 053/500: Add "in" for closing., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ec0546a41d 051/500: Tweak hanging indent, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0f94476b7e 117/500: nix-syntax-match-antiquote: Handle case where point has the property, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 183d4212e2 134/500: Fix fontification bug, ELPA Syncer, 2022/01/29