From b28d3ff3f2cb4d38580693e93a86a0205b7927f1 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 21 Apr 2015 21:40:14 +0200 Subject: [PATCH] Add section about electric pairing --- emacs/.emacs.d/init.el | 10 +++---- emacs/.emacs.d/init.org | 64 +++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index c3c7d9e..e804dec 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -1295,7 +1295,6 @@ from myaethon2.core.decorators import ( (add-hook 'gnus-exit-group-hook 'awesome-update-current-mailbox) (add-hook 'gnus-exit-gnus-hook 'awesome-update-current-mailbox) (add-hook 'haskell-mode-hook 'oni:haskell-mode-func) -(add-hook 'java-mode-hook #'electric-pair-local-mode) (add-hook 'outline-minor-mode-hook #'oni:set-tab-maybe-toggle-outline) (add-hook 'scheme-mode-hook (lambda () (setq ac-sources '(ac-source-geiser)))) (add-hook 'slime-mode-hook #'set-up-slime-ac) @@ -1322,8 +1321,7 @@ from myaethon2.core.decorators import ( 'clojure-mode-hook 'geiser-repl-mode-hook 'sawfish-mode-hook 'scheme-mode-hook) -(oni:add-hooks 'c-mode-hook - #'oni:c-mode-func #'electric-pair-local-mode) +(oni:add-hooks 'c-mode-hook #'oni:c-mode-func) (oni:add-hooks 'emacs-lisp-mode-hook (lambda () @@ -1364,14 +1362,14 @@ from myaethon2.core.decorators import ( #'oni:reset-default-directory) (oni:add-hooks 'js2-mode-hook - #'tern-mode #'moz-minor-mode #'electric-pair-local-mode) + #'tern-mode #'moz-minor-mode) (oni:add-hooks 'lisp-mode-hook (lambda () (setf ac-sources '(ac-source-slime-simple))) #'oni:set-emacs-lisp-symbols #'paredit-mode #'hl-sexp-mode) (oni:add-hooks 'lua-mode-hook - #'oni:lua-mode-func #'flycheck-mode #'electric-pair-local-mode) + #'oni:lua-mode-func #'flycheck-mode) (oni:add-hooks 'markdown-mode-hook #'whitespace-mode #'oni:markdown-mode-func) @@ -1387,7 +1385,7 @@ from myaethon2.core.decorators import ( (lambda () (setq ac-sources '(ac-source-jedi-direct))) #'oni:set-python-symbols #'flycheck-mode #'whitespace-mode #'oni:python-mode-func #'oni:set-python-imenu-function - #'jedi:setup #'subword-mode #'electric-pair-local-mode) + #'jedi:setup #'subword-mode) (oni:add-hooks 'slime-repl-mode-hook #'paredit-mode #'set-up-slime-ac #'hl-sexp-mode) diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index 5fb32b6..6c53232 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -1028,12 +1028,6 @@ ** SCSS - - Automatically match parentheses and other delimiters. - - #+BEGIN_SRC emacs-lisp - (add-hook 'scss-mode-hook #'electric-pair-local-mode) - #+END_SRC - - Enable auto-completion #+BEGIN_SRC emacs-lisp @@ -1052,12 +1046,6 @@ ** Haml - - Automatically match parentheses and other delimiters. - - #+BEGIN_SRC emacs-lisp - (add-hook 'haml-mode-hook #'electric-pair-local-mode) - #+END_SRC - - Check syntax on the fly #+BEGIN_SRC emacs-lisp @@ -1068,12 +1056,6 @@ ** Ruby - - Automatically match parentheses and other delimiters. - - #+BEGIN_SRC emacs-lisp - (add-hook 'ruby-mode-hook #'electric-pair-local-mode) - #+END_SRC - - Enable flycheck #+BEGIN_SRC emacs-lisp @@ -1088,14 +1070,6 @@ (setq ruby-align-chained-calls t) #+END_SRC -** Coffee - - - Automatically match parentheses and other delimiters. - - #+BEGIN_SRC emacs-lisp - (add-hook 'coffee-mode-hook #'electric-pair-local-mode) - #+END_SRC - ** PHP *** Show tabs and spaces in indent @@ -1166,14 +1140,6 @@ #+END_SRC -** CSS - - Turn on electric pair mode for CSS. - - #+BEGIN_SRC emacs-lisp - (add-hook 'css-mode-hook #'electric-pair-local-mode) - #+END_SRC - * Minor modes Emacs offers a lot of minor modes and even more can be found in the @@ -1214,6 +1180,36 @@ (add-hook 'css-mode-hook #'electric-indent-local-mode) #+END_SRC +** Electric pairing + + Electric pairing of delimiters is one of those features that is + just so essential to my feeling comfortable with an editor. Most of + the time I don't even use it, really. It's just that I'm so used to + having it and when I /do/ expect it to be there it is so frustrating + when it's not, or when it doesn't work properly. + + This functionality, much like [[Electric indent]] isn't something I + want enabled in all modes, though for different reasons, and for a + time there was only the global =electric-pair-mode=. Again I'm very + happy that a local version was added. + + The reason that I don't want it enabled for all modes is that some + modes (mostly Lisp-like language modes) have better alternatives. + But most non-Lisp-like language modes I really do need to have it. + + #+BEGIN_SRC emacs-lisp + (add-hook 'c-mode-hook #'electric-pair-local-mode) + (add-hook 'coffee-mode-hook #'electric-pair-local-mode) + (add-hook 'css-mode-hook #'electric-pair-local-mode) + (add-hook 'haml-mode-hook #'electric-pair-local-mode) + (add-hook 'java-mode-hook #'electric-pair-local-mode) + (add-hook 'js2-mode-hook #'electric-pair-local-mode) + (add-hook 'lua-mode-hook #'electric-pair-local-mode) + (add-hook 'python-mode-hook #'electric-pair-local-mode) + (add-hook 'ruby-mode-hook #'electric-pair-local-mode) + (add-hook 'scss-mode-hook #'electric-pair-local-mode) + #+END_SRC + * Load custom file I don't really use the Emacs customization interface much, but I