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

Emacs 25 and objc-mode inside auctex #68

Open oguibe opened 7 years ago

oguibe commented 7 years ago

Hello

First I am totally incompetent about lisp. In fact I am trying to adapt asy-mode (from the Asymptote distribution) with mmm-mode. asy-mode contains a lasy-mode which gives with two-mode.el the possibility to have highlight asymptote code into a LaTeX file. Since it seems that two-mode does not work with emacs 24 or emacs 25, or at least that the two proposed modifications produce error with auctex+asy-mode, I tried mmm-mode.

Asy-mode is based on objc-mode. If I add asy-mode to the variable mmm-c-derived-modes it seems to be ok with Emacs 24. It is a good news.

But with Emacs 25 I remarked a difference behavior which is not related to asy-mode. For example the following LaTeX code which contains objc code is not highlighted (the above part) due to the only to for (...) part (another objc code is ok)

\documentclass[12pt]{article}
\usepackage{lmodern}
\begin{document}
\begin{code}
  for(int i=0; i< 10 ; i++)
  {
    }
\end{code}
\end{document}

Here my configuration (in fact I am using spacemacs)

(setq mmm-global-mode 'maybe)
(setq mmm-submode-decoration-level 2)
(mmm-add-classes
  '((mmm-objc-latex
    :submode objc-mode
    :front "^\\\\begin{code}\n"
    :back "^\\\\end{code}"
  )))
(mmm-add-mode-ext-class 'latex-mode nil 'mmm-objc-latex)

Is related to cc-mode, mmm-mode or auctex ?

Regards O.G.

dgutov commented 7 years ago

A good way to investigate such problems is to evaluate

(font-lock-fontify-region (point-min) (point-max))

It gives a backtrace, and the first time I tried it it led to a variable we needed to save and set in CC Mode subregions (see the linked commit). But that led to a second backtrace which I don't have enough energy to decipher.

Either way, CC Mode has very poor compatibility with mmm-mode, among other things, because of how it treats narrowing. Try using js-mode instead of objc-mode. The former is not very strict about syntax, and it should give you decent experience.

oguibe commented 7 years ago

Many thanks for you kind answer. Since I am not able to understand the message of (font-lock-fontify-region (point-min) (point-max)) I will follow your advice : js-mode.