From 207ec885db240b24e19e4613b87e6b5665638da6 Mon Sep 17 00:00:00 2001 From: toctan Date: Sat, 14 Jun 2014 10:45:51 +0800 Subject: [PATCH] Make web-mode play nice with smartparens web-mode's auto paring is in conflict with smartparens. With smartparens, since the closing '>' is inserted right after the opening '<' and web-mode is not aware of that, the extra closing '>' would be inserted. That's very annoying. --- modules/prelude-web.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/prelude-web.el b/modules/prelude-web.el index 792ed14..a98d1b1 100644 --- a/modules/prelude-web.el +++ b/modules/prelude-web.el @@ -49,11 +49,25 @@ (eval-after-load 'web-mode '(progn (defun prelude-web-mode-defaults () - ) + ;; make web-mode play nice with smartparens + (setq web-mode-enable-auto-pairing nil) + (sp-with-modes '(web-mode) + (sp-local-pair "%" "%" + :unless '(sp-in-string-p) + :post-handlers '(((lambda (&rest _ignored) + (just-one-space) + (save-excursion (insert " "))) + "SPC" "=" "#"))) + (sp-local-pair "<% " " %>" :insert "C-c %") + (sp-local-pair "<%= " " %>" :insert "C-c =") + (sp-local-pair "<%# " " %>" :insert "C-c #") + (sp-local-tag "%" "<% " " %>") + (sp-local-tag "=" "<%= " " %>") + (sp-local-tag "#" "<%# " " %>"))) (setq prelude-web-mode-hook 'prelude-web-mode-defaults) (add-hook 'web-mode-hook (lambda () - (run-hooks 'prelude-web-mode-hook))))) + (run-hooks 'prelude-web-mode-hook))))) (provide 'prelude-web) ;;; prelude-web.el ends here