emmet-mode
emmet-mode copied to clipboard
Readd emmet-expand-jsx-className or alternative variable
Hi. I use Emmet mode with web-mode and JSX. I always used (setq-local emmet-expand-jsx-className? t)
from a custom web-mode hook that checks the file extension for "jsx" or "tsx" to get className= instead of class=. The new approach of emmet-jsx-major-modes
doesn't work well with web-mode + JSX, because the major mode is always web-mode
for both HTML as JSX/TSX files. Is there any workaround for this, or a way to bring a variable like emmet-expand-jsx-className back?
Any fix?
I found a work around for this.
emmet-mode
uses a functions to check if major-mode is a jsx supported mode.
I updated that function to also compare buffer-file extension.
Replace the function definition in emmet-mode.el
and byte-compile the file with M-x byte-recompile-file
.
(defun emmet-jsx-supported-mode? ()
"Is the current mode we're on enabled for jsx class attribute expansion?"
(or (member (file-name-extension buffer-file-name) '("jsx" "tsx"))
(member major-mode emmet-jsx-major-modes)))
Had to do a similar thing:
(defun emmet-jsx-supported-mode? ()
"Is the current mode we're on enabled for jsx class attribute expansion?"
(or (member major-mode emmet-jsx-major-modes)
(and (string= major-mode "web-mode") (string= web-mode-content-type "jsx"))))
Would be nice addition if we had the ability to extend that function. Something like:
(defun emmet-jsx-supported-mode? ()
"Is the current mode we're on enabled for jsx class attribute expansion?"
(or (member major-mode emmet-jsx-major-modes)
(emmet-jsx-supported-func)))
(defcustom emmet-jsx-support-func nil
"User defined custom that returns `t` if jsx support should be enabled, and `nil` for not"
)