tanishk56bisht · 2022-06-18 11:25
I added this code in config.el file
(defun my-hook()
(setq emmet-preview-mode t))
(add-hook 'web-mode-hook 'my-hook)
When I open a html file the Emmet preview mode doesn't work although I know it has been enabled because when i do M-x emmet-preview-mode the mini buffer says that emmet-preview-mode has been disabled.
And when i do M-x emmet-preview-mode again, the buffer says it has been enabled and surprisingly it's working just the way it should
Help plz
igorepst · 2022-06-18 12:21
As you use `M-x` to toggle the mode, this is a function, and not a variable. So use `(emmet-preview-mode 1)` in your hook, instead of `setq`
tanishk56bisht · 2022-06-18 13:10
I tried this
But when I open the html file an error pops up saying:
Error (web-mode-hook): error running hook "my-hook" because: (void-function Emmet-preview-mode)
igorepst · 2022-06-18 17:16
I imagine you use [this plugin](https://github.com/smihica/emmet-mode/blob/master/emmet-mode.el), as this is what is linked from [the official site](https://emmet.io/download/). As the minor mode for preview is not autoloaded, you need to require `emmet` in your hook, as described in the repo, e. g. add `(require 'emmet-mode)` before enabling preview in the hook. In addition, in your comment `emmet` starts with the capital letter. Are you sure in the code it is written right?