dgutov / mmm-mode

New official home for mmm-mode, fixed for Emacs >= 23
http://mmm-mode.sourceforge.net/
GNU General Public License v2.0
333 stars 31 forks source link

Cannot make it work #76

Open xahon opened 7 years ago

xahon commented 7 years ago

I've tried to make styled-components syntax inside .js[x]? file

Here is my function for that

(use-package mmm-mode
  :config
  (require 'mmm-auto)
  (require 'mmm-vars)
  (require 'css-mode)

  (setq mmm-global-mode 'maybe)

  (mmm-add-classes
   '((js-styled-components
      :submode css-mode
      :front "styled[.\\|(]\\{1\\}[^`]+`"
      :back "[\t]*`")))

  (mmm-add-mode-ext-class 'rjsx-mode nil 'js-styled-components)
  (mmm-add-mode-ext-class 'js2-jsx-mode nil 'js-styled-components))

It should look like that (css syntax inside js file between "styled.[^`]`" and "\s`") image

Tried to set less-css-mode and sass-mode instead of css-mode Tried to use not only css props, but css classes .someclass { ... } Regex is working well according to regex-builder Tried to swap front and back according to #72 issue I'm sure that js2-jsx-mode is enabled in buffer and tried to change to rjsx-mode

dgutov commented 7 years ago

js2-mode doesn't work well with mmm-mode. In particular, it fontifies the strings contents outside of the font-lock framework.

You can try this with js-mode as the primary mode, for comparison.

xahon commented 7 years ago

@dgutov js-mode not working

xahon commented 7 years ago

rjsx-mode too

dgutov commented 7 years ago

jsx-mode is based on js2-mode. js-mode works here.

xahon commented 7 years ago

@dgutov can you share your config i could test?