diff options
author | David Morgan <djm_uk@protonmail.com> | 2022-11-16 15:52:19 +0000 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2022-11-16 15:52:19 +0000 |
commit | a977aa74ff42f764a7883b572f8b924d154e2574 (patch) | |
tree | d7d6ec26acca3426345398da3a1b8e9b36525aa6 /.emacs.d/lisp | |
parent | de38da5ddfc26667f490fce00db446a349345e8e (diff) | |
download | dotfiles-a977aa74ff42f764a7883b572f8b924d154e2574.tar.gz |
Add kill-around-sexp function
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r-- | .emacs.d/lisp/init-smartparens.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/.emacs.d/lisp/init-smartparens.el b/.emacs.d/lisp/init-smartparens.el index 1366045..db995aa 100644 --- a/.emacs.d/lisp/init-smartparens.el +++ b/.emacs.d/lisp/init-smartparens.el @@ -53,6 +53,18 @@ (sp-wrap-round) (insert " ") (forward-char -1)) + (defun kill-around-sexp () + "Kill everything in the current list, except the current expression. +Equivalent to raising then wrapping." + (interactive) + (let ((paren-char (save-excursion + (sp-backward-up-sexp) + (following-char)))) + (sp-raise-sexp) + (cond ((= paren-char ?\() (sp-wrap-round)) + ((= paren-char ?\{) (sp-wrap-curly)) + ((= paren-char ?\[) (sp-wrap-square)) + (t (error "Not in a list"))))) (unbind-key "M-?" 'smartparens-mode-map) (unbind-key "M-?" 'sp-keymap) :bind (:map smartparens-mode-map @@ -68,6 +80,7 @@ ("M-;" . paredit-comment-dwim) ("M-q" . sp-indent-defun) ("C-j" . sp-newline) + ("M-R" . kill-around-sexp) ("C-c C-S-d" . duplicate-sexp-after-point) ("C-c M-(" . wrap-round-from-behind))) |