[Emacs-ada-mode] ada-mode: ada-indent-region failure

Pierre-Louis Escouflaire pierre-louis.escouflaire at eurocontrol.int
Thu Sep 20 00:07:31 PDT 2007


Stephen Leake wrote:
> 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?

On the following empty lines and the first following instruction (or 
label, etc.) after the semi-colon, the bug appears while type RET, TAB 
(which I have not found).

> You have also not said what version of Emacs and Ada mode you are
> using.

That's emacs version 22.1.1 and the ada-mode that comes along with it.
Note that the problem already existed in emacs version 21.4.1.

> 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

That's the error we have.
The problem is that you can't edit the file unless using tricks.
Note you can also reproduce the problem using 'M-x ada-indent-region' on 
the whole file.

> On the other hand, placing point on the line after 'Another_Label;'
> does not give the error.

After the first non-empty line following the end of the named 'declare' 
block with comments in-between, the problem will not appear.

> 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.

We will then wait for the new version.
Thanks for your concern.

Regards,
Pierre-Louis ESCOUFLAIRE

____

This message and any files transmitted with it are legally privileged and intended for the sole use of the individual(s) or entity to whom they are addressed. If you are not the intended recipient, please notify the sender by reply and delete the message and any attachments from your system. Any unauthorised use or disclosure of the content of this message is strictly prohibited and may be unlawful.

Nothing in this e-mail message amounts to a contractual or legal commitment on the part of EUROCONTROL, unless it is confirmed by appropriately signed hard copy.

Any views expressed in this message are those of the sender.




More information about the Emacs-ada-mode mailing list