[Emacs-ada-mode] Ada 2005 feature: extended return statement
Stephen Leake
Stephe.Leake at nasa.gov
Sun Oct 12 03:19:00 PDT 2008
deadlyhead <deadlyhead at deadlyhead.com> writes:
> What is the status of Ada 2005 support in ada-mode?
Somewhat ad-hoc. AdaCore added some stuff, I've added more. But there
has been no attempt to be exhaustive.
> Attempting to type in the return statement triggers an error from ada-mode:
>
> Missing 'accept' in front of 'do'
Thanks for the example. I've now fixed it in my local code. I'll post
a new version of Ada mode soon.
I have used an extended return statement; apparently I didn't try to
add anything after it.
> This prevents me from actually entering in a new line after end return;,
> which can be gotten around, but is annoying. :-/
Right.
> I'm currently running the version of ada-mode off of the web site,
> version 3.9. I understand that you have version 4.0 available via Emacs
> CVS, and that you're planning to update the site with this version,
> too. Does 4.0 have support for extended returns?
It does now :).
> I've gone digging through the source of ada-mode.el a bit, but haven't
> quite wrapped my head around where all of the decisions for word
> ordering, indentation, etc, are made, so I'm hesitant to just start
> hacking, especially without the latest version of the code.
Yes, it's quite convoluted.
> If you have any suggestions on understanding how this code works,
> though, I'm willing to try adding extended returns to it, though.
I found the problem by using edebug to trace thru the indentation
code, using your example. But I've done this several times before;
it's much more confusing the first time :)
If you are up to applying patches, here's the fix (should work with
3.9):
--- a/emacs_stephe_site_lisp/ada-mode.el
+++ b/emacs_stephe_site_lisp/ada-mode.el
@@ -2872,12 +2872,15 @@
(forward-word 1)
(ada-goto-next-non-ws)
(cond
- ((looking-at "\\<\\(loop\\|select\\|if\\|case\\)\\>")
+ ;;
+ ;; loop/select/if/case/return
+ ;;
+ ((looking-at "\\<\\(loop\\|select\\|if\\|case\\|return\\)\\>")
(save-excursion (ada-check-matching-start (match-string 0)))
(list (save-excursion (back-to-indentation) (point)) 0))
;;
- ;; loop/select/if/case/record/select
+ ;; record
;;
((looking-at "\\<record\\>")
(save-excursion
@@ -3930,13 +3933,12 @@
(goto-char (match-beginning 0)))
;;
- ;; found 'do' => skip back to 'accept'
+ ;; found 'do' => skip back to 'accept' or 'return'
;;
((looking-at "do")
(unless (ada-search-ignore-string-comment
- "accept" t nil nil
- 'word-search-backward)
- (error "Missing 'accept' in front of 'do'"))))
+ "\\<accept\\|return\\>" t)
+ (error "Missing 'accept' or 'return' in front of 'do'"))))
(point))
(if noerror
--
-- Stephe
More information about the Emacs-ada-mode
mailing list