Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readd emmet-expand-jsx-className or alternative variable #138

Open
rikberkelder opened this issue Dec 4, 2021 · 3 comments
Open

Readd emmet-expand-jsx-className or alternative variable #138

rikberkelder opened this issue Dec 4, 2021 · 3 comments

Comments

@rikberkelder
Copy link

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?

@anhsirk0
Copy link

Any fix?

@anhsirk0
Copy link

anhsirk0 commented Sep 29, 2023

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)))

@gopar
Copy link

gopar commented Apr 29, 2024

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"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants