Two small syntax highlighting patches

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Two small syntax highlighting patches

Maxime Henrion
        Hello guys,



Here are two little patches to fix minor problems I have been
experiencing with syntax highlighting and that I've been wanting to fix
for years (especially the patch to sh.vim).

The patch to xf86conf.vim makes it recognize "Extensions" as a valid
section.  This section is only used in Xorg configuration files, not in
XFree86 configuration files.  Maybe I should have made it conditional on
something?

The second patch is for sh.vim and looks like it could lead to a "hot"
dicussion...  There's a five years old comment telling that by consensus
of vimdev'ers, arithmetic expansion (ie $((2 + 2)) ) as well as the
less common form for command substitution (ie $(ls) instead of `ls`) are
flagged as errors in /bin/sh files because they are supposedly not
supported by sh.  Both syntaxes are however perfectly correct, widely
used and both are documented in SUSv3.  My patch just makes those
syntaxes valid again for plain sh files.

The patch should be attached to this mail, and has been generated
against CVS this morning.

Cheers,
Maxime

vim.patch (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Two small syntax highlighting patches

Bram Moolenaar

Maxime Henrion wrote:

> Here are two little patches to fix minor problems I have been
> experiencing with syntax highlighting and that I've been wanting to fix
> for years (especially the patch to sh.vim).
>
> The patch to xf86conf.vim makes it recognize "Extensions" as a valid
> section.  This section is only used in Xorg configuration files, not in
> XFree86 configuration files.  Maybe I should have made it conditional on
> something?
>
> The second patch is for sh.vim and looks like it could lead to a "hot"
> dicussion...  There's a five years old comment telling that by consensus
> of vimdev'ers, arithmetic expansion (ie $((2 + 2)) ) as well as the
> less common form for command substitution (ie $(ls) instead of `ls`) are
> flagged as errors in /bin/sh files because they are supposedly not
> supported by sh.  Both syntaxes are however perfectly correct, widely
> used and both are documented in SUSv3.  My patch just makes those
> syntaxes valid again for plain sh files.
>
> The patch should be attached to this mail, and has been generated
> against CVS this morning.

Did you also send the patch to the syntax file maintainers?

--
For society, it's probably a good thing that engineers value function over
appearance.  For example, you wouldn't want engineers to build nuclear power
plants that only _look_ like they would keep all the radiation inside.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: Two small syntax highlighting patches

Charles E Campbell Jr
In reply to this post by Maxime Henrion
Quoting Maxime Henrion <[hidden email]>:

> The second patch is for sh.vim and looks like it could lead to a "hot"
> dicussion...  There's a five years old comment telling that by consensus
> of vimdev'ers, arithmetic expansion (ie $((2 + 2)) ) as well as the
> less common form for command substitution (ie $(ls) instead of `ls`) are
> flagged as errors in /bin/sh files because they are supposedly not
> supported by sh.  Both syntaxes are however perfectly correct, widely
> used and both are documented in SUSv3.  My patch just makes those
> syntaxes valid again for plain sh files.

The default sh.vim highlighting is for Bourne shell; not Posix, not Korn, not
Bash.  It turns out that many Posix machines' /bin/sh is actually Korn
shell.  If folks want Kornshell highlighting for these masquerades, the
documented solution (:help sh-syntax) is available: put

   let is_kornshell=1

in your <.vimrc>.

I also get email from those who have bash masquerading as /bin/sh, including
the receipt of patches to "fix things".  They appear to be about as adamant
about it as the Posix/Kornshell types, by the way.  To "fix" things up for
this, simply put

   let is_bash=1

in your <.vimrc>, again, as documented.

So, I intend to continue being ornery (as perceived by both groups) and
to continue letting /bin/sh be assumed to be Bourne shell as it has been.

I'm a "is_kornshell=1" type, myself, BTW.

Regards,
Charles E. Campbell, Jr.
Reply | Threaded
Open this post in threaded view
|

RE: Two small syntax highlighting patches

Zdenek Sekera-2
>
> The default sh.vim highlighting is for Bourne shell; not
> Posix, not Korn, not Bash.  It turns out that many Posix
> machines' /bin/sh is actually Korn shell.

If only it was ksh, but more often than not it is 'pdksh',
looks like ksh but it isn't...

>    let is_kornshell=1
>    let is_bash=1

These are very good solutions.
 
> I'm a "is_kornshell=1" type, myself, BTW.

So am I.

---Zdenek

Reply | Threaded
Open this post in threaded view
|

Re: Two small syntax highlighting patches

Maxime Henrion
In reply to this post by Bram Moolenaar
Bram Moolenaar wrote:

>
> Maxime Henrion wrote:
>
> > Here are two little patches to fix minor problems I have been
> > experiencing with syntax highlighting and that I've been wanting to fix
> > for years (especially the patch to sh.vim).
> >
> > The patch to xf86conf.vim makes it recognize "Extensions" as a valid
> > section.  This section is only used in Xorg configuration files, not in
> > XFree86 configuration files.  Maybe I should have made it conditional on
> > something?
> >
> > The second patch is for sh.vim and looks like it could lead to a "hot"
> > dicussion...  There's a five years old comment telling that by consensus
> > of vimdev'ers, arithmetic expansion (ie $((2 + 2)) ) as well as the
> > less common form for command substitution (ie $(ls) instead of `ls`) are
> > flagged as errors in /bin/sh files because they are supposedly not
> > supported by sh.  Both syntaxes are however perfectly correct, widely
> > used and both are documented in SUSv3.  My patch just makes those
> > syntaxes valid again for plain sh files.
> >
> > The patch should be attached to this mail, and has been generated
> > against CVS this morning.
>
> Did you also send the patch to the syntax file maintainers?

I didn't realize there were maintainers for each file.  I'm going to
mail them now, thanks.

Cheers,
Maxime