[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 1512d02830 279/500: Formatting
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 1512d02830 279/500: Formatting |
Date: |
Sat, 29 Jan 2022 08:27:13 -0500 (EST) |
branch: elpa/nix-mode
commit 1512d02830fe90dddd35c9b4bd83d0ee963de57b
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
Formatting
---
nix-mode.el | 121 +++++++++++++++++++++++++++++-------------------------------
1 file changed, 59 insertions(+), 62 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index d6c507e38c..d4bf6fc486 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -133,16 +133,14 @@ Valid functions for this are:
"\\<\\([a-zA-Z_][a-zA-Z0-9_'\-\.]*\\)[ \t]*=[^=]")
(defconst nix-font-lock-keywords
- `(
- (,(regexp-opt nix-keywords 'symbols) 0 'nix-keyword-face)
+ `((,(regexp-opt nix-keywords 'symbols) 0 'nix-keyword-face)
(,(regexp-opt nix-warning-keywords 'symbols) 0 'nix-keyword-warning-face)
(,(regexp-opt nix-builtins 'symbols) 0 'nix-builtin-face)
(,nix-re-url 0 'nix-constant-face)
(,nix-re-file-path 0 'nix-constant-face)
(,nix-re-variable-assign 1 'nix-attribute-face)
(,nix-re-bracket-path 0 'nix-constant-face)
- (nix--syntax-match-antiquote 0 'nix-antiquote-face t)
- )
+ (nix--syntax-match-antiquote 0 'nix-antiquote-face t))
"Font lock keywords for nix.")
(defconst nix--variable-char "[a-zA-Z0-9_'\-]")
@@ -298,7 +296,8 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
'nix-string-type string-type)
(put-text-property start (1+ start)
'nix-syntax-antiquote t)
- (let ((ahead (buffer-substring (1+ start) (min (point-max) (+ 5
start)))))
+ (let ((ahead (buffer-substring (1+ start)
+ (min (point-max) (+ 5 start)))))
(pcase string-type
(`?\" (cond
((or (string-match "^\\\\\"" ahead)
@@ -326,7 +325,7 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
"Special syntax properties for Nix from START to END."
(goto-char start)
(remove-text-properties start end
- '(syntax-table nil nix-string-type nil
nix-syntax-antiquote nil))
+ '(nix-string-type nil nix-syntax-antiquote nil))
(funcall
(syntax-propertize-rules
("\\\\\\\\"
@@ -359,20 +358,18 @@ STRING-TYPE type of string based off of Emacs syntax
table types"
(cond
((looking-at "in\\b")
(let ((counter 1))
- (while (and (> counter 0) (re-search-backward "\\b\\(let\\|in\\)\\b" nil
t))
+ (while (and (> counter 0)
+ (re-search-backward "\\b\\(let\\|in\\)\\b" nil t))
(unless (nix--inside-string-or-comment)
(setq counter (cond ((looking-at "let") (- counter 1))
- ((looking-at "in") (+ counter 1))))
- )
- )
+ ((looking-at "in") (+ counter 1))))))
counter ))
((looking-at "}")
(backward-up-list) t)
((looking-at "]")
(backward-up-list) t)
((looking-at ")")
- (backward-up-list) t)
- ))
+ (backward-up-list) t)))
(defun nix-indent-to-backward-match ()
"Match the previous line’s indentation."
@@ -381,8 +378,7 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(skip-chars-forward "[:space:]")
(if (nix-find-backward-matching-token)
(current-indentation)))))
- (when matching-indentation (indent-line-to matching-indentation) t))
- )
+ (when matching-indentation (indent-line-to matching-indentation) t)))
(defun nix-mode-make-regexp (parts)
"Combine the regexps into a single or-delimited regexp.
@@ -423,10 +419,12 @@ PARTS a list of regexps"
(done nil)
(indent (current-indentation)))
(save-excursion
- ;; we want to indent this line, so we don't care what it contains
- ;; skip to the beginning so reverse searching doesn't find any matches
within
+ ;; we want to indent this line, so we don't care what it
+ ;; contains skip to the beginning so reverse searching doesn't
+ ;; find any matches within
(beginning-of-line)
- ;; search backward until an unbalanced cap is found or no cap or end is
found
+ ;; search backward until an unbalanced cap is found or no cap or
+ ;; end is found
(while (and (not done) (nix-mode-search-backward))
(cond
((looking-at (nix-mode-quotes-regexp))
@@ -456,7 +454,8 @@ PARTS a list of regexps"
(setq done t))))))
;; done is t when we found an unbalanced expression cap
(when done
- ;; indent relative to the indentation of the expression containing our
line
+ ;; indent relative to the indentation of the expression
+ ;; containing our line
(indent-line-to (+ tab-width indent)))
;; return t to the caller if we found at least one cap
;; this signals that we handled the indentation
@@ -486,46 +485,46 @@ PARTS a list of regexps"
(defun nix-indent-line ()
"Indent current line in a Nix expression."
(interactive)
- (let ((end-of-indentation (save-excursion
- (cond
-
- ;; comment
- ((save-excursion
- (beginning-of-line)
- (nth 4 (syntax-ppss)))
- (indent-line-to (nix-indent-prev-level)))
-
- ;; string
- ((save-excursion
- (beginning-of-line)
- (nth 3 (syntax-ppss)))
- (indent-line-to (+ (nix-indent-prev-level)
- (* tab-width (+ (if (save-excursion
- (forward-line -1)
- (end-of-line)
- (skip-chars-backward "[:space:]")
- (looking-back "''" 0)) 1 0)
- (if (save-excursion
- (beginning-of-line)
- (skip-chars-forward
- "[:space:]")
- (looking-at "''")
- ) -1 0)
- )))))
-
- ;; dedent '}', ']', ')' 'in'
- ((nix-indent-to-backward-match))
-
- ;; indent between = and ; + 2, or to 2
- ((nix-indent-expression-start))
-
- ;; else
- (t
- (indent-line-to (nix-indent-prev-level)))
- )
- (point))))
- (when (> end-of-indentation (point)) (goto-char end-of-indentation)))
- )
+ (let ((end-of-indentation
+ (save-excursion
+ (cond
+
+ ;; comment
+ ((save-excursion
+ (beginning-of-line)
+ (nth 4 (syntax-ppss)))
+ (indent-line-to (nix-indent-prev-level)))
+
+ ;; string
+ ((save-excursion
+ (beginning-of-line)
+ (nth 3 (syntax-ppss)))
+ (indent-line-to (+ (nix-indent-prev-level)
+ (* tab-width
+ (+ (if (save-excursion
+ (forward-line -1)
+ (end-of-line)
+ (skip-chars-backward "[:space:]")
+ (looking-back "''" 0)) 1 0)
+ (if (save-excursion
+ (beginning-of-line)
+ (skip-chars-forward
+ "[:space:]")
+ (looking-at "''")
+ ) -1 0)
+ )))))
+
+ ;; dedent '}', ']', ')' 'in'
+ ((nix-indent-to-backward-match))
+
+ ;; indent between = and ; + 2, or to 2
+ ((nix-indent-expression-start))
+
+ ;; else
+ (t
+ (indent-line-to (nix-indent-prev-level))))
+ (point))))
+ (when (> end-of-indentation (point)) (goto-char end-of-indentation))))
;;;###autoload
(defun nix-mode-ffap-nixpkgs-path (str)
@@ -556,8 +555,7 @@ don’t do anything"
(defun nix-create-menu ()
"Create the Nix menu as shown in the menu bar."
(let ((m '("Nix"
- ["Format buffer" nix-format-buffer t])
- ))
+ ["Format buffer" nix-format-buffer t])))
(easy-menu-define ada-mode-menu nix-mode-map "Menu keymap for Nix mode"
m)))
(nix-create-keymap)
@@ -622,8 +620,7 @@ The hook `nix-mode-hook' is run when Nix mode is started.
(push '(nix-mode . nix-mode-ffap-nixpkgs-path) ffap-alist)
(push '(nix-mode "--:\\\\${}<>+@-Z_[:alpha:]~*?" "@" "@;.,!:")
- ffap-string-at-point-mode-alist)
- )
+ ffap-string-at-point-mode-alist))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.nix\\'" . nix-mode))
- [nongnu] elpa/nix-mode ae2c44c160 250/500: Add nix-shell-haskell.el, (continued)
- [nongnu] elpa/nix-mode ae2c44c160 250/500: Add nix-shell-haskell.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c462eb400b 251/500: Add alias for nix-repl-show, ELPA Syncer, 2022/01/29
- [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 <=
- [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, 2022/01/29
- [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