From: Ted Zlatanov <tzz@lifelogs.com>
To: Tim Chambers <tim.chambers@viavisolutions.com>
Cc: Tim Chambers <tbc@alum.mit.edu>, 23762@debbugs.gnu.org
Subject: bug#23762: [PATCH] * lisp/generic-x.el (ansible-inventory-generic-mode): New mode. (generic-unix-modes): Add it.
Date: Tue, 14 Jun 2016 12:43:54 -0400 [thread overview]
Message-ID: <87twgvoh4l.fsf@lifelogs.com> (raw)
In-Reply-To: <20160613170940.13268-1-tim.chambers@viavisolutions.com> (Tim Chambers's message of "Mon, 13 Jun 2016 11:09:40 -0600")
[-- Attachment #1: Type: text/plain, Size: 267 bytes --]
Hi Tim,
please see attached for a slightly improved patch:
* fixes syntax error
* highlights variables and values correctly (see screenshot)
* leading space for section and host names is OK
* imenu adjusted accordingly as well
Let me know what you think. Thanks!
[-- Attachment #2: ansible generic inventory screenshot_2016-06-14_12-40-30.png --]
[-- Type: image/png, Size: 29976 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-lisp-generic-x.el-ansible-inventory-generic-mode-with-vars.patch --]
[-- Type: text/x-diff, Size: 1531 bytes --]
commit da2b5fa1f76d98d6656d77196f54c23358d231cc
Author: Tim Chambers <tbc@alum.mit.edu>
Date: Sat Jun 11 23:13:40 2016 -0600
* lisp/generic-x.el (ansible-inventory-generic-mode): New mode. (generic-unix-modes): Add it.
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index 71ba1f7..bd0d831 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -215,6 +215,7 @@ generic-mswindows-modes
(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 @@ alias-generic-mode
'((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)
next prev parent reply other threads:[~2016-06-14 16:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 17:09 bug#23762: [PATCH] * lisp/generic-x.el (ansible-inventory-generic-mode): New mode. (generic-unix-modes): Add it Tim Chambers
2016-06-14 16:43 ` Ted Zlatanov [this message]
2016-06-14 19:26 ` Tim Chambers
2016-06-15 13:36 ` Ted Zlatanov
2016-06-15 20:02 ` Tim Chambers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87twgvoh4l.fsf@lifelogs.com \
--to=tzz@lifelogs.com \
--cc=23762@debbugs.gnu.org \
--cc=tbc@alum.mit.edu \
--cc=tim.chambers@viavisolutions.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.