Re: [PATCH] doc/gitattributes: add Octave
- From
LI, BO XUAN <liboxuan@connect.hku.hk>
- Date
- May 11, 2019, 02:36 UTC
- Message-ID
- <CALM0=-mTLakSBW67vqHNX84p=uw990QDbpeUfh1HKq9N0CiiLA@mail.gmail.com>
- In-Reply-To
- <87woixx556.fsf@evledraar.gmail.com>
On Sat, May 11, 2019 at 7:26 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 38 quoted lines
> > > On Fri, May 10 2019, Boxuan Li wrote: > > > `matlab` pattern is also suitable for source code > > in the GNU Octave language. > > > > Signed-off-by: Boxuan Li <liboxuan@connect.hku.hk> > > --- > > Documentation/gitattributes.txt | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt > > index 4fb20cd0e9..1b28381bda 100644 > > --- a/Documentation/gitattributes.txt > > +++ b/Documentation/gitattributes.txt > > @@ -819,7 +819,7 @@ patterns are available: > > > > - `java` suitable for source code in the Java language. > > > > -- `matlab` suitable for source code in the MATLAB language. > > +- `matlab` suitable for source code in the MATLAB/Octave language. > > > > - `objc` suitable for source code in the Objective-C language. > > I've never used either, but browsing our patterns I see: > > "^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$", > > I.e. that last bit matches ^%%, and then here: > https://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB > > MATLAB uses the percent sign '%' to begin a comment. Octave uses > both the hash symbol # and the percent sign % interchangeably. > > So here we have the "function" pattern matching a comment, right? (this > doesn't have any tests) and we'd want to add "#" to Octave, but not > MATLAB.
Thanks, that's a great catch! Actually, '%%' is used to start a code section in Matlab (https://www.mathworks.com/help/matlab/matlab_prog/run-sections-of-programs.html), while Octave uses both '%%' and '##' (https://octave.org/doc/interpreter/Sections.html).
> > I see both tend to use the ".m" extension. Anyway, isn't it better to > add an "octave" pattern, and document that they're mostly the same
I agree. I'll send an updated patch soon.
> (although it looks like we can add #-comments, to future-proof > ourselves?