简体   繁体   中英

In emacs, how do I force certain characters to act as end of statement delineators?

I've created a new major mode derived from cc-mode, because I'm using a meta-language that is mostly C-like, but is parsed to generate code automatically.

Say I have something like this:

struct MyNewStruct
{
    int newInt = 32;
    {
        [flag, different-flag]
        string newString = "foo";
    }
}

I need the ']' character to effectively be equivalent to the ; or the next line, declaring the string, doesn't indent properly.

I've tried using Mx modify-syntax-entry for ']' and making it both a closing character as well as a punctuation character (according to the GNU manual on syntax tables), but it doesn't look like it's allowed to belong to two character classes simultaneously (unless one of those character classes is a comment). (And if it's just a punctuation character, that causes other problems.)

I can't change the grammar of the meta-language, so adding a semicolon after the close bracket isn't possible.

In this case, the real answer was to pick something that was syntactically closer to my meta-language. csharp-mode already parses the brackets correctly and marks sections enclosed in brackets as statements, not statement-cont.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM