Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bug#14448: Wrong indentation in comment lines for F90 mode?

2 views
Skip to first unread message

Angelo Graziosi

unread,
May 23, 2013, 6:51:35 AM5/23/13
to 14...@debbugs.gnu.org
Start Emacs with

$ emacs -Q &

then "C-x C-f foo.f90". Now type "!" to start a comment line and then
type M-j to produce other comment lines. The result is as follow:


!
!
!
!
!

from the second line, the comment is indented. Repeating the same steps
for a C++ mode file, "C-x C-f foo.cpp", the result is

//
//
//
//
//

without indentation. I would expect the same for F90 mode...

So, is the behavior in F90 mode to be expected (on purpose) or is it wrong?


Ciao,
Angelo.



Glenn Morris

unread,
May 23, 2013, 1:04:24 PM5/23/13
to Angelo Graziosi, 14...@debbugs.gnu.org
Angelo Graziosi wrote:

> Start Emacs with
>
> $ emacs -Q &
>
> then "C-x C-f foo.f90". Now type "!" to start a comment line and then
> type M-j to produce other comment lines. The result is as follow:
>
>
> !
> !

You reported this before.
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5595

As I said then:

I don't understand what comment-indent-new-line is supposed to do, nor
which variables modes should set to make it work correctly.



Angelo Graziosi

unread,
May 23, 2013, 4:00:13 PM5/23/13
to Glenn Morris, 14...@debbugs.gnu.org
Oh, sorry for the noise then... :(

Any way, all my observations I did in that thread are still alive...


Stefan, have you some comment? In that thread you wrote:

> comment-indent-new-line is written with a "traditional" free text style
> of languages and comments, so I'm not surprised it doesn't work 100%

F90 is a "free text style of languages and comments" like C++, so one
doesn't understand why its comments behaves differently...

> right under languages such as Fortran.
> It's a nasty function, but I've spent a fair bit of time in it (years
> ago), so I should be able to track down the problem.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

(WoW! I didn't remember that... :-) )



Ciao,
Angelo.




Stefan Monnier

unread,
May 24, 2013, 11:23:27 PM5/24/13
to Angelo Graziosi, 14...@debbugs.gnu.org
>> I don't understand what comment-indent-new-line is supposed to do, nor
>> which variables modes should set to make it work correctly.

To tell you the truth, I don't know either. The way I see it, M-j
should be bound to a function that funcalls comment-line-break-function
(whose default value is comment-indent-new-line). So modes can modify
comment-line-break-function (ideally via add-function) to tune
its behavior.

> F90 is a "free text style of languages and comments" like C++, so one
> doesn't understand why its comments behaves differently...

I see now that it behaves differently because f90 tells it to, via
f90-comment-indent. Try:

! bla
! bli

and then hit either TAB or M-; on the second line, and you'll see it
gets indented by 1 more space, just like in your example.


Stefan



Angelo Graziosi

unread,
May 25, 2013, 7:24:28 AM5/25/13
to Stefan Monnier, 14...@debbugs.gnu.org
Indeed...

It seems that this happens only for comments before source code...
Anyway, it isn't very important.

Thanks for clarification..

Ciao.
Angelo.




Glenn Morris

unread,
May 25, 2013, 11:09:03 PM5/25/13
to Stefan Monnier, 14...@debbugs.gnu.org, Angelo Graziosi
Stefan Monnier wrote:

> I see now that it behaves differently because f90 tells it to, via
> f90-comment-indent. Try:
>
> ! bla
> ! bli
>
> and then hit either TAB or M-; on the second line, and you'll see it
> gets indented by 1 more space, just like in your example.

ITYM 2 spaces?

This takes me back to my original question:
Is M-j supposed to re-indent the line it starts on, or not?

If not, is it supposed to indent the following line as it would normally
be indented, or to match the indentation of the original line?

If the answers are "no", and "as normal", then there is no bug here.

> It seems that this happens only for comments before source code...

Probably because that is an ambiguous state, depending on whether or not
a leading "program" line gets added. See
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3729#10



Stefan Monnier

unread,
May 26, 2013, 2:36:47 PM5/26/13
to Glenn Morris, 14...@debbugs.gnu.org, Angelo Graziosi
> Is M-j supposed to re-indent the line it starts on, or not?

That's unspecified. IIUC it doesn't, currently.

> If not, is it supposed to indent the following line as it would normally
> be indented, or to match the indentation of the original line?

The new line should be indented according to indent-according-to-mode.

> If the answers are "no", and "as normal", then there is no bug here.

At least w.r.t M-j, that's my impression as well: the only problem is
that the OP wants his ! comments to be on column 0 whereas f90-mode puts
them in column 1, but that's unrelated to M-j.


Stefan



0 new messages