# HG changeset patch # User jwe # Date 857499652 0 # Node ID d21505cbcc58f325b0bdc21cbd43d2916a80f3a3 # Parent 650ab15f89547bbe1e69c2993868c93436566d26 [project @ 1997-03-04 18:20:51 by jwe] diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 4 12:19:24 1997 John W. Eaton + + * emacs/octave-mod.el: Update from Kurt Hornik to handle switch + statement. + Mon Mar 3 15:44:42 1997 John W. Eaton * dlfcn/Makefile.in (DISTFILES): Add ftp-site. diff --git a/emacs/octave-mod.el b/emacs/octave-mod.el --- a/emacs/octave-mod.el +++ b/emacs/octave-mod.el @@ -100,7 +100,9 @@ "end_unwind_protect" "endwhile")) (defvar octave-reserved-words - (append octave-begin-keywords octave-else-keywords octave-end-keywords + (append octave-begin-keywords + octave-else-keywords + octave-end-keywords '("all_va_args" "break" "continue" "global" "gplot" "gsplot" "replot" "return")) "Reserved words in Octave.") @@ -323,7 +325,7 @@ '(("for" . ("end" "endfor")) ("function" . ("end" "endfunction")) ("if" . ("else" "elseif" "end" "endif")) - ("switch" . ("end" "endswitch")) + ("switch" . ("case" "end" "endswitch" "otherwise")) ("try" . ("catch" "end" "end_try_catch")) ("unwind_protect" . ("unwind_protect_cleanup" "end" "end_unwind_protect")) @@ -623,6 +625,8 @@ (while (< (point) eol) (if (octave-not-in-string-or-comment-p) (cond + ((looking-at "\\") + (setq icol (+ icol (* 2 octave-block-offset)))) ((looking-at octave-block-begin-regexp) (setq icol (+ icol octave-block-offset))) ((looking-at octave-block-else-regexp) @@ -630,30 +634,39 @@ (setq icol (+ icol octave-block-offset)))) ((looking-at octave-block-end-regexp) (if (not (= bot (point))) - (setq icol (- icol octave-block-offset)))))) + (setq icol (- icol + (octave-block-end-offset))))))) (forward-char))) (if is-continuation-line (setq icol (+ icol octave-continuation-offset))))))) (save-excursion (back-to-indentation) (cond - ((and (or (looking-at octave-block-else-regexp) - (looking-at octave-block-end-regexp)) + ((and (looking-at octave-block-else-regexp) (octave-not-in-string-or-comment-p)) (setq icol (- icol octave-block-offset))) + ((and (looking-at octave-block-end-regexp) + (octave-not-in-string-or-comment-p)) + (setq icol (- icol (octave-block-end-offset)))) ((looking-at "\\s<\\s<\\s<\\S<") (setq icol (list 0 icol))) ((looking-at "\\s<\\S<") (setq icol (list comment-column icol))))) icol)) +(defun octave-block-end-offset () + (save-excursion + (octave-backward-up-block 1) + (* octave-block-offset + (if (string-match (match-string 0) "switch") 2 1)))) + (defun octave-comment-indent () (if (looking-at "\\s<\\s<\\s<") 0 (if (looking-at "\\s<\\s<") (calculate-octave-indent) (skip-syntax-backward " ") - (max (if (bolp) 0 (+ (current-column))) + (max (if (bolp) 0 (+ 1 (current-column))) comment-column)))) (defun octave-indent-for-comment ()