all repos — nixfiles @ 3e15bd32d236180ba5fa5ce5da083d538791a608

System and user configuration, managed by nix and home-manager

Emacs: Add mmm-mode for SQL inside PHP

…assuming I got the regex right.
Alan Pearce alan@alanpearce.co.uk
Thu, 10 Jul 2014 22:05:45 +0100
commit

3e15bd32d236180ba5fa5ce5da083d538791a608

parent

8c6c7cdc4c5397d9704b168e93021248f57fdf77

2 files changed, 19 insertions(+), 0 deletions(-)

jump to
M tag-emacs/emacs.d/Casktag-emacs/emacs.d/Cask
@@ -45,6 +45,7 @@ (depends-on "litable") (depends-on "lua-mode")
 (depends-on "magit")
 (depends-on "markdown-mode")
+(depends-on "mmm-mode")
 (depends-on "move-text")
 (depends-on "multi-term")
 (depends-on "multiple-cursors")
M tag-emacs/emacs.d/init.eltag-emacs/emacs.d/init.el
@@ -1063,6 +1063,24 @@ web-mode-script-padding 0                 web-mode-comment-style 2
                 web-mode-disable-auto-pairing t))
 
+(req-package mmm-auto
+  :config (progn
+            (defvar php-sql-mmm-submode-enabled nil)
+            (defun php-sql-mmm-submode ()
+              "Provides a very minimal embedding of SQL in PHP, via mmm-mode."
+              (interactive)
+              (when (not php-sql-mmm-submode-enabled)
+                (set-face-background 'mmm-default-submode-face nil)
+                (mmm-add-classes
+                 '((php-sql
+                    :submode sql-mode
+                    :front "\\($\\(sql\\|query\\)\\s-*=\\s-*[\"']\\|<<<SQL\\)"
+                    :back "\\([\"']\\|SQL\\);?"
+                    :face mmm-code-submode-face)))
+                (mmm-add-mode-ext-class 'php-mode "\\.php$" 'php-sql)
+                (setq php-sql-mmm-submode-enabled t))))
+  :init (setq 'mmm-global-mode 'maybe))
+
 ;;;; Windows & Frames
 
 (setq frame-title-format