summary refs log tree commit diff stats
path: root/tag-emacs
diff options
context:
space:
mode:
authorAlan Pearce2014-09-18 22:07:58 +0100
committerAlan Pearce2014-09-18 22:07:58 +0100
commitbc1a9ab08614e8c2bc2ae7e20909abba1497a17e (patch)
tree6f72c211f526d774f21e7bc2eb934c8bc0c2e339 /tag-emacs
parentdb0a14cddc21eba4b312a47f3af39de4b9a85053 (diff)
downloaddotfiles-bc1a9ab08614e8c2bc2ae7e20909abba1497a17e.tar.lz
dotfiles-bc1a9ab08614e8c2bc2ae7e20909abba1497a17e.tar.zst
dotfiles-bc1a9ab08614e8c2bc2ae7e20909abba1497a17e.zip
Emacs: Use smartparens to replace 4 other modes
Paredit, autopair, cedit and smart-forward. Should work nicely in HTML
modes, too!
Diffstat (limited to 'tag-emacs')
-rw-r--r--tag-emacs/emacs.d/Cask5
-rw-r--r--tag-emacs/emacs.d/init.el92
2 files changed, 24 insertions, 73 deletions
diff --git a/tag-emacs/emacs.d/Cask b/tag-emacs/emacs.d/Cask
index ed03f3a..9374e0c 100644
--- a/tag-emacs/emacs.d/Cask
+++ b/tag-emacs/emacs.d/Cask
@@ -8,10 +8,8 @@
 (depends-on "ag")
 (depends-on "auto-compile")
 (depends-on "auto-indent-mode")
-(depends-on "autopair")
 (depends-on "bind-key")
 (depends-on "cask")
-(depends-on "cedit")
 (depends-on "cider")
 (depends-on "clj-refactor")
 (depends-on "clojure-mode")
@@ -64,7 +62,6 @@
 (depends-on "org-plus-contrib")
 (depends-on "pallet")
 (depends-on "paradox")
-(depends-on "paredit")
 (depends-on "persp-projectile")
 (depends-on "perspective")
 (depends-on "php-extras")
@@ -80,9 +77,9 @@
 (depends-on "scss-mode")
 (depends-on "skewer-mode")
 (depends-on "slime")
-(depends-on "smart-forward")
 (depends-on "smart-tab")
 (depends-on "smart-tabs-mode")
+(depends-on "smartparens")
 (depends-on "toml-mode")
 (depends-on "tup-mode")
 (depends-on "undo-tree")
diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el
index 10bdea9..d5b693d 100644
--- a/tag-emacs/emacs.d/init.el
+++ b/tag-emacs/emacs.d/init.el
@@ -997,8 +997,6 @@ mouse-1: Display Line and Column Mode Menu"))))))
 ;; replace highlighted text rather than just inserting at point
 (delete-selection-mode t)
 
-(show-paren-mode t)
-
 (bind-key "S-SPC" #'set-mark-command)
 
 (req-package subword
@@ -1029,21 +1027,6 @@ mouse-1: Display Line and Column Mode Menu"))))))
             (setq ace-jump-word-mode-use-query-char nil
                   ace-jump-mode-scope 'window)))
 
-(req-package autopair
-  :commands (autopair-mode
-             autopair-on)
-  :init (progn
-          (add-hook 'prog-mode-hook #'autopair-on)
-          (add-hook 'text-mode-hook #'autopair-on)
-          (add-hook 'yaml-mode-hook #'autopair-on)
-          (defun autopair-off ()
-            (autopair-mode -1))
-          (add-hook 'web-mode-hook #'autopair-off)
-          (add-hook 'lisp-mode-common-hook #'autopair-off)
-          (add-hook 'c-mode-common-hook #'autopair-off)
-          (setq autopair-blink nil
-                autopair-skip-whitespace nil)))
-
 (req-package expand-region
   :bind ("C-M-SPC" . er/expand-region))
 
@@ -1069,61 +1052,34 @@ mouse-1: Display Line and Column Mode Menu"))))))
   :commands (eldoc-mode)
   :diminish eldoc-mode
   :config (progn
-            (eldoc-add-command 'paredit-backward-delete 'paredit-close-round 'autopair-insert-opening)
             (setq eldoc-idle-delay 0.1)))
 
-(req-package cedit
-  :diminish "{}"
-  :require paredit
-  :init (progn
-          (defvar cedit-mode-map (make-sparse-keymap)
-            "Keymap for the cedit minor mode.")
-          (define-minor-mode cedit-mode
-            "Minor mode for paredit-style editing in c-style modes."
-            :lighter " Cedit")
-          (defun turn-on-cedit-mode ()
-            (enable-paredit-mode)
-            (cedit-mode 1))
-          (add-hook #'c-mode-common-hook #'turn-on-cedit-mode))
-  :config (progn
-            (bind-key "M-a" #'cedit-beginning-of-statement cedit-mode-map)
-            (bind-key "M-e" #'cedit-end-of-statement cedit-mode-map)
-            (bind-key "C-M-d" #'cedit-down-block cedit-mode-map)
-            (bind-key "C-M-u" #'cedit-up-block-backward cedit-mode-map)
-            (bind-key "C-M-n" #'cedit-up-block-forward cedit-mode-map)
-            (bind-key "M-{" #'cedit-wrap-brace cedit-mode-map)
-            (bind-key "C-)" #'cedit-or-paredit-slurp cedit-mode-map)
-            (bind-key "C-}" #'cedit-or-paredit-barf cedit-mode-map)
-            (bind-key "M-<up>" #'cedit-or-paredit-splice-killing-backward cedit-mode-map)
-            (bind-key "M-r" #'cedit-or-paredit-raise cedit-mode-map)))
-
-(req-package paredit
-  :diminish "()"
-  :commands (paredit-mode)
+(req-package smartparens
+  :defer t
   :config (progn
-            (defun ap/cedit-space-delimiter-p (endp delimiter)
-              "Don't insert a space before delimiters in c-style modes"
-              (not cedit-mode))
-            (add-to-list 'paredit-space-for-delimiter-predicates #'ap/cedit-space-delimiter-p))
-  :init (progn
-          (add-hook 'lisp-mode-common-hook #'enable-paredit-mode)
-          (put #'paredit-forward-delete 'delete-selection 'supersede)
-          (put #'paredit-backward-delete 'delete-selection 'supersede)
-          (add-hook 'minibuffer-setup-hook #'conditionally-enable-paredit-mode)
-          (defun conditionally-enable-paredit-mode ()
-            "enable paredit-mode during eval-expression"
-            (if (eq this-command 'eval-expression)
-                (paredit-mode 1)))))
+            (sp-use-smartparens-bindings)
+            (fset 'wrap-with-paren "\C-](") ;; `sp-select-next-thing-exchange'
+            (bind-key "C-(" #'wrap-with-paren sp-keymap)
+            (bind-key "C-)" #'sp-forward-slurp-sexp sp-keymap)
+            (bind-key "M-<backspace>" #'backwarp-kill-word sp-keymap)
+            (bind-key "M-?" #'sp-convolute-sexp sp-keymap sp-keymap)
+            (bind-key "M-t" #'sp-transpose-sexp sp-keymap sp-keymap)
+            (bind-key "M-r" #'sp-raise-sexp sp-keymap)
+            (bind-key "M-s" #'sp-splice-sexp sp-keymap)
+            (bind-key "M-S" #'sp-split-sexp sp-keymap)
+            (bind-key "M-J" #'sp-join-sexp sp-keymap)
+            (bind-key "M-<up>" #'sp-splice-sexp-killing-backward sp-keymap)
+            (bind-key "M-<down>" #'sp-splice-sexp-killing-forward sp-keymap)
+            (show-smartparens-global-mode t)
+            (smartparens-global-strict-mode t)))
+
+(req-package smartparens-config
+  :require smartparens
+  :defer t)
 
 (req-package move-text
   :config (move-text-default-bindings))
 
-(req-package smart-forward
-  :bind (("C-M-u" . smart-up)
-         ("C-M-d" . smart-down)
-         ("C-M-p" . smart-backward)
-         ("C-M-n" . smart-forward)))
-
 (req-package undo-tree
   :config (progn
             (global-undo-tree-mode)
@@ -1149,8 +1105,7 @@ mouse-1: Display Line and Column Mode Menu"))))))
 
 (defun ap/lisp-setup ()
   (run-hooks 'lisp-mode-common-hook)
-  (setq indent-tabs-mode nil)
-  (local-set-key (kbd "RET") #'paredit-newline))
+  (setq indent-tabs-mode nil))
 
 (defun set-common-lisp-indentation ()
     (set (make-local-variable 'lisp-indent-function)
@@ -1197,8 +1152,7 @@ mouse-1: Display Line and Column Mode Menu"))))))
   :config (progn
             (setq nrepl-hide-special-buffers t)
             (unbind-key "C-c C-f" cider-mode-map)
-            (add-hook 'cider-mode-hook #'cider-turn-on-eldoc-mode)
-            (add-hook 'cider-repl-mode-hook #'paredit-mode)))
+            (add-hook 'cider-mode-hook #'cider-turn-on-eldoc-mode)))
 
 (req-package redshank
   :diminish " Λ"