Re: Different comment syntaxes in within the same buffer?

Stefan Monnier via Users list for the GNU Emacs text editor <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> I would like to ask the Lispers here whether there is a good solution
> for having different comment syntaxes in the same buffer depending on
> the point's position. For more context, a lot of web templating
> languages (e.g., Svelte, Astro) have multiple syntaxes in the same file.
> For example, Astro filles have a "frontmatter" section where JavaScript
> can go, then after the frontmatter section goes CSS and/or HTML.

Presumably you'd like Emacs to handle correctly not just the comments
but also the highlighting of the rest, as well as the indentation,
etc...

IOW, you need a major mode that understands that the file is split into
several sub parts each one using a different major mode.
AKA "multi major modes".

There are various packages that provide solutions for that, such as
`mmm-mode` and `polymode`.

The built-in `mhtml-mode` also does it for the specific case of HTML
files including CSS and Javascript elements.


=== Stefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.