From 0a5333ec1da90dde6afe46bf90cb4a24ad435c30 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 18 Apr 2014 15:21:10 +0100 Subject: [PATCH] Switch from autopair to smartparens The smartparens package also negates the need for ruby-electric-mode, and doesn't play nice with cua-mode. But my use of cua-mode was due to a bug between ECB and delete-selection-mode, which seems to now be fixed. Hence cua-mode is out too. --- aliases.el | 1 + behavior.el | 14 ++------------ custom-variables.el | 4 ++-- keybindings.el | 8 ++++++++ mode-customizations/ruby-mode.el | 4 ---- packages.el | 9 +++++---- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/aliases.el b/aliases.el index c6d3b2e..b08eaeb 100644 --- a/aliases.el +++ b/aliases.el @@ -9,6 +9,7 @@ (defalias 'sl 'sort-lines) (defalias 'rr 'reverse-region) (defalias 'wc 'whitespace-cleanup) +(defalias 'rw 'sp-rewrap-sexp) (defalias 'lml 'list-matching-lines) (defalias 'dml 'delete-matching-lines) diff --git a/behavior.el b/behavior.el index 6073c55..70d80f4 100644 --- a/behavior.el +++ b/behavior.el @@ -14,11 +14,6 @@ (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) -;; Autopair mode. I'm sorry, electric-pair mode just isn't as good, mainly -;; cause it can't wrap the region in the pair-character you type. -(when (require 'autopair nil 'noerror) - (autopair-global-mode)) - ;; Enable Projectile global mode. (when (require 'projectile nil 'noerror) (projectile-global-mode)) @@ -32,13 +27,8 @@ (recentf-mode 1) (setq recentf-max-menu-items 100) -;; When using autopair, ECB and delete-selection-mode there's a weird conflict -;; which disables delete-selection-mode whenever you click on a directory or -;; file in ECB's tree buffer. For that reason, and for it's neat rectangle -;; selection feature we're using cua-mode as it's delete-selection-ish feature -;; is not effected by the issue. -(setq cua-rectangle-mark-key (kbd "M-RET")) -(cua-mode t) +;; Enable delete-selection-mode +(delete-selection-mode t) ;; Disable cua-mode's fancy keys like C-z, C-v, etc. cause we use them for ;; other things, and we already have good keybindings for cut, copy, paste and diff --git a/custom-variables.el b/custom-variables.el index 84930ef..957ff4e 100644 --- a/custom-variables.el +++ b/custom-variables.el @@ -16,7 +16,6 @@ '(aquamacs-additional-fontsets nil t) '(aquamacs-customization-version-id 211 t) '(aquamacs-tool-bar-user-customization nil t) - '(autopair-global-mode t) '(column-number-mode t) '(display-time-24hr-format t) '(display-time-day-and-date nil) @@ -142,4 +141,5 @@ '(mumamo-background-chunk-submode2 ((t nil)) t) '(mumamo-background-chunk-submode3 ((t nil)) t) '(mumamo-background-chunk-submode4 ((t nil)) t) - '(persp-selected-face ((t (:foreground "royal blue" :weight bold))))) + '(persp-selected-face ((t (:foreground "royal blue" :weight bold)))) + '(sp-pair-overlay-face ((t (:inherit nil))))) diff --git a/keybindings.el b/keybindings.el index 97292f3..954ff1f 100644 --- a/keybindings.el +++ b/keybindings.el @@ -176,6 +176,14 @@ (define-key global-map (kbd "M-p") 'move-text-up) (define-key global-map (kbd "M-n") 'move-text-down)) +;; smartparens +(when (require 'smartparens nil 'noerror) + ;; Must be set after textmate is required. + (define-key sp-keymap (kbd "M-F") 'sp-forward-symbol) + (define-key sp-keymap (kbd "M-B") 'sp-backward-symbol) + (define-key sp-keymap (kbd "C-M-f") 'sp-forward-sexp) + (define-key sp-keymap (kbd "C-M-b") 'sp-backward-sexp)) + ;; Set/increase/decrease transparency (via helpers.el) (global-set-key (kbd "C-M-|") 'transparency-set-value) (global-set-key (kbd "C-M-<") 'transparency-increase) diff --git a/mode-customizations/ruby-mode.el b/mode-customizations/ruby-mode.el index 418a070..0b37389 100644 --- a/mode-customizations/ruby-mode.el +++ b/mode-customizations/ruby-mode.el @@ -17,10 +17,6 @@ (defun customizations-for-ruby-mode () (interactive) - (when (require 'ruby-electric nil 'noerror) - (ruby-electric-mode t) - (setq ruby-electric-expand-delimiters-list (quote (124)))) - (when (require 'ruby-compilation nil 'noerror) (define-key ruby-mode-map (kbd "s-r") 'ruby-compilation-this-buffer) (define-key ruby-mode-map (kbd "C-c C-r") 'ruby-compilation-this-buffer)) diff --git a/packages.el b/packages.el index d3c1ec0..8725baa 100644 --- a/packages.el +++ b/packages.el @@ -30,7 +30,6 @@ ace-jump-mode ack-and-a-half auto-complete - autopair browse-kill-ring buffer-move coffee-mode @@ -78,10 +77,10 @@ rhtml-mode rubocop ruby-compilation - ruby-electric ruby-interpolation sass-mode scss-mode + smartparens smex smooth-scrolling stylus-mode @@ -181,8 +180,10 @@ (when (require 'workgroups2 nil 'noerror) (workgroups-mode 1)) - ;; Load ruby-electric (autoload fails) - (require 'ruby-electric) + ;; smartparens + (when (require 'smartparens nil 'noerror) + (require 'smartparens-config) + (smartparens-global-mode)) ;; Load Undo-Tree (require 'undo-tree)