From 879bd52df9f0e308a97bfaa7df9f2d6e8a6ae0c2 Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Tue, 20 Jan 2015 23:05:56 -0500 Subject: [PATCH] Update lisp state key bindings Some commands do not auto switch to lisp state anymore (i.e. eval commands, test and goto commands, etc...) --- doc/DOCUMENTATION.md | 39 ++++++++---- .../extensions/evil-lisp-state/README.md | 32 +++++++--- .../evil-lisp-state/evil-lisp-state.el | 62 +++++++++++-------- 3 files changed, 85 insertions(+), 48 deletions(-) diff --git a/doc/DOCUMENTATION.md b/doc/DOCUMENTATION.md index 953f55366..858aa7243 100644 --- a/doc/DOCUMENTATION.md +++ b/doc/DOCUMENTATION.md @@ -108,7 +108,9 @@ - [Commenting](#commenting) - [Deleting files](#deleting-files) - [Editing Lisp code](#editing-lisp-code) - - [Commands:](#commands) + - [Lisp state Key Bindings](#lisp-state-key-bindings) + - [Lisp state Auto-switch commands](#lisp-state-auto-switch-commands) + - [Lisp state Other commands](#lisp-state-other-commands) - [Project management](#project-management) - [Registers](#registers) - [Errors handling](#errors-handling) @@ -1625,8 +1627,9 @@ to `nil` in your `~/.spacemacs`. Edition of lisp code is provided by [evil-lisp-state][]. -Every commands below will set the current state to `lisp state` where -the commands can be repeated without pressing on SPC m. +Some commands will set the current state to `lisp state` where +different commands combo can be repeated without pressing on +SPC m. When in `lisp state` the color of the mode-line changes to pink. @@ -1634,10 +1637,15 @@ Examples: - to slurp three times while in normal state: SPC m 3 n - to wrap a symbol in parenthesis then slurping two times: SPC m w 2 n -### Commands: +#### Lisp state Key Bindings + +##### Lisp state Auto-switch commands + +These commands switch to `lisp state`. Key Binding | Function ---------------------|------------------------------------------------------------ +SPC | evil leader SPC m % | evil jump item SPC m : | ex command SPC m ( | insert expression before (same level as current one) @@ -1645,14 +1653,10 @@ Key Binding | Function SPC m $ | go to the end of current sexp SPC m 0 | go to the beginning of current sexp SPC m a | absorb expression +SPC m A | transpose expression SPC m b | forward barf expression SPC m B | backward barf expression SPC m c | convolute expression -SPC m d | describe elisp thing at point (show documentation) -SPC m e $ | go to end of line and evaluate last sexp -SPC m e e | evaluate last sexp -SPC m e f | evaluate current defun -SPC m g | go to definition SPC m h | backward char SPC m H | previous symbol SPC m i | switch to `insert state` @@ -1671,9 +1675,6 @@ Key Binding | Function SPC m q | unwrap current expression and kill all symbols after point SPC m Q | unwrap current expression and kill all symbols before point SPC m r | raise expression (replace parent expression by current one) -SPC m t b | execute buffer tests -SPC m t q | ask for test function to execute -SPC m T | transpose expression SPC m u | undo SPC m C-r | redo SPC m v | switch to `visual state` @@ -1686,6 +1687,20 @@ Key Binding | Function SPC m xx | delete expression SPC m y | copy expression +##### Lisp state Other commands + +These command does not change the current state. + +Key Binding | Function +---------------------|------------------------------------------------------------ +SPC m e $ | go to end of line and evaluate last sexp +SPC m e e | evaluate last sexp +SPC m e f | evaluate current defun +SPC m d d | describe elisp thing at point (show documentation) +SPC m g g | go to definition +SPC m t b | execute buffer tests +SPC m t q | ask for test function to execute + ## Project management Projects in `Spacemacs` are managed with [projectile][projectile]. In diff --git a/spacemacs/extensions/evil-lisp-state/README.md b/spacemacs/extensions/evil-lisp-state/README.md index 680d3eb8b..cf6ca1037 100644 --- a/spacemacs/extensions/evil-lisp-state/README.md +++ b/spacemacs/extensions/evil-lisp-state/README.md @@ -44,7 +44,8 @@ both `evil`, `evil-leader` and `smartparens` to be installed. To execute a command while in normal state, the evil-leader is used. By default, the prefix for each command is ` m`. -Each command when executed set the current state to `lisp state`. + +Some commands when executed set the current state to `lisp state`. Examples: @@ -56,7 +57,11 @@ Examples: m w 2 n -## Commands and key bindings +## Key Bindings + +### Auto-switch commands + +These commands switch to `lisp state`. Key Binding | Function ----------------------------|------------------------------------------------------------ @@ -68,14 +73,10 @@ Key Binding | Function \ m $ | go to the end of current sexp \ m 0 | go to the beginning of current sexp \ m a | absorb expression +\ m A | transpose expression \ m b | forward barf expression \ m B | backward barf expression \ m c | convolute expression -\ m d | describe elisp thing at point (show documentation) -\ m e $ | go to end of line and evaluate last sexp -\ m e e | evaluate last sexp -\ m e f | evaluate current defun -\ m g | go to definition \ m h | backward char \ m H | previous symbol \ m i | switch to `insert state` @@ -94,9 +95,6 @@ Key Binding | Function \ m q | unwrap current expression and kill all symbols after point \ m Q | unwrap current expression and kill all symbols before point \ m r | raise expression (replace parent expression by current one) -\ m t b | execute buffer tests -\ m t q | ask for test function to execute -\ m T | transpose expression \ m u | undo \ m C-r | redo \ m v | switch to `visual state` @@ -109,6 +107,20 @@ Key Binding | Function \ m xx | delete expression \ m y | copy expression +### Other commands + +These command does not change the current state. + +Key Binding | Function +----------------------------|------------------------------------------------------------ +\ m e $ | go to end of line and evaluate last sexp +\ m e e | evaluate last sexp +\ m e f | evaluate current defun +\ m d d | describe elisp thing at point (show documentation) +\ m g g | go to definition +\ m t b | execute buffer tests +\ m t q | ask for test function to execute + ## Configuration Key bindings are set only for `emacs-lisp-mode` by default. diff --git a/spacemacs/extensions/evil-lisp-state/evil-lisp-state.el b/spacemacs/extensions/evil-lisp-state/evil-lisp-state.el index a794adfb7..fd5319cc2 100644 --- a/spacemacs/extensions/evil-lisp-state/evil-lisp-state.el +++ b/spacemacs/extensions/evil-lisp-state/evil-lisp-state.el @@ -5,7 +5,7 @@ ;; Author: Sylvain Benner ;; Keywords: convenience editing evil smartparens lisp mnemonic ;; Created: 9 Oct 2014 -;; Version: 6.1 +;; Version: 6.2 ;; Package-Requires: ((evil "1.0.9") (evil-leader "0.4.3") (smartparens "1.6.1")) ;; URL: https://github.com/syl20bnr/evil-lisp-state @@ -34,14 +34,17 @@ ;; To execute a command while in normal state, the evil-leader is used. ;; By default, the prefix for each command is ` m`. -;; Each command when executed set the current state to `lisp state`. +;; Some commands when executed set the current state to `lisp state`. + ;; By example, to slurp three times while in normal state: ;; m 3 n ;; Or to wrap a symbol in parenthesis then slurping two times: ;; m w 2 n -;; Commands and key bindings: -;; -------------------------- +;; Auto-switch to lisp state commands: +;; ---------------------------------- + +;; These commands switch the current state to `lisp state'. ;; Key Binding | Function ;; ---------------|------------------------------------------------------------ @@ -53,14 +56,10 @@ ;; `leader m $' | go to the end of current sexp ;; `leader m 0' | go to the beginning of current sexp ;; `leader m a' | absorb expression +;; `leader m A' | transpose expression ;; `leader m b' | forward barf expression ;; `leader m B' | backward barf expression ;; `leader m c' | convolute expression -;; `leader m d' | describe elisp thing at point (show documentation) -;; `leader m e $' | go to end of line and evaluate last sexp -;; `leader m e e' | evaluate last sexp -;; `leader m e f' | evaluate current defun -;; `leader m g' | go to definition ;; `leader m h' | backward char ;; `leader m H' | previous symbol ;; `leader m i' | switch to `insert state` @@ -76,12 +75,9 @@ ;; `leader m N' | backward slurp expression ;; `leader m p' | paste after ;; `leader m P' | paste before -;; `leader m q' | unwrap current expression and kill all symbols after point -;; `leader m Q' | unwrap current expression and kill all symbols before point +;; `leader m q' | (splice) unwrap current expression and kill all symbols after point +;; `leader m Q' | (splice) unwrap current expression and kill all symbols before point ;; `leader m r' | raise expression (replace parent expression by current one) -;; `leader m t b' | execute buffer tests -;; `leader m t q' | ask for test function to execute -;; `leader m T' | transpose expression ;; `leader m u' | undo ;; `leader m C-r' | redo ;; `leader m v' | switch to `visual state` @@ -94,6 +90,21 @@ ;; `leader m xx' | delete expression ;; `leader m y' | copy expression +;; Other commands: +;; --------------- + +;; These commands don't change the current state. + +;; Key Binding | Function +;; ---------------|------------------------------------------------------------ +;; `leader m e $' | go to end of line and evaluate last sexp +;; `leader m e e' | evaluate last sexp +;; `leader m e f' | evaluate current defun +;; `leader m d d' | describe elisp thing at point (show documentation) +;; `leader m g g' | go to definition +;; `leader m t b' | execute buffer tests +;; `leader m t q' | ask for test function to execute + ;; Configuration: ;; -------------- @@ -160,14 +171,20 @@ ;; escape (define-key evil-lisp-state-map [escape] 'evil-normal-state) - ;; toggle lisp state (define-key evil-lisp-state-map ",," 'lisp-state-toggle-lisp-state) -(dolist (mm evil-lisp-state-major-modes) - (evil-leader/set-key-for-mode mm "m," 'lisp-state-toggle-lisp-state)) - ;; leader (define-key evil-lisp-state-map (kbd evil-leader/leader) evil-leader--default-map) +;; commands that wont switch to lisp state +(dolist (mm evil-lisp-state-major-modes) + (evil-leader/set-key-for-mode mm "me$" 'lisp-state-eval-sexp-end-of-line) + (evil-leader/set-key-for-mode mm "mee" 'eval-last-sexp) + (evil-leader/set-key-for-mode mm "mef" 'eval-defun) + (evil-leader/set-key-for-mode mm "mgg" 'elisp-slime-nav-find-elisp-thing-at-point) + (evil-leader/set-key-for-mode mm "mhd" 'elisp-slime-nav-describe-elisp-thing-at-point) + (evil-leader/set-key-for-mode mm "m," 'lisp-state-toggle-lisp-state) + (evil-leader/set-key-for-mode mm "mtb" 'spacemacs/ert-run-tests-buffer) + (evil-leader/set-key-for-mode mm "mtq" 'ert)) ;; auto-switch to lisp state commands (defconst evil-lisp-state-commands @@ -187,14 +204,10 @@ ("8" . digit-argument) ("9" . digit-argument) ("a" . sp-absorb-sexp) + ("A" . sp-transpose-sexp) ("b" . sp-forward-barf-sexp) ("B" . sp-backward-barf-sexp) ("c" . sp-convolute-sexp) - ("d" . elisp-slime-nav-describe-elisp-thing-at-point) - ("e$" . lisp-state-eval-sexp-end-of-line) - ("ee" . eval-last-sexp) - ("ef" . eval-defun) - ("g" . elisp-slime-nav-find-elisp-thing-at-point) ("h" . evil-backward-char) ("H" . sp-backward-symbol) ("i" . evil-insert-state) @@ -213,9 +226,6 @@ ("q" . sp-splice-sexp-killing-forward) ("Q" . sp-splice-sexp-killing-backward) ("r" . sp-raise-sexp) - ("tb" . spacemacs/ert-run-tests-buffer) - ("tq" . ert) - ("T" . sp-transpose-sexp) ("u" . undo-tree-undo) ("C-r" . undo-tree-redo) ("v" . evil-visual-char)