I'm new to emacs, does anybody know is there a way to combine xml-mode and sql-mode so SQL code inside tags can be highlighted and proper indent?


<FnTable ID="MyCode">

  declare @ID bigint = @p0

  select * from Company.Table where ID = @ID 



Your question qualifies as duplicate of that question about "Multiple major modes in one buffer". Therefore it should be closed.

Nevertheless, since you are new to Emacs I give you below a modified version of the code block from the accepted answer of the duplicate that should solve your problem. Copy that code block into your init file, which is most often one of ~/.emacs or ~/.emacs.d/init.el.

If you use that code block make sure that you have installed mmm-mode. You can check or run the installation of mmm-mode with the menu item Options->Manage Emacs Packages. See the manual page about Emacs packages for other ways of managing packages.

(require 'mmm-auto)
    :submode sql-mode
    :face mmm-default-submode-face
    :front "<FnTable\\( ID=\".*\"\\)?>\n"
    :back "</FnTable>\n")))

(setq mmm-global-mode 'maybe)
(mmm-add-mode-ext-class 'nxml-mode nil 'nxml-sql)
| improve this answer | |

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