From f73e348534a05754216df310580fe6e1e166f338 Mon Sep 17 00:00:00 2001 From: toctan Date: Sat, 14 Jun 2014 10:29:27 +0800 Subject: [PATCH 1/2] Remove web-mode customization - Code indent offset is subjected to personal taste, I think we should stick to the web-mode default, which is sensible enough, and leave it to the user to decide. - `web-mode-disable-autocompletion` is no longer used by web-mode. - As to `newline-and-indent`, I think we should be consistent across all major modes. And this line of code will become useless with Emacs 24.4. --- modules/prelude-web.el | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/prelude-web.el b/modules/prelude-web.el index 0a0062b..792ed14 100644 --- a/modules/prelude-web.el +++ b/modules/prelude-web.el @@ -49,12 +49,7 @@ (eval-after-load 'web-mode '(progn (defun prelude-web-mode-defaults () - ;; Customizations - (setq web-mode-markup-indent-offset 4) - (setq web-mode-css-indent-offset 2) - (setq web-mode-code-indent-offset 4) - (setq web-mode-disable-autocompletion t) - (local-set-key (kbd "RET") 'newline-and-indent)) + ) (setq prelude-web-mode-hook 'prelude-web-mode-defaults) (add-hook 'web-mode-hook (lambda () From 207ec885db240b24e19e4613b87e6b5665638da6 Mon Sep 17 00:00:00 2001 From: toctan Date: Sat, 14 Jun 2014 10:45:51 +0800 Subject: [PATCH 2/2] 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