[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 7f968e8a7f 284/500: Merge pull request #61 from e
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 7f968e8a7f 284/500: Merge pull request #61 from etu/master |
Date: |
Sat, 29 Jan 2022 08:27:14 -0500 (EST) |
branch: elpa/nix-mode
commit 7f968e8a7f955fb8f3aec7b00129cac3b3b5986f
Merge: 1512d02830 98426b94e5
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #61 from etu/master
Add function to indent things in blocks for nix-indent-line
---
nix-mode.el | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/nix-mode.el b/nix-mode.el
index d4bf6fc486..05ba967388 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -380,6 +380,39 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(current-indentation)))))
(when matching-indentation (indent-line-to matching-indentation) t)))
+(defun nix-indent-first-line-in-block ()
+ "Indent the first line in a block."
+
+ (let ((matching-indentation (save-excursion
+ ;; If we're on the first line of the buffer
+ (if (= (line-number-at-pos) 1)
+ ;; Return that we want to ident to
position 0 if we're on th
+ ;; first line. This fixes bad indent of
things and avoid endless
+ ;; indent loop of tokens that would match
below if we press tab
+ ;; on the first line and it happens to
match any of the ones below.
+ 0
+
+ ;; Go back to previous line that contain
anything useful to check the
+ ;; contents of that line.
+ (beginning-of-line)
+ (skip-chars-backward "\n[:space:]")
+
+ ;; Grab the full string of the line before
the one we're indenting
+ (let ((line (buffer-substring-no-properties
(line-beginning-position) (line-end-position))))
+ ;; Then regex-match strings at the end of
the line to detect if we need to indent the line after.
+ ;; We could probably add more things to
look for here in the future.
+ (if (or (string-match "let$" line)
+ (string-match "import$" line)
+ (string-match "\\[$" line)
+ (string-match "=$" line)
+ (string-match "\($" line)
+ (string-match "\{$" line))
+
+ ;; If it matches any of the regexes
above, grab the indent level
+ ;; of the line and add 2 to ident the
line below this one.
+ (+ 2 (current-indentation))))))))
+ (when matching-indentation (indent-line-to matching-indentation) t)))
+
(defun nix-mode-make-regexp (parts)
"Combine the regexps into a single or-delimited regexp.
PARTS a list of regexps"
@@ -514,6 +547,9 @@ PARTS a list of regexps"
) -1 0)
)))))
+ ;; indent line after 'let', 'import', '[', '=', '(', '{'
+ ((nix-indent-first-line-in-block))
+
;; dedent '}', ']', ')' 'in'
((nix-indent-to-backward-match))
- [nongnu] elpa/nix-mode 47cdb44e2e 255/500: Improve indentation robustness, (continued)
- [nongnu] elpa/nix-mode 47cdb44e2e 255/500: Improve indentation robustness, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1c772ad539 253/500: Remove recommended config, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 295cd6729b 261/500: Add nix-edit.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode fde8c8e38c 268/500: Merge pull request #48 from dustinlacewell/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 90ac0a74b2 273/500: Merge pull request #55 from teozkr/issue-54, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 563f6bdb03 272/500: Fixed `nix-mode-comments` matching everything, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode abdeae0f23 276/500: Make sure nix-instantiate-executable exists before running it, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 57ea981cb2 278/500: Use eval-when-compile for subr-x, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1512d02830 279/500: Formatting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0c0ec7dbd6 281/500: ert/indent: Add macro to easily test indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7f968e8a7f 284/500: Merge pull request #61 from etu/master,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 4ac7b5afb6 287/500: Add indent region function, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ff0a773d31 297/500: fix-issue-72: Check the correct element from syntax-ppss, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1798168074 307/500: Use nix-indent-function when setting indent-line-function., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 022fac17a6 308/500: Un-delete nix-indent-line., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1cda7dabbc 309/500: Bug fix: replace memq with member, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4016a1c89b 321/500: Release 1.4.0, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 91834848b4 320/500: Generate AUTHORS.md, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0bab799a87 325/500: Add failing test that checks indentation of closing parens., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode dd5f937a49 331/500: Change the description of a couple of tests., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 10ac680cd6 332/500: Merge pull request #80 from j-piecuch/smie-tweaks, ELPA Syncer, 2022/01/29