Skip to content

Commit 9e7aa6e

Browse files
committed
Adds re-indent command and keybinding
1 parent 3c65fec commit 9e7aa6e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using mnemonic key bindings.
1212
- [Package manager](#package-manager)
1313
- [Manually](#manually)
1414
- [Principle](#principle)
15-
- [Commands and key bindings](#commands-and-key-bindings)
15+
- [Commands and key bindings](#key-bindings)
1616
- [Configuration](#configuration)
1717

1818
<!-- markdown-toc end -->
@@ -107,6 +107,7 @@ Key Binding | Function
107107
<kbd>\<leader\> w</kbd> | wrap expression with parenthesis
108108
<kbd>\<leader\> W</kbd> | unwrap expression
109109
<kbd>\<leader\> y</kbd> | copy expression
110+
<kbd>\<leader\> =</kbd> | re-indent expression
110111

111112
## Configuration
112113

evil-lisp-state.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ If `evil-lisp-state-global' is non nil then this variable has no effect."
254254
("C-v" . evil-visual-block)
255255
("w" . lisp-state-wrap)
256256
("W" . sp-unwrap-sexp)
257-
("y" . sp-copy-sexp))
257+
("y" . sp-copy-sexp)
258+
("=" . lisp-state-reindent))
258259
"alist of keys and commands in lisp state.")
259260

260261
(defvar evil-lisp-state-major-mode-map (make-sparse-keymap))
@@ -347,6 +348,13 @@ If `evil-lisp-state-global' is non nil then this variable has no effect."
347348
(sp-beginning-of-sexp)
348349
(evil-backward-char))
349350

351+
(defun lisp-state-reindent ()
352+
"Re-indent everything within parent sexp"
353+
(interactive)
354+
(save-excursion
355+
(backward-up-list 2 t)
356+
(let ((bounds (bounds-of-thing-at-point 'sexp)))
357+
(evil-indent (car bounds) (cdr bounds)))))
350358

351359
(provide 'evil-lisp-state)
352360

0 commit comments

Comments
 (0)