forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hamzehn
committed
Apr 29, 2024
1 parent
1263d32
commit f46a42d
Showing
1 changed file
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,40 @@ | ||
;;; init-html.el --- Editing HTML -*- lexical-binding: t -*- | ||
;; init-html.el --- Editing HTML -*- lexical-binding: t -*- | ||
;;; Commentary: | ||
|
||
;; ERB is configured separately in init-ruby | ||
|
||
;;; Code: | ||
|
||
(require-package 'tagedit) | ||
(with-eval-after-load 'sgml-mode | ||
(tagedit-add-paredit-like-keybindings) | ||
(define-key tagedit-mode-map (kbd "M-?") nil) | ||
(define-key tagedit-mode-map (kbd "M-s") nil) | ||
(add-hook 'sgml-mode-hook (lambda () (tagedit-mode 1)))) | ||
(require 'sgml-mode) | ||
|
||
(add-auto-mode 'html-mode "\\.\\(jsp\\|tmpl\\)\\'") | ||
(when (maybe-require-package 'web-mode) | ||
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) | ||
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) | ||
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode)) | ||
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode)) | ||
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) | ||
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) | ||
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)) | ||
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))) | ||
|
||
|
||
(with-eval-after-load 'web-mode | ||
(setq web-mode-markup-indent-offset 2)) | ||
|
||
(defun my/enable-minor-mode (my-pair) | ||
"Enable minor mode if filename match the regexp. MY-PAIR is a cons cell (regexp . minor-mode)." | ||
(if (buffer-file-name) | ||
(if (string-match (car my-pair) buffer-file-name) | ||
(funcall (cdr my-pair))))) | ||
|
||
(when (maybe-require-package 'prettier-js) | ||
(add-hook 'web-mode-hook #'(lambda () | ||
(my/enable-minor-mode | ||
'("\\.html?\\'" . prettier-js-mode))))) | ||
|
||
(defun my/turn-on-sgml-electric-tag-pair-mode () | ||
(sgml-electric-tag-pair-mode 1)) | ||
(add-hook 'web-mode-hook 'my/turn-on-sgml-electric-tag-pair-mode) | ||
|
||
(provide 'init-html) | ||
;;; init-html.el ends here |