2

I'm looking for a multiple-major-modes package that doesn't remove fontification of the host mode from its inner submodes?

I tried MMM Mode and Polymode, but they remove the initial fontification and put own faces with own background colors in regions with submodes.

What I'm trying to achieve is to fontify diff hunks in diff-mode syntactically according to the rules of their source code language, e.g. to highlight their keywords like it's done on diff pages of version control web sites like github/gitlab.

multiple-major-modes packages are able to detect diff hunks and their source language from file extensions in the diff header, find the corresponding major mode using auto-mode-alist, and fontify these diff hunks accordingly as submodes. But they don't keep fontification of diff-mode with faces diff-added and diff-removed that highlight changes using different background colors.

Is there a package that can do this?

3

This is implemented now in Emacs 27 and available by default using the variable diff-font-lock-syntax.

  • Could you expand your answer to show how to configure it? – Dan Dec 25 '18 at 20:39
  • Actually there is no need to configure it, because it's enabled by default. – link0ff Dec 25 '18 at 21:03
  • Great! Could you just add that point to your answer for future readers? – Dan Dec 25 '18 at 21:28

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.