[Pkg-octave-devel] Bug#253188: octave2.1: Keyword end confuses octave-mode.el

Rafael Laboissiere Rafael Laboissiere <rafael@debian.org>, 253188@bugs.debian.org
Fri, 4 Mar 2005 23:08:37 +0100


--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

* John W. Eaton <jwe@bevo.che.wisc.edu> [2004-06-07 15:18]:

> On  7-Jun-2004, Dirk Eddelbuettel <edd@debian.org> wrote:
> 
> | On Mon, Jun 07, 2004 at 03:19:10PM -0400, D. Goel wrote:
> | > Package: octave2.1
> | > Version: 2.1.57-2
> | > Severity: wishlist
> | > 
> | > When i use a keyword end when referring to matrix entries, example,
> | > data(2:end), octave-mode.el takes that "end" to end the block and
> | > spoils the indentation going forward.
> | > 
> | > Perhaps the block-end-regexp could use [^:]end instead of end ...
> | 
> | Fair point. Could you possibly prepare a patch?
> 
> You will also need to pay attention to things like "(end" or ",end"
> except the latter is valid in contexts other than indexing
> expressions, so doing it right will probably require more than a
> regexp.
> 
> Also, this should only be a problem with "end", since the other endXXX
> keywords can't be confused.  That's another good reason to use the
> more specific keywords when writing Octave code.

I am trying to clean up the bug record for the octave package in Debian and
I am resurecting this old discussion.  I agree with John that the problem
cannot be easily fixed with a mere regexp.  Also, I agree that people
writing Octave code should stick to the endXXX keywords.  

Therefore, I have a concrete proposal to "fix" the problem reported here
once and forever. The patch attached below drops "end" from the
octave-end-keywords variable, keeping it in octave-reserved-words though.
Furthermore, it drops "end" from the list of closing statements in
octave-block-match-alist.

I hope this patch will be suitable upstream.

-- 
Rafael

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="octave-mod.el-patch"

--- octave-mod.el-orig	2005-03-04 22:51:04.000000000 +0100
+++ octave-mod.el	2005-03-04 22:50:39.000000000 +0100
@@ -106,14 +106,14 @@
 (defvar octave-else-keywords
   '("case" "catch" "else" "elseif" "otherwise" "unwind_protect_cleanup"))
 (defvar octave-end-keywords
-  '("end" "endfor" "endfunction" "endif" "endswitch" "end_try_catch"
+  '("endfor" "endfunction" "endif" "endswitch" "end_try_catch"
     "end_unwind_protect" "endwhile" "until"))
 
 (defvar octave-reserved-words
   (append octave-begin-keywords
 	  octave-else-keywords
 	  octave-end-keywords
-	  '("all_va_args" "break" "continue" "global" "gplot" "gsplot"
+	  '("all_va_args" "break" "continue" "end" "global" "gplot" "gsplot"
 	    "replot" "return"))
   "Reserved words in Octave.")
 
@@ -356,14 +356,14 @@
   (concat octave-block-else-regexp "\\|" octave-block-end-regexp))
 (defvar octave-block-match-alist
   '(("do" . ("until"))
-    ("for" . ("end" "endfor"))
-    ("function" . ("end" "endfunction"))
-    ("if" . ("else" "elseif" "end" "endif"))
-    ("switch" . ("case" "otherwise" "end" "endswitch"))
-    ("try" . ("catch" "end" "end_try_catch"))
-    ("unwind_protect" . ("unwind_protect_cleanup" "end"
+    ("for" . ("endfor"))
+    ("function" . ("endfunction"))
+    ("if" . ("else" "elseif" "endif"))
+    ("switch" . ("case" "otherwise" "endswitch"))
+    ("try" . ("catch" "end_try_catch"))
+    ("unwind_protect" . ("unwind_protect_cleanup"
 			 "end_unwind_protect"))
-    ("while" . ("end" "endwhile")))
+    ("while" . ("endwhile")))
   "Alist with Octave's matching block keywords.
 Has Octave's begin keywords as keys and a list of the matching else or
 end keywords as associated values.")

--J2SCkAp4GZ/dPZZf--