octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Identification string for Octave script detection in VIM


From: Júlio Hoffimann
Subject: Re: Identification string for Octave script detection in VIM
Date: Sun, 15 Apr 2012 14:02:54 -0300

Hi Mike,

I think the big problem for VIM devs is having to treat the exceptional case for Octave/MATLAB distinction. I also prefer the additional variable on .vimrc, since i'm not a MATLAB programmer. :-)

I'm just trying to find a common viable solution for both communities, Bram just purposed the string identification, but nothing is certain yet. By the way, i think -*-octave-*- is a better string.

Regards,
Júlio.

2012/4/15 Mike Miller <address@hidden>
On Sun, Apr 15, 2012 at 01:18:27PM -0300, Júlio Hoffimann wrote:
> Dear all,
>
> I've being contacting VIM developers to add Rik's octave.vim syntax to the
> official VIM distribution. The problem we face is that (as we all know) GNU
> Octave scripts tries to be as compatible as possible with MATLAB scripts,
> making the automatic filetype detection impossible.
>
> In VIM, files are generally identified by extensions (*.m) and comment
> symbols (%), but both interpreters share the same patterns. Although Octave
> supports # and the shebang mechanism, it's not good practice use them if we
> are looking for portability.
>
> I heard Perl and Prolog suffered from the same issue in the past because
> their file extension, the solution VIM developers had at that time was to
> add an additional variable to set the preference of the user on .vimrc. The
> problem with that approach is that some users programmed in both languages
> and have to set the configurations over and over again is not desired.
> Having said that, Bram (The Man - Creator of VIM) purposed define an
> identification string for Octave scripts such that in the end the following
> pseudo-code would apply when opening *.m files:
>
> if (filename matches *.m)
>   if (comment_symbol == '#' || script_last_line == '% OctScript')
>     filetype=octave
>   else
>     filetype=matlab
>
> 1. What do you think?

I'm a die-hard Vim user and I love it when everything works magically in
Vim.  However, I don't like this solution, if I read you right.  I think
it puts an unnecessary burden on the authors of Octave scripts just to
get the filetype detection right in one particular editor.

> 2. Any proposals for the identification string?
> 3. `OctScript' is okay? I invented. :-)

What is the downside of detecting based on the presence of a #-style
comment?  Ignoring the obvious case of an Octave script that does not
use #-style comments :)

I would personally not find it too inconvenient to have one filetype be
the default for *.m files, configurable as you mention above, and maybe
set up my own key mapping to toggle between the two.

--
mike


reply via email to

[Prev in Thread] Current Thread [Next in Thread]