unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5595: Commenting in F90
@ 2010-02-18 10:30 Angelo Graziosi
  2010-02-19  9:12 ` Glenn Morris
  2022-02-05 23:44 ` bug#14448: Wrong indentation in comment lines for F90 mode? Lars Ingebrigtsen
  0 siblings, 2 replies; 14+ messages in thread
From: Angelo Graziosi @ 2010-02-18 10:30 UTC (permalink / raw)
  To: 5595

I do not know if this is a bug but it looks strange to me.

Start Emacs with:

$ emacs -Q &

Then visit a new file:

C-x C-f foo.f90

Type '!' (it is at line 1, column 0 in Emacs).

Then continue to comment: C-M-j. The new '!' is at line 2, column 2 and 
not at line 2, column 0, i.e. below the previous '!', as one expects (at 
least me!). In other word the second '!' is indended.

Why this?

Ciao,
Angelo.







^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#5595: Commenting in F90
  2010-02-18 10:30 bug#5595: Commenting in F90 Angelo Graziosi
@ 2010-02-19  9:12 ` Glenn Morris
  2010-02-19  9:42   ` Angelo Graziosi
  2022-02-05 23:44 ` bug#14448: Wrong indentation in comment lines for F90 mode? Lars Ingebrigtsen
  1 sibling, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2010-02-19  9:12 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: 5595

retitle 5595 comment-indent-new-line in f90-mode
stop

Angelo Graziosi wrote:

> C-x C-f foo.f90
>
> Type '!' (it is at line 1, column 0 in Emacs).
>
> Then continue to comment: C-M-j. The new '!' is at line 2, column 2
> and not at line 2, column 0, i.e. below the previous '!', as one
> expects (at least me!). In other word the second '!' is indended.

C-M-j runs comment-indent-new-line, a function which I do not understand. 
Maybe it's doing what it is supposed to do.

The only way to customize the behaviour of this function is through
standard comment variables. As far as I know these are all set
correctly in f90-mode.

The doc-string says

    Break line at point and indent, continuing comment if within one.
    This indents the body of the continued comment
    under the previous comment line.

It's a little ambiguous from that as to whether it indents the first
line or not. The Emacs manual is clearer, saying:

   Like <RET> followed by inserting and aligning a comment

Ie, it does not indent the first line, only the second.
Under these criteria, it appears to be working correctly.

Personally I prefer C-j `f90-indent-new-line'.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#5595: Commenting in F90
  2010-02-19  9:12 ` Glenn Morris
@ 2010-02-19  9:42   ` Angelo Graziosi
  2010-02-19 18:01     ` Glenn Morris
  2010-02-19 18:25     ` Stefan Monnier
  0 siblings, 2 replies; 14+ messages in thread
From: Angelo Graziosi @ 2010-02-19  9:42 UTC (permalink / raw)
  To: 5595

Il 19/02/2010 10.12, Glenn Morris ha scritto:
> It's a little ambiguous from that as to whether it indents the first
> line or not. The Emacs manual is clearer, saying:
>
>     Like<RET>  followed by inserting and aligning a comment
>
> Ie, it does not indent the first line, only the second.
> Under these criteria, it appears to be working correctly.

Uhm...

It is not clear why this happens only with F90 mode. Repeating with 
'foo.cpp' (C/C++ mode and '!' --> '//') or with 'foo.f' (Fortran mode, 
'!' --> 'C'), C-M-j sets the comment character correctly indended (to 
me!), under the previous and not shifted...

In any case thanks for clarification.


Ciao,
Angelo.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#5595: Commenting in F90
  2010-02-19  9:42   ` Angelo Graziosi
@ 2010-02-19 18:01     ` Glenn Morris
  2010-02-21  0:33       ` Angelo Graziosi
  2010-02-19 18:25     ` Stefan Monnier
  1 sibling, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2010-02-19 18:01 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: 5595

Angelo Graziosi wrote:

> It is not clear why this happens only with F90 mode. Repeating with
> foo.cpp' (C/C++ mode and '!' --> '//') or with 'foo.f' (Fortran mode,
> !' --> 'C'), C-M-j sets the comment character correctly indended (to
> me!), under the previous and not shifted...

But 'C' comments in Fortran mode get zero indentation, so how can one
tell if this functin is indenting the first line or not?

Like I said, I don't really understand what this function is supposed
to do, nor which variables modes should set to make it work correctly.

Perhaps the maintainer of newcomment.el can help us out...






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#5595: Commenting in F90
  2010-02-19  9:42   ` Angelo Graziosi
  2010-02-19 18:01     ` Glenn Morris
@ 2010-02-19 18:25     ` Stefan Monnier
  1 sibling, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2010-02-19 18:25 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: 5595

>> It's a little ambiguous from that as to whether it indents the first
>> line or not. The Emacs manual is clearer, saying:
>> Like<RET>  followed by inserting and aligning a comment
>> Ie, it does not indent the first line, only the second.
>> Under these criteria, it appears to be working correctly.

> Uhm...

> It is not clear why this happens only with F90 mode. Repeating with
> foo.cpp' (C/C++ mode and '!' --> '//') or with 'foo.f' (Fortran mode,
> !' --> 'C'), C-M-j sets the comment character correctly indended (to me!),
> under the previous and not shifted...

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


        Stefan






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#5595: Commenting in F90
  2010-02-19 18:01     ` Glenn Morris
@ 2010-02-21  0:33       ` Angelo Graziosi
  0 siblings, 0 replies; 14+ messages in thread
From: Angelo Graziosi @ 2010-02-21  0:33 UTC (permalink / raw)
  To: 5595

Il 19/02/2010 19.01, Glenn Morris ha scritto:
> Angelo Graziosi wrote:
>
>> It is not clear why this happens only with F90 mode. Repeating with
>> foo.cpp' (C/C++ mode and '!' -->  '//') or with 'foo.f' (Fortran mode,
>> !' -->  'C'), C-M-j sets the comment character correctly indended (to
>> me!), under the previous and not shifted...
>
> But 'C' comments in Fortran mode get zero indentation, so how can one
> tell if this functin is indenting the first line or not?
>
> Like I said, I don't really understand what this function is supposed
> to do, nor which variables modes should set to make it work correctly.
>
> Perhaps the maintainer of newcomment.el can help us out...

...or, perhaps, the indentation should regard only the cursor, not the 
character! For example, editing bash script, the following happens (with 
the cursor, X, at the end of last line):

## [...]
## [...]
##    foo text...X  <== last line

Typing C-M-j produces

## [...]
## [...]
##    foo text...
##    X

with the cursor (X) under the 'f' of 'foo': the character '##' is 
vertically aligned.

Ciao,
Angelo.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#14448: Wrong indentation in comment lines for F90 mode?
@ 2013-05-23 10:51 Angelo Graziosi
  2013-05-23 17:04 ` Glenn Morris
  0 siblings, 1 reply; 14+ messages in thread
From: Angelo Graziosi @ 2013-05-23 10:51 UTC (permalink / raw)
  To: 14448

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.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#14448: Wrong indentation in comment lines for F90 mode?
  2013-05-23 10:51 Angelo Graziosi
@ 2013-05-23 17:04 ` Glenn Morris
  2013-05-23 20:00   ` Angelo Graziosi
  0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2013-05-23 17:04 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: 14448

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.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#14448: Wrong indentation in comment lines for F90 mode?
  2013-05-23 17:04 ` Glenn Morris
@ 2013-05-23 20:00   ` Angelo Graziosi
  2013-05-25  3:23     ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Angelo Graziosi @ 2013-05-23 20:00 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 14448

Il 23/05/2013 19.04, Glenn Morris ha scritto:
> 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.
>

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.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#14448: Wrong indentation in comment lines for F90 mode?
  2013-05-23 20:00   ` Angelo Graziosi
@ 2013-05-25  3:23     ` Stefan Monnier
  2013-05-25 11:24       ` Angelo Graziosi
  2013-05-26  3:09       ` Glenn Morris
  0 siblings, 2 replies; 14+ messages in thread
From: Stefan Monnier @ 2013-05-25  3:23 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: 14448

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





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#14448: Wrong indentation in comment lines for F90 mode?
  2013-05-25  3:23     ` Stefan Monnier
@ 2013-05-25 11:24       ` Angelo Graziosi
  2013-05-26  3:09       ` Glenn Morris
  1 sibling, 0 replies; 14+ messages in thread
From: Angelo Graziosi @ 2013-05-25 11:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14448

Il 25/05/2013 5.23, Stefan Monnier ha scritto:
>>> 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.

Indeed...

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

Thanks for clarification..

Ciao.
  Angelo.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#14448: Wrong indentation in comment lines for F90 mode?
  2013-05-25  3:23     ` Stefan Monnier
  2013-05-25 11:24       ` Angelo Graziosi
@ 2013-05-26  3:09       ` Glenn Morris
  2013-05-26 18:36         ` Stefan Monnier
  1 sibling, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2013-05-26  3:09 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14448, 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





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#14448: Wrong indentation in comment lines for F90 mode?
  2013-05-26  3:09       ` Glenn Morris
@ 2013-05-26 18:36         ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2013-05-26 18:36 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 14448, 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





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#14448: Wrong indentation in comment lines for F90 mode?
  2010-02-18 10:30 bug#5595: Commenting in F90 Angelo Graziosi
  2010-02-19  9:12 ` Glenn Morris
@ 2022-02-05 23:44 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-05 23:44 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: Glenn Morris, 14448, 5595

Angelo Graziosi <angelo.graziosi@alice.it> writes:

> Start Emacs with:
>
> $ emacs -Q &
>
> Then visit a new file:
>
> C-x C-f foo.f90
>
> Type '!' (it is at line 1, column 0 in Emacs).
>
> Then continue to comment: C-M-j. The new '!' is at line 2, column 2
> and not at line 2, column 0, i.e. below the previous '!', as one
> expects (at least me!). In other word the second '!' is indended.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I'm unable to reproduce this in more recent Emacs versions, so I'm
guessing it's been fixed in the decade since this was reported, and I'm
therefore closing this bug report.  If this bug is still present, please
respond to the debbugs address and we'll reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-02-05 23:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-18 10:30 bug#5595: Commenting in F90 Angelo Graziosi
2010-02-19  9:12 ` Glenn Morris
2010-02-19  9:42   ` Angelo Graziosi
2010-02-19 18:01     ` Glenn Morris
2010-02-21  0:33       ` Angelo Graziosi
2010-02-19 18:25     ` Stefan Monnier
2022-02-05 23:44 ` bug#14448: Wrong indentation in comment lines for F90 mode? Lars Ingebrigtsen
  -- strict thread matches above, loose matches on Subject: below --
2013-05-23 10:51 Angelo Graziosi
2013-05-23 17:04 ` Glenn Morris
2013-05-23 20:00   ` Angelo Graziosi
2013-05-25  3:23     ` Stefan Monnier
2013-05-25 11:24       ` Angelo Graziosi
2013-05-26  3:09       ` Glenn Morris
2013-05-26 18:36         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).