Open kuszmaul opened 4 years ago
Thanks!
Does it actually work for you with these changes?
With C mode as the primary mode or a submode?
latex as the primary mode, C++ as the submode. It works, but I cannot claim that I tested it extensively.
I'm included to follow the advice I just saw elsewhere and just go to js-mode, however. It seems like the C engine is going to be a problem forever...
Perhaps it would be good to include documentation to the effect, and also show how to use latex lstlisting.
(mmm-add-classes '((lstlisting-c++
:submode js-mode
:front "^\\\\begin{lstlisting}"
:back "^\\\\end{lstlisting}"
:front-offset (end-of-line 1)
:back-offset (beginning-of-line -1))))
(mmm-add-mode-ext-class 'latex-mode nil 'lstlisting-c++)
Is that like CWeb? See mmm-cweb.el
and the comments at the bottom.
latex as the primary mode, C++ as the submode. It works, but I cannot claim that I tested it extensively.
Thanks. That's good enough for me. If it breaks later (again), it breaks, but why not make this small effort, especially since you have already come up with the list.
Is that like CWeb? See
mmm-cweb.el
and the comments at the bottom.
I'm not sure. The lstlisting environment is one of the two main ways that people write code in latex. (The other way is minted, which is about the same. You write things like
-*- mode: latex -*
The defintion of the $n$th fibonacci number is
\[ \mbox{fib}(n) = \left{ \begin{array}{ll}
n & \mbox{if $n \leq 2$,}
\mbox{fib}(n-1) + \mbox{fib}(n-2) &\mbox{otherwise.}
\end{array} \right. \]
which you can implement in C as
\begin{lstlisting}
int fib(int n) {
if (n <= 2) return n;
else return fib(n-1)+fib(n-2);
}
\end{lstlisting}
No guarantees that that code will compile. I just wrote it.
Perhaps it would be good to include documentation to the effect, and also show how to use latex lstlisting
Not sure what's a good place for that, though. mmm-sample.el
?
These variables seem necessary to get C mode to work inside mmm.