Created
July 25, 2013 13:05
-
-
Save pkkm/6079418 to your computer and use it in GitHub Desktop.
My bindings for smartparens.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Bindings. | |
(define-key sp-keymap (kbd "C-M-f") 'sp-forward-sexp) | |
(define-key sp-keymap (kbd "C-M-b") 'sp-backward-sexp) | |
(define-key sp-keymap (kbd "C-M-d") 'sp-down-sexp) | |
(define-key sp-keymap (kbd "C-M-a") 'sp-backward-down-sexp) | |
(define-key sp-keymap (kbd "C-S-a") 'sp-beginning-of-sexp) | |
(define-key sp-keymap (kbd "C-S-d") 'sp-end-of-sexp) | |
(define-key sp-keymap (kbd "C-M-e") 'sp-up-sexp) | |
(define-key emacs-lisp-mode-map (kbd ")") 'sp-up-sexp) | |
(define-key sp-keymap (kbd "C-M-u") 'sp-backward-up-sexp) | |
(define-key sp-keymap (kbd "C-M-t") 'sp-transpose-sexp) | |
(define-key sp-keymap (kbd "C-M-n") 'sp-next-sexp) | |
(define-key sp-keymap (kbd "C-M-p") 'sp-previous-sexp) | |
(define-key sp-keymap (kbd "C-M-k") 'sp-kill-sexp) | |
(define-key sp-keymap (kbd "C-M-w") 'sp-copy-sexp) | |
;;(define-key sp-keymap (kbd "M-<delete>") 'sp-unwrap-sexp) | |
;;(define-key sp-keymap (kbd "M-<backspace>") 'sp-backward-unwrap-sexp) | |
(define-key sp-keymap (kbd "C-<right>") 'sp-forward-slurp-sexp) | |
(define-key sp-keymap (kbd "C-<left>") 'sp-forward-barf-sexp) | |
(define-key sp-keymap (kbd "C-M-<left>") 'sp-backward-slurp-sexp) | |
(define-key sp-keymap (kbd "C-M-<right>") 'sp-backward-barf-sexp) | |
(define-key sp-keymap (kbd "M-D") 'sp-splice-sexp) | |
;;(define-key sp-keymap (kbd "C-M-<delete>") 'sp-splice-sexp-killing-forward) | |
;;(define-key sp-keymap (kbd "C-M-<backspace>") 'sp-splice-sexp-killing-backward) | |
;;(define-key sp-keymap (kbd "C-S-<backspace>") 'sp-splice-sexp-killing-around) | |
(define-key sp-keymap (kbd "C-]") 'sp-select-next-thing-exchange) | |
(define-key sp-keymap (kbd "C-<left_bracket>") 'sp-select-previous-thing) | |
(define-key sp-keymap (kbd "C-M-]") 'sp-select-next-thing) | |
(define-key sp-keymap (kbd "M-F") 'sp-forward-symbol) | |
(define-key sp-keymap (kbd "M-B") 'sp-backward-symbol) | |
;;; Other bindings. | |
(defvar my-smartparens-map (make-sparse-keymap) | |
"Keymap for rarely used Smartparens commands.") | |
(define-prefix-command 'my-smartparens-map) | |
(define-key evil-normal-state-map (kbd "g p") #'my-smartparens-map) | |
(define-key my-smartparens-map (kbd "t") 'sp-prefix-tag-object) ; Perform the next operation on an SGML tag. | |
(define-key my-smartparens-map (kbd "p") 'sp-prefix-pair-object) ; Perform the next operation on a balanced pair. | |
;; Splice sexp, killing backward. Then wrap the enclosing sexp with the killed one. | |
;; Example (| -- cursor): | |
;; (let ((stuff 1)) |(while (we-are-good) | |
;; (while (we-are-good) -> (let ((stuff 1)) | |
;; |(do-thing 1) (do-thing 1) | |
;; (do-thing 2))) (do-thing 2))) | |
(define-key my-smartparens-map (kbd "c") 'sp-convolute-sexp) | |
;; Absorb -- move the sexp before the one we're in into it, at the cursor position. | |
;; Emit -- the reverse. | |
;; Example (| -- cursor): | |
;; (do-stuff 1) (save-excursion | |
;; (save-excursion --absorb--> |(do-stuff 1) | |
;; |(do-stuff 2)) (do-stuff 2)) | |
(define-key my-smartparens-map (kbd "a") 'sp-absorb-sexp) | |
(define-key my-smartparens-map (kbd "e") 'sp-emit-sexp) | |
(define-key my-smartparens-map (kbd "A") 'sp-emit-sexp) | |
(define-key my-smartparens-map (kbd "E") 'sp-absorb-sexp) | |
;; Add the expression after/before point to the list before/after point (like slurp forward/backward, but from the outside). | |
(define-key my-smartparens-map (kbd "p") 'sp-add-to-previous-sexp) | |
(define-key my-smartparens-map (kbd "n") 'sp-add-to-next-sexp) | |
;; Join, split. | |
(define-key my-smartparens-map (kbd "j") 'sp-join-sexp) | |
(define-key my-smartparens-map (kbd "T") 'sp-join-sexp) | |
(define-key my-smartparens-map (kbd "s") 'sp-split-sexp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment