unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23762: [PATCH] * lisp/generic-x.el (ansible-inventory-generic-mode): New mode. (generic-unix-modes): Add it.
@ 2016-06-13 17:09 Tim Chambers
  2016-06-14 16:43 ` Ted Zlatanov
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Chambers @ 2016-06-13 17:09 UTC (permalink / raw)
  To: 23762; +Cc: Tim Chambers

From: Tim Chambers <tbc@alum.mit.edu>

---
 lisp/generic-x.el | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index 71ba1f7..bedb100 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -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,25 @@ 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
+  '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face)
+    ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
+     (1 font-lock-function-name-face)
+     (2 font-lock-variable-name-face)))
+  '("inventory")
+  (list
+   (function
+    (lambda ()
+      (setq imenu-generic-expression
+	    '((nil "^\\[\\(.*\\)\\]" 1)
+	      ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 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)
-- 
1.9.1






^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#23762: [PATCH] * lisp/generic-x.el (ansible-inventory-generic-mode): New mode. (generic-unix-modes): Add it.
  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
  2016-06-14 19:26   ` Tim Chambers
  0 siblings, 1 reply; 5+ messages in thread
From: Ted Zlatanov @ 2016-06-14 16:43 UTC (permalink / raw)
  To: Tim Chambers; +Cc: Tim Chambers, 23762

[-- 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)

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#23762: [PATCH] * lisp/generic-x.el (ansible-inventory-generic-mode): New mode. (generic-unix-modes): Add it.
  2016-06-14 16:43 ` Ted Zlatanov
@ 2016-06-14 19:26   ` Tim Chambers
  2016-06-15 13:36     ` Ted Zlatanov
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Chambers @ 2016-06-14 19:26 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: 23762

Hi Ted,

I'd like to see your patch accepted instead of mine.

Thanks for the improvements!

— Tim





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#23762: [PATCH] * lisp/generic-x.el (ansible-inventory-generic-mode): New mode. (generic-unix-modes): Add it.
  2016-06-14 19:26   ` Tim Chambers
@ 2016-06-15 13:36     ` Ted Zlatanov
  2016-06-15 20:02       ` Tim Chambers
  0 siblings, 1 reply; 5+ messages in thread
From: Ted Zlatanov @ 2016-06-15 13:36 UTC (permalink / raw)
  To: Tim Chambers; +Cc: 23762-done

On Tue, 14 Jun 2016 13:26:47 -0600 Tim Chambers <tbc@alum.mit.edu> wrote: 

TC> I'd like to see your patch accepted instead of mine.

All right, it's in master (won't be in the next release because of the
feature freeze). Since it was a tiny change I marked is as
copyright-exempt and edited the commit message slightly. Thanks for your
contribution!

Ted





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#23762: [PATCH] * lisp/generic-x.el (ansible-inventory-generic-mode): New mode. (generic-unix-modes): Add it.
  2016-06-15 13:36     ` Ted Zlatanov
@ 2016-06-15 20:02       ` Tim Chambers
  0 siblings, 0 replies; 5+ messages in thread
From: Tim Chambers @ 2016-06-15 20:02 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: 23762-done

> All right, it's in master

Haha. I happened to be scanning Gmane early this morning and noticed
the commit [1]. As for the feature freeze, no worries. I'm quite happy
to wait. It's in the repo for anyone to patch. I've already applied it
for myself. Who knows? I may have more patches to it before the
unfreeze.

> I marked is as copyright-exempt

I concur. I'd like to work harder before doing the paperwork to assign
copyright. :)

> Thanks for your contribution!

Ted, it's been my dream to contribute to Emacs. Thank _you_ for
Twenty-four years ago I announced a package I called bufset [2], and
RMS tracked down my work number and called me with an offer to include
it. He wanted changes, though. Back then I had a one-year-old and was
consumed with my family and my day-job. I don't regret turning down
Richard. I dumped that package after deciding I liked bookmarks
better. Sorry if this sounds like a silly award acceptance speech, but
I want to mark this humble milestone because it means that much to me,
closing the loop after nearly a quarter century. And I'm determined to
use this experience to keep up my involvement after my last false
start [3]. A dream is a goal with a deadline, and I thank _you_ for
lighting a fire under me [4]. That's all it took for me to turn my
dream into a goal. Three times was a charm in my case. Now I need to
make a new goal for myself.

There's a method to my madness, rambling on like this. Ted, I’d like
to buy you a beverage of your choice next time we meet face to face
[5]. Really. And for you, a Duvel [7] if you so desire. I live in
Colorado and am open to driving to meet you if you happen to be
traveling through the state. My son and daughter-in-law live in
Arlington, MA. We visit them every so often, and I'll ping you next
time I'm out there.

My offer extends to the first person other than you, Ted, who reads
this. To that future reader, I'd like to buy you a beverage, too! [5]
Just contact me and refer to this page. That's all it takes. (Well,
besides us being able to be in the same place at the same time. :)
This is a sort of hobby of mine [7]. (Bcc'ing Drew to remind him I
still owe him a Duvel. Now I know what that is [6].)

— Tim

[1] http://article.gmane.org/gmane.emacs.diffs/135994
[2] 1fm44kINNghk@hp-col.col.hp.com
https://groups.google.com/forum/#!searchin/comp.editors/bufset/comp.editors/EPKRoYbGjjY/1UWmBtJPq68J
[3] http://lists.gnu.org/archive/html/emacs-devel/2014-08/msg00424.html
[4] https://groups.google.com/d/msg/ansible-devel/sdVE11c6OC8/khtQU-D3AgAJ
[5] Within reason. No premium aged scotch, no champagne from
Champagne, no Belgian Chimay beer, no Kopi Luwak. I trust you get the
idea.
[6] https://goo.gl/photos/puN9gMGdpcD2k1YL8
[7] https://www.emacswiki.org/emacs/tbc





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-15 20:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2016-06-14 19:26   ` Tim Chambers
2016-06-15 13:36     ` Ted Zlatanov
2016-06-15 20:02       ` Tim Chambers

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).