[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 4ac7b5afb6 287/500: Add indent region function
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 4ac7b5afb6 287/500: Add indent region function |
Date: |
Sat, 29 Jan 2022 08:27:14 -0500 (EST) |
branch: elpa/nix-mode
commit 4ac7b5afb66f995f3fcfa0834939326b749f4da8
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
Add indent region function
We will always use nix-indent line here.
---
nix-mode.el | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/nix-mode.el b/nix-mode.el
index bb8f1c2f67..73d12a5e63 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -398,7 +398,6 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
"Search backward for items of interest regarding indentation."
(re-search-backward nix-re-ends nil t)
(re-search-backward nix-re-quotes nil t)
- (re-search-backward nix-re-comments nil t)
(re-search-backward nix-re-caps nil t))
(defun nix-indent-expression-start ()
@@ -527,6 +526,30 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(or (looking-at nix-re-quotes)
(nix--get-string-type (nix--get-parse-state (point)))))
+;;;###autoload
+(defun nix-indent-region (start end)
+ "Indent on a whole region. Enabled by default.
+START where to start in region.
+END where to end the region."
+ (save-excursion
+ (goto-char start)
+ (while (< (point) end)
+ (or (and (bolp) (eolp))
+ (when (and
+ ;; Skip if previous line is empty or a comment.
+ (save-excursion
+ (let ((line-is-comment-p (nix-is-comment-p)))
+ (forward-line -1)
+ (not
+ (or (and (nix-is-comment-p)
+ ;; Unless this line is a comment too.
+ (not line-is-comment-p))
+ (nix-is-comment-p)))))
+ ;; Don't mess with strings.
+ (nix-is-string-p))
+ (nix-indent-line)))
+ (forward-line 1))))
+
;;;###autoload
(defun nix-mode-ffap-nixpkgs-path (str)
"Support `ffap' for <nixpkgs> declarations.
@@ -605,6 +628,7 @@ The hook `nix-mode-hook' is run when Nix mode is started.
;; Automatic indentation [C-j]
(setq-local indent-line-function nix-indent-function)
+ (set (make-local-variable 'indent-region-function) 'nix-indent-region)
;; Indenting of comments
(setq-local comment-start "# ")
@@ -617,8 +641,10 @@ The hook `nix-mode-hook' is run when Nix mode is started.
(setq-local paragraph-start "[ \t]*\\(#+[ \t]*\\)?$")
(setq-local paragraph-separate paragraph-start)
+ ;; Menu
(easy-menu-add nix-mode-menu nix-mode-map)
+ ;; Find file at point
(push '(nix-mode . nix-mode-ffap-nixpkgs-path) ffap-alist)
(push '(nix-mode "--:\\\\${}<>+@-Z_[:alpha:]~*?" "@" "@;.,!:")
ffap-string-at-point-mode-alist))
- [nongnu] elpa/nix-mode 1c772ad539 253/500: Remove recommended config, (continued)
- [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, 2022/01/29
- [nongnu] elpa/nix-mode 4ac7b5afb6 287/500: Add indent region function,
ELPA Syncer <=
- [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
- [nongnu] elpa/nix-mode 907336cd0b 337/500: Silence byte compiler warnings in nix-shell, ELPA Syncer, 2022/01/29