[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 'end' odds & ends
From: |
John W. Eaton |
Subject: |
Re: 'end' odds & ends |
Date: |
Thu, 10 Feb 2005 14:07:31 -0500 |
On 10-Feb-2005, address@hidden <address@hidden> wrote:
| Well, I'd argue that both those examples you gave have round parentheses
| around the "end" statements. Analogous to "if", as opposed to "if and
| only if", I'm not requiring there be nothing else inside of those round
| parentheses. Expanding the definition, can you now think of a case where
| "end" used as an index will not have parentheses around it?
There are lots of things you have to watch out for if you really want
to get it right. But if you are writing Octave code and only use
"end" for indexing and never as an end-of-block token (always
prefering "endfor", "endif", etc.) then you could add something like
the following to your .emacs file:
(add-hook
'octave-mode-hook
(lambda ()
(setq octave-end-keywords
'("endfor" "endfunction" "endif" "endswitch" "end_try_catch"
"end_unwind_protect" "endwhile" "until"))
(setq octave-block-end-regexp
(concat "\\<\\("
(mapconcat 'identity octave-end-keywords "\\|")
"\\)\\>"))
(setq octave-block-begin-or-end-regexp
(concat octave-block-begin-regexp "\\|" octave-block-end-regexp))
(setq octave-block-else-or-end-regexp
(concat octave-block-else-regexp "\\|" octave-block-end-regexp))
(setq octave-block-match-alist
'(("do" . ("until"))
("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" . ("endwhile"))))))
All this does is tell Emacs that it should not consider "end" by
itself to be an end-of-block keyword.
jwe