Search code examples
pythonemacssalt-project

Saltstack mode for emacs


How can I get Emacs to work with Salt files? Is there some code already available, or how can I create a mode myself?

There's a Sublime Text plugin that does something similar.

Thanks


Solution

  • The sublime text config you linked to appears to just use a YAML mode, so you could do the same thing using the yaml-mode available for Emacs:

    (add-to-list 'auto-mode-alist '("\\.sls\\'" . yaml-mode))
    

    or if you wanted to incorporate the tab settings from that sublime config, you could create a new mode like so:

    (require 'yaml-mode)
    
    (define-derived-mode saltstack-mode yaml-mode "Saltstack"
      "Minimal Saltstack mode, based on `yaml-mode'."
      (setq tab-width 2
            indent-tabs-mode nil))
    
    (add-to-list 'auto-mode-alist '("\\.sls\\'" . saltstack-mode))
    

    (n.b. untested)