[Pacemaker] Syntax highlighting in vim for crm configure edit

Dejan Muhamedagic dejanmm at fastmail.fm
Tue Dec 13 10:19:36 EST 2011


On Fri, Dec 09, 2011 at 11:38:22AM +0200, Dan Frincu wrote:
> Hi,
> 
[...]
> > Just tried it out, and when I do :set filetype=pcmk, vim spews at
> > me this:
> >
> > Error detected while processing /usr/share/vim/vim72/syntax/synload.vim:
> > line   58:
> > E127: Cannot redefine function <SNR>3_SynSet: It is in use
> > E127: Cannot redefine function <SNR>3_SynSet: It is in use
> > E127: Cannot redefine function <SNR>3_SynSet: It is in use
> > E127: Cannot redefine function <SNR>3_SynSet: It is in use
> > Error detected while processing /usr/share/vim/vim72/syntax/nosyntax.vim:
> > line   21:
> > E218: autocommand nesting too deep
> > Error detected while processing /usr/share/vim/vim72/syntax/synload.vim:
> > line   58:
> > E127: Cannot redefine function <SNR>3_SynSet: It is in use
> > Error detected while processing /usr/share/vim/vim72/syntax/syntax.vim:
> > line   40:
> > E218: autocommand nesting too deep
> >
> > BTW, I just copied the pcmk.vim file to ~/.vim/syntax.
> >
> 
> Well, first of all, the patch was meant to be applied to the source, I
> did not mention this before. To apply it on the running system just
> use the patch from http://pastebin.com/PWpuzQ4m
> 
> The patch also assumes the pcmk.vim file is copied to
> /usr/share/vim/vim72/syntax/pcmk.vim

What happens when vim 7.3 is released or with installations
which are still running 7.1? So, how do we package pcmk.vim?

> If not the path must be adjusted to match the location of pcmk.vim.

Which path and where?

> Then when opening crm configure edit the syntax highlighting is
> applied. You're test and the respective errors come from not applying
> the patch.

As I said above (or perhaps I didn't :), I just used vi to open
a file, i.e. no crm involved.

What confuses me how would a user with no root privileges do
filetype detection and syntax highlighting.

> > Otherwise, the output looks fine. There are a few differences to
> > the configure show output:
> >
> > - quotes are red along with the value
> > - ids are green whereas in configure show they are normal
> > - id references are light blue and in configure show they are green
> > - scores are red and in configure show violet
> > - roles/actions in constraints red and in configure show normal
> >
> > There are probably a few more differences.
> >
> 
> Indeed, not perfect, however it's better than nothing and could be
> improved over time.

Why not fix it right away?

Cheers,

Dejan

> Regards,
> Dan
> 
> > Cheers,
> >
> > Dejan
> >
> >
> >> Regards,
> >> Dan
> >>
> >> p.s.: many thanks to everyone for the input received on IRC.
> >>
> >> >
> >> > thanks,
> >> > raoul
> >> > --
> >> > ____________________________________________________________________
> >> > DI (FH) Raoul Bhatia M.Sc.          email.          r.bhatia at ipax.at
> >> > Technischer Leiter
> >> >
> >> > IPAX - Aloy Bhatia Hava OG          web.          http://www.ipax.at
> >> > Barawitzkagasse 10/2/2/11           email.            office at ipax.at
> >> > 1190 Wien                           tel.               +43 1 3670030
> >> > FN 277995t HG Wien                  fax.            +43 1 3670030 15
> >> > ____________________________________________________________________
> >> >
> >>
> >>
> >>
> >> --
> >> Dan Frincu
> >> CCNA, RHCE
> >
> >> From d3ab2ab159137b271382db8d0edeef6d69325894 Mon Sep 17 00:00:00 2001
> >> From: =?UTF-8?q?Dan=20Fr=C3=AEncu?= <df.cluster at gmail.com>
> >> Date: Tue, 22 Nov 2011 18:50:10 +0200
> >> Subject: [PATCH][BUILD] Low: extra: Add syntax highlighting for crm configure edit
> >> MIME-Version: 1.0
> >> Content-Type: text/plain; charset=UTF-8
> >> Content-Transfer-Encoding: 8bit
> >>
> >>
> >> Signed-off-by: Dan Frîncu <df.cluster at gmail.com>
> >> ---
> >>  shell/modules/cibconfig.py |    1 +
> >>  shell/modules/utils.py     |    7 +++++--
> >>  2 files changed, 6 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/shell/modules/cibconfig.py b/shell/modules/cibconfig.py
> >> index 9cc9751..49b4b51 100644
> >> --- a/shell/modules/cibconfig.py
> >> +++ b/shell/modules/cibconfig.py
> >> @@ -128,6 +128,7 @@ class CibObjectSet(object):
> >>              except IOError, msg:
> >>                  common_err(msg)
> >>                  break
> >> +            s += "\n# vim: set filetype=.pcmk :\n"
> >>              s = ''.join(f)
> >>              f.close()
> >>              if hash(s) == filehash: # file unchanged
> >> diff --git a/shell/modules/utils.py b/shell/modules/utils.py
> >> index b57aa54..00013c6 100644
> >> --- a/shell/modules/utils.py
> >> +++ b/shell/modules/utils.py
> >> @@ -158,7 +158,7 @@ def str2tmp(s):
> >>      Write the given string to a temporary file. Return the name
> >>      of the file.
> >>      '''
> >> -    fd,tmp = mkstemp()
> >> +    fd,tmp = mkstemp(suffix=".pcmk")
> >>      try: f = os.fdopen(fd,"w")
> >>      except IOError, msg:
> >>          common_err(msg)
> >> @@ -317,7 +317,10 @@ def edit_file(fname):
> >>          return
> >>      if not user_prefs.editor:
> >>          return
> >> -    return ext_cmd("%s %s" % (user_prefs.editor,fname))
> >> +    if user_prefs.editor == "vim" or user_prefs.editor == "vi":
> >> +        return ext_cmd("%s %s -u /usr/share/vim/vim72/syntax/pcmk.vim" % (user_prefs.editor,fname))
> >> +    else:
> >> +        return ext_cmd("%s %s" % (user_prefs.editor,fname))
> >>
> >>  def page_string(s):
> >>      'Write string through a pager.'
> >> --
> >> 1.7.0.4
> >>
> >
> >
> >> _______________________________________________
> >> Pacemaker mailing list: Pacemaker at oss.clusterlabs.org
> >> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> >>
> >> Project Home: http://www.clusterlabs.org
> >> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> >> Bugs: http://bugs.clusterlabs.org
> >
> >
> > _______________________________________________
> > Pacemaker mailing list: Pacemaker at oss.clusterlabs.org
> > http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> >
> > Project Home: http://www.clusterlabs.org
> > Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> > Bugs: http://bugs.clusterlabs.org
> 
> 
> 
> -- 
> Dan Frincu
> CCNA, RHCE
> 
> _______________________________________________
> Pacemaker mailing list: Pacemaker at oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> 
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://bugs.clusterlabs.org




More information about the Pacemaker mailing list