]> git.eshelyaron.com Git - emacs.git/commitdiff
Add new ansible-inventory-generic-mode (Bug#23762)
authorTim Chambers <tbc@alum.mit.edu>
Sun, 12 Jun 2016 05:13:40 +0000 (23:13 -0600)
committerTed Zlatanov <tzz@lifelogs.com>
Wed, 15 Jun 2016 13:31:12 +0000 (09:31 -0400)
* lisp/generic-x.el (ansible-inventory-generic-mode): Add new mode.

Copyright-paperwork-exempt: yes

lisp/generic-x.el

index 71ba1f7d002e2eb4556006d26ef4f59b76263e70..bd0d8318859ef35f15fd1f4007c2a4ee39d204db 100644 (file)
@@ -215,6 +215,7 @@ This hook will be installed if the variable
 
 (defconst generic-unix-modes
   '(alias-generic-mode
+    ansible-inventory-generic-mode
     etc-fstab-generic-mode
     etc-modules-conf-generic-mode
     etc-passwd-generic-mode
@@ -646,6 +647,26 @@ like an INI file.  You can add this hook to `find-file-hook'."
            '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
   "Generic mode for C Shell alias files."))
 
+;; Ansible inventory files
+(when (memq 'ansible-inventory-generic-mode generic-extras-enable-list)
+
+(define-generic-mode ansible-inventory-generic-mode
+  '(?#)
+  nil
+  '(("^\\s-*\\(\\[.*\\]\\)" 1 font-lock-constant-face)
+    ("^\\s-*\\([^ \n\r]*\\)" 1 font-lock-function-name-face)
+    ("\\([^ =\n\r]+\\)=\\([^ \n\r]*\\)"
+     (1 font-lock-variable-name-face)
+     (2 font-lock-keyword-face)))
+  '("inventory")
+  (list
+   (function
+    (lambda ()
+      (setq imenu-generic-expression
+           '((nil "^\\s-*\\[\\(.*\\)\\]" 1)
+             ("*Variables*" "\\s-+\\([^ =\n\r]+\\)=" 1))))))
+  "Generic mode for Ansible inventory files."))
+
 ;;; Windows RC files
 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
 (when (memq 'rc-generic-mode generic-extras-enable-list)