web-mode
August 15, 2023 |
emacs
emacs mode #
for editing , and many other formats
Debugging #
Issue: while using replace feature, it was just changing first instance and the replace session was stoping #
error: “Match data clobbered by buffer modification hooks”
Solution: #
- was not good solution because this disable all the change hook in buffer unintended conseqeunce: when a line is commented it’s face won’t change.
(setq inhibit-modification-hooks nil);; If this variable is non-nil, all of the change hooks are disabled; none of them run.
- I was using this package “auto-rename-tag”, with following configs:
(add-hook 'web-mode-hook 'auto-rename-tag-mode) ;; Auto-start on any web modes
#+begin_src elisp
(use-package auto-rename-tag
:ensure t
:hook
(web-mode-hook . auto-rename-tag-mode))
This mode’s hook was causing the clobber.
Indentation #
While working with on , his preffered coding convention was to use spaces instead of tabs. Web mode indetation is by default 4, made it to 2 to avoid format changes on every change.
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
smartparens and web-mode curly braces conflict #
solved this by adding an extra “space”
;; let smartparens mode take of this
(require 'smartparens)
;; https://smartparens.readthedocs.io/en/latest/pair-management.html
(sp-pair "%" "%" :wrap "C-%")
(sp-pair "<" ">" :wrap "C->")
(sp-pair "%" " %")
(sp-pair "" " ")