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

Handling of functions like (bobp) in c-mode derived major modes (csharp-mode) #96

Open
Ruin0x11 opened this issue Jun 3, 2019 · 1 comment

Comments

@Ruin0x11
Copy link

Ruin0x11 commented Jun 3, 2019

I'm trying to use mmm-mode in a language with embedded C# blocks. Since csharp-mode is derived from c-mode it fails to parse because it calls c-state-pp-to-literal which depends on the value of (bobp). But (bobp) returns nil even though the fontify function starts at the beginning of the C# region. If there is a C# using directive at the beginning of the embedded region then mmm-mode-idle-reparse will constantly throw errors on every edit command and nothing gets fontified. It also prevents insertion of text sometimes, eventually forcing me to disable it.

Also mmm-derived-c-modes doesn't contain csharp-mode, but adding it doesn't seem to change anything. Strangely c-mode itself doesn't throw any errors so I'll use it in the meantime.

This example is enough to reproduce the error.

#CS
using System;
#ENDCS
(mmm-add-classes
 '((embedded-csharp
    :submode csharp-mode
    :delimiter-mode nil
    :front "^#CS\n"
    :back "^#ENDCS$")))
@dgutov
Copy link
Owner

dgutov commented Jun 3, 2019

CC Mode is tricky. Fontification should happen inside a narrowing (where (bobp) returns t), but maybe some of CC Mode's functions populates the same cache and is called outside of a narrowing. It might take a fair amount of work to track it down, and honestly I would not recommend it, because IME even c-mode doesn't work well with MMM. So if it does work, maybe it's good enough.

You can try to report this problem to the csharp-mode devevloper, though. If c-mode doesn't use bobp, why should csharp-mode do that?

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