ada-mode-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ada mode 6.2.1: ada-indent-comment-col-0 no longer honored


From: Stephen Leake
Subject: Re: Ada mode 6.2.1: ada-indent-comment-col-0 no longer honored
Date: Tue, 19 Nov 2019 12:12:41 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (windows-nt)

SCHOEPFLIN Markus <address@hidden> writes:

> Resending to the list...
>
>> From: Stephen Leake <address@hidden>
>> > SCHOEPFLIN Markus <address@hidden> writes:
>> 
>> > In my .emacs I have " '(ada-indent-comment-col-0 t)",
>> 
>> I gather this is part of a "custom-set-variables" form.
>
> Yes.
>
>> ada-indent-comment-col-0 is buffer-local; does custom-set-variables
>> handle that properly? (I tried reading the code in custom.el, and it's
>> complicated; it seems to use set-default unless special conditions
>> apply) It may be setting the value for the .emacs buffer only, or
>> possibly only for the first ada-mode buffer created.
>> 
>> Try this instead in your .emacs:
>> 
>>     (set-default 'ada-indent-comment-col-0 t)
>> 
>> Also examine the value in the ada-mode buffer (M-x
>> ada-indent-comment-col-0); is it t?
>
> <CTRL>-h-v ada-indent-comment-col-0 gives:
>
> ---%<---
> ada-indent-comment-col-0 is a variable defined in 
> 'ada-indent-user-options.el'.
> Its value is t
> Original value was nil
>
>   Automatically becomes buffer-local when set.
>   This variable is safe as a file local variable if its value
>   satisfies the predicate \u2018booleanp\u2019.
>
> Documentation:
> If non-nil, comments currently starting in column 0 are left in column 0.
> Otherwise, they are indented with previous comments or code.
>
> You can customize this variable.
> --->%---
>
> So the customization is applied correctly.

Ok, good.

>
>
>> 
>> If that fixes the problem, then I should change all the buffer-local
>> indent settings to be not custom variables. Keeping them custom makes
>> them easier to discover.
>> 
>> If that doesn't fix the problem, something else is wrong.
>> 
>> You can look in the " *Ada_wisi_parse*" buffer (note the leading space
>> in the name); the first line is the parse command sent to the background
>> process, with lots of parameters for the indent settings. One of the
>> values is either 0 or 1 for ada-indent-comment-col-0 nil or t. The line
>> looks like either:
>> 
>> ;; parse 2 "ada_mode-options.ads" 1 918 918 1 1 33 0 0 0 -1 0 0 0 -1 -1 -1
>> 15 917 3 2 0 0 -3 0 2 0 2 3 2 0 0
>> ;; parse 2 "ada_mode-options.ads" 1 918 918 1 1 33 0 0 0 -1 0 0 0 -1 -1 -1
>> 15 917 3 2 1 0 -3 0 2 0 2 3 2 0 0
>> 
>>    ada-indent-comment-col-0 ----------------------------------------------
>> ------------^
>> 
>> (those lines will probably get messed up by the mail program).
>> 
>> Here the first line has nil, the second t. That should reflect the value
>> in the buffer. (this line is built in the function
>> wisi-process-parse--send-parse, which calls
>> wisi-parse-format-language-options, which handles
>> ada-indent-comment-col-0).
>
> The line looks like this:
>
> ;; parse 2 "mms_env.adb" 1 6815 6815 1 1 184 0 0 0 -1 0 0 0 -1 -1 -1
> 15 6814 3 2 1 0 -3 3 2 0 2 3 2 0 0
>
> If I didn't mix up the columns, this means that the value of the option is 
> correct.
>
>> If that is correct, you've found a corner case in the indent algorithm;
>> please post a reproducing source file.
>
> Tried but failed. But then I noticed I can't even indent the most
> simple source file correctly (but it nevertheless works in principle
> for "real" source files). E.g.:
>
> ---%<---
> procedure TEST is
> X : INTEGER;
> begin
> X := 0;
> end TEST;
> --->%---
>
> When I place the cursor at column 0 of line 2 (the declaration of X)
> and press <TAB>, I get the following output:
>
> ---%<---
> ;; parse 2 "test.adb" 1 56 56 1 1 6 0 0 0 -1 0 0 0 -1 -1 -1 15 55 3 2
> 1 0 -3 3 2 0 2 3 2 0 0
> (parse_error "test.adb:1:0: action raised exception CONSTRAINT_ERROR:
> wisi.adb:2120 range check failed")

This is a bug in ada-mode 6.2.1 (and in my current devel sources!).

I did not have a test where the first line in a file is not a comment
and ada-indent-comment-col-0 is t.

Patch attached.

Apply the patch in ~/.emacs.d/elpa/wisi-2.2.0, and run
~/.emacs.d/elpa/ada-mode-6.2.1/build.sh again (patched to install in
your directory).

Then restart emacs, to get the new parser executable (or kill the process
from M-x list-processes).

This may fix your original problem

-- 
-- Stephe

#
# old_revision [2f537cdbfca4944de3e5977240237429f17c9039]
#
# patch "wisi.adb"
#  from [ff8d8ee4bae339ff41b5a20d2da38184ffb160fa]
#    to [285ce399c6cea8bbb89f5a0420350caabb6dc3f0]
#
============================================================
*** wisi.adb    ff8d8ee4bae339ff41b5a20d2da38184ffb160fa
--- wisi.adb    285ce399c6cea8bbb89f5a0420350caabb6dc3f0
*************** package body Wisi is
*** 2117,2123 ****
                 use all type Ada.Text_IO.Count;
                 Indent : Boolean := True;
              begin
!                if Data.Line_Begin_Token.all (Line - 1) /= 
Augmented_Token_Arrays.No_Index then
                    for Tok of Data.Terminals (Data.Line_Begin_Token.all (Line 
- 1)).Non_Grammar loop
                       if Tok.Line = Line and then
                         Tok.ID in Data.First_Comment_ID .. 
Data.Last_Comment_ID and then
--- 2117,2125 ----
                 use all type Ada.Text_IO.Count;
                 Indent : Boolean := True;
              begin
!                if Line > Data.Line_Begin_Token.First_Index and then
!                  Data.Line_Begin_Token.all (Line - 1) /= 
Augmented_Token_Arrays.No_Index
!                then
                    for Tok of Data.Terminals (Data.Line_Begin_Token.all (Line 
- 1)).Non_Grammar loop
                       if Tok.Line = Line and then
                         Tok.ID in Data.First_Comment_ID .. 
Data.Last_Comment_ID and then

reply via email to

[Prev in Thread] Current Thread [Next in Thread]