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

emacs-26.3 more mmm-vars.el for C mode #116

Open
kuszmaul opened this issue Sep 8, 2020 · 7 comments
Open

emacs-26.3 more mmm-vars.el for C mode #116

kuszmaul opened this issue Sep 8, 2020 · 7 comments

Comments

@kuszmaul
Copy link

kuszmaul commented Sep 8, 2020

These variables seem necessary to get C mode to work inside mmm.

git diff
diff --git a/mmm-vars.el b/mmm-vars.el
index 00478eb..9d04636 100644
--- a/mmm-vars.el
+++ b/mmm-vars.el
@@ -184,6 +184,7 @@
 	 c-comment-prefix-regexp
 	 c-comment-start-regexp
 	 c-cpp-defined-fns
+	 c-cpp-expr-functions-key
 	 c-current-comment-prefix
 	 c-decl-block-key
          c-decl-hangon-key
@@ -196,6 +197,7 @@
 	 c-expr-kwds
 	 c-file-offsets
 	 c-file-style
+	 c-found-types
          c-not-primitive-type-keywords-regexp
 	 c-hanging-braces-alist
 	 c-hanging-colons-alist
@@ -223,8 +225,10 @@
 	 c-lambda-kwds
          c-literal-start-regexp
 	 c-macro-with-semi-re
+	 c-make-top-level-key
          ;; c-make-top-level-key
          ;; c-make-top-level-kwds
+	 c-noise-macro-with-parens-name-re
          c-nonlabel-token-key
          c-nonlabel-token-2-key
          c-nonsymbol-chars
@@ -258,6 +262,7 @@
 	 c-other-decl-block-kwds
 	 c-other-decl-kwds
 	 c-overloadable-operators-regexp
+	 c-pack-key
          c-paragraph-separate
          c-paragraph-start
          c-paren-stmt-key
@@ -286,6 +291,7 @@
          c-syntactic-ws-start
          c-type-decl-prefix-key
          c-type-decl-suffix-key
+	 c-type-decl-suffix-ws-ids-key
 	 c-type-prefix-key
          c-typeof-key
          c-prefix-spec-kwds-re
@dgutov
Copy link
Owner

dgutov commented Sep 8, 2020

Thanks!

Does it actually work for you with these changes?

With C mode as the primary mode or a submode?

@kuszmaul
Copy link
Author

kuszmaul commented Sep 8, 2020

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

@kuszmaul
Copy link
Author

kuszmaul commented Sep 8, 2020

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

@dgutov
Copy link
Owner

dgutov commented Sep 8, 2020

Is that like CWeb? See mmm-cweb.el and the comments at the bottom.

@dgutov
Copy link
Owner

dgutov commented Sep 8, 2020

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.

@kuszmaul
Copy link
Author

kuszmaul commented Sep 8, 2020

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.

dgutov added a commit that referenced this issue Sep 8, 2020
@dgutov
Copy link
Owner

dgutov commented Sep 8, 2020

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?

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