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

Specifying regions in mmm-mode with start and end index and avoid parse #97

Open
cjohansson opened this issue Jul 31, 2019 · 7 comments

Comments

@cjohansson
Copy link

I would like to be able to use mmm-mode with my major mode phps-mode, in phps-mode I automatically get regions specified where inline code (HTML, XML, etc) can be used based on semantic lexer tokens with start and end character indexes of the current buffer, this means there is no need for mmm-mode to parse the buffer in any way.

Is there a way I can send regions to mmm-mode manually and prevent it from parsing the buffer?

Ideally I would like phps-mode as primary mode and then web-mode as mode for the inline areas of a phps-mode buffer. After that I would like css-mode and js2-mode to trigger based on regex regions in web-mode

@dgutov
Copy link
Owner

dgutov commented Jul 31, 2019

You can try using mmm-make-region, I think.

Another option would be to save some parsing information in the buffer via text properties. Then define the submodes using FRONT and BACK with function values. Said functions can search for the aforementioned text properties.

@cjohansson
Copy link
Author

Ok thanks will try using that function

@cjohansson
Copy link
Author

Ok it works but I get a warning: Invalid or undefined submode class: phps-web, it is possible to avoid it?

This is my code:

(setq phps-mode-inline-mmm-submode 'web-mode)
(mmm-add-mode-ext-class 'phps-mode nil 'phps-web)

;; The lexer does this
(when (and (boundp 'phps-mode-inline-mmm-submode)
               phps-mode-inline-mmm-submode
               (fboundp 'mmm-make-region))
      (mmm-make-region phps-mode-inline-mmm-submode start end))

@dgutov
Copy link
Owner

dgutov commented Nov 6, 2019

Try using t instead.

If CLASS
is the symbol t, MMM Mode is turned on in all buffers matching MODE
and EXT, but no classes are activated.

@cjohansson
Copy link
Author

Another error

  overlay-start(nil)
  whitespace-point--flush-used(350)
  font-lock-fontify-keywords-region(1 350 nil)
  font-lock-default-fontify-region(1 350 nil)
  #f(compiled-function (reg) #<bytecode 0x1ff3b8c7d599>)((1 350 nil))
  mapc(#f(compiled-function (reg) #<bytecode 0x1ff3b8c7d599>) ((1 350 nil)))
  mmm-fontify-region-list(phps-mode ((1 350 nil)))
  #f(compiled-function (elt) #<bytecode 0x1ff3b8c7d52d>)((phps-mode (1 350 nil)))
  mapc(#f(compiled-function (elt) #<bytecode 0x1ff3b8c7d52d>) ((phps-mode (1 350 nil))))
  mmm-fontify-region(1 350 nil)
  font-lock-fontify-region(1 350)
  mmm-refontify-maybe(1 350)
  mmm-apply-all()
  mmm-mode-on()
  mmm-make-region(web-mode 234 350)
  (progn (mmm-make-region phps-mode-inline-mmm-submode start end))
  (if (and (equal token 'T_INLINE_HTML) phps-mode-inline-mmm-submode (fboundp 'mmm-make-region)) (progn (mmm-make-region phps-mode-inline-mmm-submode start end)))
  phps-mode-lexer-RETURN_TOKEN(T_INLINE_HTML 234 350)

@dgutov
Copy link
Owner

dgutov commented Nov 7, 2019

Try disabling whitespace-mode? I'm not quite sure what would make it work in this situation.

@cjohansson
Copy link
Author

cjohansson commented Nov 7, 2019

Yes that seemed to resolve that issue, will dig further.. it seems to work with whitespace-mode as well.. Maybe it was a one time error

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

2 participants