[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Identification string for Octave script detection in VIM
From: |
Mike Miller |
Subject: |
Re: Identification string for Octave script detection in VIM |
Date: |
Sun, 15 Apr 2012 12:54:05 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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
Re: Identification string for Octave script detection in VIM, Jordi Gutiérrez Hermoso, 2012/04/17