A programming language that I use lets me format comments and docstrings using markdown, and then export my code and documentation to PDF.

When I edit the file, though, Emacs doesn't see comments as markdown; just as plain boring text.

I would like to access the full power of markdown-mode when I edit comments, without giving up the nice features of my programming languages' major mode outside of comments. How can I do this?

(A similar problem would include using a Javadoc specific mode map and syntax highlighting inside of Javadoc comments, for example)

  • I'm open to better tagging; mmm-mode doesn't seem to exist – Clément Jun 22 '15 at 17:54

You can use poporg for this. People mostly use it to edit comments in Org mode, but you can use whatever mode you want by setting poporg-edit-hook.

(remove-hook 'poporg-edit-hook 'org-mode)
(add-hook 'poporg-edit-hook 'markdown-mode)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.