branch: elpa/nix-mode commit 23bdbdf21fa17c31204d063bec2edd6270c9fca8 Author: Matthew Bauer <mjbaue...@gmail.com> Commit: Matthew Bauer <mjbaue...@gmail.com>
Add custom mmm-mode --- nix-mode.el | 2 ++ nix-sh.el | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/nix-mode.el b/nix-mode.el index c6f3b81db2..4a3bc0bd94 100644 --- a/nix-mode.el +++ b/nix-mode.el @@ -399,6 +399,8 @@ (when (require 'company nil 'noerror) (require 'nix-company nil 'noerror)) +(when (require 'mmm-mode nil 'noerror) (require 'nix-sh nil 'noerror)) + ;;;###autoload (define-derived-mode nix-mode prog-mode "Nix" "Major mode for editing Nix expressions. diff --git a/nix-sh.el b/nix-sh.el new file mode 100644 index 0000000000..6953290b18 --- /dev/null +++ b/nix-sh.el @@ -0,0 +1,27 @@ +(require 'mmm-auto) + +(defun nix-sh-extra-phases (name) + (list (concat name "Phase") (concat "pre" (capitalize name)) + (concat "post" (capitalize name)))) + +(let* ((nix-sh-all-phases + (apply #'append + (mapcar 'nix-sh-extra-phases + '("unpack" "patch" "configure" "build" + "check" "install" "fixup" + "dist")))) + (nix-sh-start-regexp + (concat (mmm-regexp-opt nix-sh-all-phases t) " = ''"))) + (mmm-add-group 'nix-sh + '((sh-command + :submode sh-mode + :face mmm-code-submode-face + :front "buildPhase = ''" + :back "''" + ))) + ) + +(mmm-add-mode-ext-class 'nix-mode "\\.nix\\'" 'nix-sh) + +(provide 'nix-sh) +;;; nix-mode-mmm.el ends here