[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-lisp-state 3a72893879 031/125: New common backward pr
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-lisp-state 3a72893879 031/125: New common backward prefix |
Date: |
Thu, 6 Jan 2022 04:58:39 -0500 (EST) |
branch: elpa/evil-lisp-state
commit 3a72893879a0eb0d5f664d977d3ecc18bc0ba40a
Author: syl20bnr <sylvain.benner@gmail.com>
Commit: syl20bnr <sylvain.benner@gmail.com>
New common backward prefix
A couple of key bindings have changed, refer to readme for more
information.
---
README.md | 51 +++++++++++++++++++++++++++++++++------------------
evil-lisp-state.el | 54 ++++++++++++++++++++++++++++++++++++------------------
2 files changed, 69 insertions(+), 36 deletions(-)
diff --git a/README.md b/README.md
index 69e4695c57..0cb9e9c553 100644
--- a/README.md
+++ b/README.md
@@ -36,26 +36,42 @@ in order to trigger the `lisp state`.
(define-key evil-normal-state-map "L" 'evil-lisp-state)
```
+To change custom variables:
+
+```
+M-x customize-group evil-lisp-state
+```
+
+### Backward prefix
+
+Corresponding backward version of a command is performed by a common prefix
+whose value is determined by the custom variable
+`evil-lisp-state-backward-prefix`. Default value is `n`.
+
+For instance, `slurping forward` is performed with `s` and the backward
+version `slurping backward` with `ns`.
+
## Key bindings map
-While in `lisp state`:
+While in `lisp state` (assume that `evil-lisp-state-backward-prefix` is set
+to default `n`):
Key Binding | Function
--------------|------------------------------------------------------------
`$` | sp-end-of-sexp
`0` | sp-beginning-of-sexp
`a` | sp-absorb-sexp
-`bh` | sp-backward-barf-sexp
-`bl` | sp-forward-barf-sexp
+`b` | sp-forward-barf-sexp
+`nb` | sp-backward-barf-sexp
`c` | sp-convolute-sexp
`C` | sp-comment
`dd` | sp-kill-hybrid-sexp
-`dh` | sp-backward-kill-sexp
-`dl` | sp-kill-sexp
-`dsl` | sp-kill-symbol
-`dsh` | sp-backward-kill-symbol
-`dwl` | sp-kill-word
-`dwh` | sp-backward-kill-word
+`dx` | sp-kill-sexp
+`ndx` | sp-backward-kill-sexp
+`ds`x | sp-kill-symbol
+`nds` | sp-backward-kill-symbol
+`dw` | sp-kill-word
+`ndw` | sp-backward-kill-word
`e$` | evil-lisp-state-eval-sexp-end-of-line
`ef` | eval-defun
`el` | eval-last-sexp
@@ -72,21 +88,20 @@ Key Binding | Function
`m` | sp-join-sexp (think about `merge-sexp`)
`p` | evil-past-after
`P` | evil-past-before
-`r` | sp-raise-sexp (same as `ska`)
+`r` | sp-raise-sexp
`R` | sp-rewrap-sexp
`C-r` | undo-tree-redo
-`ska` | sp-splice-sexp-killing-around
-`skh` | sp-splice-sexp-killing-backward
-`skl` | sp-splice-sexp-killing-forward
-`sh` | sp-backward-slurp-sexp
-`sl` | sp-forward-slurp-sexp
-`sx` | sp-splice-sexp
+`s` | sp-forward-slurp-sexp
+`ns` | sp-backward-slurp-sexp
+`S` | sp-splice-sexp-killing-forward
+`nS` | sp-splice-sexp-killing-backward
`t` | sp-transpose-sexp
`T` | sp-transpose-hybrid-sexp
`u` | undo-tree-undo
`U` | sp-unwrap-sexp
-`yh` | sp-backward-copy-sexp
-`yl` | sp-copy-sexp
+`nU` | sp-backward-unwrap-sexp
+`y` | sp-copy-sexp
+`ny` | sp-backward-copy-sexp
`RET` | sp-newline
`ESC` | evil-normal-state
diff --git a/evil-lisp-state.el b/evil-lisp-state.el
index 86f3e67826..dbe0cd0df8 100644
--- a/evil-lisp-state.el
+++ b/evil-lisp-state.el
@@ -5,7 +5,7 @@
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; Keywords: convenience editing evil smartparens lisp mnemonic
;; Created: 9 Oct 2014
-;; Version: 1.0
+;; Version: 1.1
;; Package-Requires: ((evil "1.0.9") (smartparens "1.6.1"))
;; URL: https://github.com/syl20bnr/evil-lisp-state
@@ -52,6 +52,33 @@
;; force smartparens mode
(if (evil-lisp-state-p) (smartparens-mode)))
+(defgroup evil-lisp-state nil
+ "Evil lisp state."
+ :group 'emulations
+ :prefix 'evil-lisp-state-)
+
+(defcustom evil-lisp-state-backward-prefix "n"
+ "Prefix to execute the backward version of a command"
+ :type 'string
+ :group 'evil-lisp-state)
+
+(defmacro evil-lisp-state-define-key (key command &optional backward)
+ "Define a key binding for KEY and COMMAND.
+
+If BACKWARD is not nil then a binding is also created for backward version
+of COMMAND.
+ The backward binding is prepended with `evil-lisp-state-backward-prefix'"
+ `(let* ((cmdstr ,(symbol-name command))
+ (cmdsym (intern (format "sp-%s" cmdstr))))
+ (define-key evil-lisp-state-map ,key cmdsym)
+ (if ,backward
+ (let* ((bcmdstr (if (string-match "forward" cmdstr)
+ (replace-regexp-in-string "forward" "backward"
cmdstr)
+ (concat "backward-" cmdstr)))
+ (bcmdsym (intern (format "sp-%s" bcmdstr)))
+ (bkey ,(concat evil-lisp-state-backward-prefix key)))
+ (define-key evil-lisp-state-map bkey bcmdsym)))))
+
;; key bindings
(define-key evil-lisp-state-map "1" 'digit-argument)
(define-key evil-lisp-state-map "2" 'digit-argument)
@@ -65,17 +92,13 @@
(define-key evil-lisp-state-map "$" 'sp-end-of-sexp)
(define-key evil-lisp-state-map "0" 'sp-beginning-of-sexp)
(define-key evil-lisp-state-map "a" 'sp-absorb-sexp)
-(define-key evil-lisp-state-map "bh" 'sp-backward-barf-sexp)
-(define-key evil-lisp-state-map "bl" 'sp-forward-barf-sexp)
+(evil-lisp-state-define-key "b" forward-barf-sexp t)
(define-key evil-lisp-state-map "c" 'sp-convolute-sexp)
(define-key evil-lisp-state-map "C" 'sp-comment)
(define-key evil-lisp-state-map "dd" 'sp-kill-hybrid-sexp)
-(define-key evil-lisp-state-map "dh" 'sp-backward-kill-sexp)
-(define-key evil-lisp-state-map "dl" 'sp-kill-sexp)
-(define-key evil-lisp-state-map "dsh" 'sp-backward-kill-symbol)
-(define-key evil-lisp-state-map "dsl" 'sp-kill-symbol)
-(define-key evil-lisp-state-map "dwh" 'sp-backward-kill-word)
-(define-key evil-lisp-state-map "dwl" 'sp-kill-word)
+(evil-lisp-state-define-key "dx" kill-sexp t)
+(evil-lisp-state-define-key "ds" kill-symbol t)
+(evil-lisp-state-define-key "dw" kill-word t)
(define-key evil-lisp-state-map "e$" 'evil-lisp-state-eval-sexp-end-of-line)
(define-key evil-lisp-state-map "ef" 'eval-defun)
(define-key evil-lisp-state-map "el" 'eval-last-sexp)
@@ -95,18 +118,13 @@
(define-key evil-lisp-state-map "r" 'sp-raise-sexp)
(define-key evil-lisp-state-map "R" 'sp-rewrap-sexp)
(define-key evil-lisp-state-map (kbd "C-r") 'undo-tree-redo)
-(define-key evil-lisp-state-map "ska" 'sp-splice-sexp-killing-around)
-(define-key evil-lisp-state-map "skh" 'sp-splice-sexp-killing-backward)
-(define-key evil-lisp-state-map "skl" 'sp-splice-sexp-killing-forward)
-(define-key evil-lisp-state-map "sh" 'sp-backward-slurp-sexp)
-(define-key evil-lisp-state-map "sl" 'sp-forward-slurp-sexp)
-(define-key evil-lisp-state-map "sx" 'sp-splice-sexp)
+(evil-lisp-state-define-key "s" forward-slurp-sexp t)
+(evil-lisp-state-define-key "S" splice-sexp-killing-forward t)
(define-key evil-lisp-state-map "t" 'sp-transpose-sexp)
(define-key evil-lisp-state-map "T" 'sp-transpose-hybrid-sexp)
(define-key evil-lisp-state-map "u" 'undo-tree-undo)
-(define-key evil-lisp-state-map "U" 'sp-unwrap-sexp)
-(define-key evil-lisp-state-map "yh" 'sp-backward-copy-sexpp)
-(define-key evil-lisp-state-map "yl" 'sp-copy-sexp)
+(evil-lisp-state-define-key "U" unwrap-sexp t)
+(evil-lisp-state-define-key "y" copy-sexp t)
(define-key evil-lisp-state-map (kbd "DEL") 'evil-backward-char)
(define-key evil-lisp-state-map (kbd "RET") 'sp-newline)
(define-key evil-lisp-state-map [escape] 'evil-normal-state)
- [nongnu] elpa/evil-lisp-state b4a1371a01 020/125: Add key bindings for transpose functions, (continued)
- [nongnu] elpa/evil-lisp-state b4a1371a01 020/125: Add key bindings for transpose functions, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state af7ce842d1 024/125: Add fine grain forward and backward motion with evil standard, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state eefaabc310 027/125: Add installation instruction for MELPA and Cask in readme, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 563654c8cd 040/125: Swap back `k` and `K`, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state d2fe2754c7 044/125: Add disclaimer about experimentation in readme, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 5569669299 049/125: Add `gs` key binding for elisp-slime-nav-find-elisp-thing-at-point, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state c6131e28e0 056/125: New navigation model leading to version 2.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 90c8a95714 061/125: Add `%` key binding documentation in readme, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 46fbe7ade7 069/125: Keep `a` for evil-append, absorb-sexp is now on `A`, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 176ebd50e8 062/125: Change key binding `xs` to `xx` for consistency, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 3a72893879 031/125: New common backward prefix,
ELPA Syncer <=
- [nongnu] elpa/evil-lisp-state 37533c6d13 032/125: Type in readme, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 769d43ab36 036/125: Add forward/backward symbol binding to `L` and `H` respectively, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 7b1d98bf75 041/125: Version 1.3, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 0f6eefcb3e 045/125: Add `o` command to insert a new sexp at point on a new line below, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 77b8cc7bd8 050/125: Add key binding `(` which switches to insert state and insert `(`, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state dbc6ae05b5 051/125: Add evil-open-above with binding `O`, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state f387d10375 054/125: `L` bindings no go to the beginning of the next sexp at the same level, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 29a85e9948 059/125: Minor change in readme, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state ca32c94dce 067/125: Update commentary, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-lisp-state 1a0efed5c2 068/125: Set back to t the variable sp-navigate-consider-symbols, ELPA Syncer, 2022/01/06