[Emacs-ada-mode] ada-mode: ada-indent-region failure
Stephen Leake
stephen_leake at stephe-leake.org
Wed Sep 19 04:41:00 PDT 2007
Pierre-Louis Escouflaire <pierre-louis.escouflaire at eurocontrol.int> writes:
> Hello,
>
> We have probably encountered a bug in ada-mode related to the function
> ada-indent-region. This bug seems to appear when a comment is inserted
> between a label and its associated instruction.
>
> I have attached a file for test purpose.
> Note that the bug only has been noticed for labels on 'declare' blocks.
> Note that the bug also appears during editing (on "end My_Label;").
> ^
> On the closing semi-colon (;), that is to say here!
You have not said exactly how to reproduce the problem; what keys do
you type, and where is point?
You have also not said what version of Emacs and Ada mode you are
using.
So I played around a bit, and here is what I get. I'm using Emacs
22.1, with Ada mode from my CVS (somewhat improved from the website):
Place point on line after 'Label_With_Inbetween_Comment;'
type TAB
That gives an error:
if: Matching defun has different name: fail
On the other hand, placing point on the line after 'Another_Label;'
does not give the error.
The problem is that ada-check-matching-start does not skip the
comment.
Here's a patch:
diff -u -r1.32 ada-mode.el
--- ada-mode.el 19 Sep 2007 11:37:04 -0000 1.32
+++ ada-mode.el 19 Sep 2007 11:37:58 -0000
@@ -3540,11 +3540,13 @@
Assumes point to be already positioned by `ada-goto-matching-start'.
Moves point to the beginning of the declaration."
- ;; named block without a `declare'
+ ;; named block without a `declare'; ada-goto-matching-start leaves
+ ;; point at start of 'begin' for a block.
(if (save-excursion
(ada-goto-previous-word)
(looking-at (concat "\\<" defun-name "\\> *:")))
t ; do nothing
+ ;; else
;;
;; 'accept' or 'package' ?
;;
@@ -3558,7 +3560,9 @@
;; a named 'declare'-block ? => jump to the label
;;
(if (looking-at "\\<declare\\>")
- (backward-word 1)
+ (progn
+ (forward-comment -1)
+ (backward-word 1))
;;
;; no, => 'procedure'/'function'/'task'/'protected'
;;
Since I also have other improvements, I'll post a new version to the website.
--
-- Stephe
More information about the Emacs-ada-mode
mailing list