GNU bug report logs - #6869
Octave mode: incorrect "unbalanced block" warning

Previous Next

Package: emacs;

Reported by: "Sprague, Webb (OFM)" <Webb.Sprague <at> ofm.wa.gov>

Date: Tue, 17 Aug 2010 00:01:01 UTC

Severity: normal

Fixed in version 24.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 6869 <at> debbugs.gnu.org (full text, mbox):

From: "Sprague, Webb (OFM)" <Webb.Sprague <at> ofm.wa.gov>
To: "Stefan Monnier" <monnier <at> iro.umontreal.ca>
Cc: 6869 <at> debbugs.gnu.org
Subject: RE: bug#6869: Octave mode: incorrect "unbalanced block" warning
Date: Tue, 17 Aug 2010 08:34:35 -0700
Hi Stefan.  See below...
 
> It's a bug in octave's indentation code, indeed.  It gets confused by
> the "end" in the following line:
> 
> >   x = data(:,2:end);

Oh -- that makes sense.

> 
> I don't know Octave much, as it so happens but I've recently been
> playing with a new indentation code for Octave (using SMIE), so I'm
> interested in fixing it.  Could you explain to me what is this "end"
> (and more generally what the "data(:,2:end)" means: all I can guess is
> that it's an array indexing of some sort).

There are two uses for "end" that are pretty different:

  1. Closing blocks (e.g. "if x==1 y=3 end")

  2. Indexing arrays. Here "end" is evaluated to give the length of a
dimension in the array. For example  if x=[2 3 4 5], then x(end) == 5,
x(end-1) == 4, etc.  

Note that ":" means all elements when evaluated as an index, and "x:y"
gives the vector of elements between x and y, and "3:end" means [3 4 5
... end] where end is the max index.  So, "data(:,2:end)" means all the
rows of data (the first ":") and the columns from 2 to the end.

Does that make sense?
	
If you really want to learn octave and don't have much experience with
matlab I would suggest Attaway's book on matlab.  Octave tracks it
pretty closely.

Thanks so much for dealing with this!  I sort of have my hands full, and
emacs indentation code just freaks me out ;)




This bug report was last modified 14 years and 247 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.