all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
@ 2014-07-01 21:31 Roland Winkler
  2014-07-01 22:47 ` Stefan Monnier
  2014-07-01 23:38 ` Glenn Morris
  0 siblings, 2 replies; 12+ messages in thread
From: Roland Winkler @ 2014-07-01 21:31 UTC (permalink / raw)
  To: 17895


emacs -Q
insert a multiline comment while editing a file with fortran-mode

expected behavior (= emacs 24.3): typing RET (bound to newline)
inserts a newline and puts point at column 0 of the new line

actual behavior: the new line is indented to column 6

A similar problem exists with multiline statements requiring
fortran-continuation-string in column 5.

I do not see the benefit of this new behavior in the context of
fortran-mode.  Maybe electric-indent-chars should be locally bound to
nil in fortran-mode.

PS: It seems to me that in fortran-mode the command
indent-for-tab-command bound to TAB is better suited to provide the
proper indentation *after* typing, say, fortran-comment-line-start
or fortran-continuation-string in column 0 of a new line.




In GNU Emacs 24.3.91.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.4.2)
 of 2014-05-12 on regnitz
Windowing system distributor `The X.Org Foundation', version 11.0.11103000
System Description:	Ubuntu 12.04.4 LTS





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-01 21:31 bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode Roland Winkler
@ 2014-07-01 22:47 ` Stefan Monnier
  2014-07-01 23:49   ` Glenn Morris
  2014-07-01 23:38 ` Glenn Morris
  1 sibling, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2014-07-01 22:47 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 17895

[ Don't know enough about Fortran to know what is "insert a multiline
  comment" in this context, neither do I know what is a "multiline
  statement" or why it would "require fortran-continuation-string", so
  I'll skip this part of your bug-report.  Presumably Glenn will be able
  to give you a more useful answer in this area.  ]

> PS: It seems to me that in fortran-mode the command
> indent-for-tab-command bound to TAB is better suited to provide the
> proper indentation *after* typing, say, fortran-comment-line-start
> or fortran-continuation-string in column 0 of a new line.

Maybe a way to fix this problem, then, would be to make fortran's
indent-line-function indent to column 0 when called on an empty line in
one of those contexts.


        Stefan





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-01 21:31 bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode Roland Winkler
  2014-07-01 22:47 ` Stefan Monnier
@ 2014-07-01 23:38 ` Glenn Morris
  2014-07-02  1:17   ` Stefan Monnier
  1 sibling, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2014-07-01 23:38 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 17895

"Roland Winkler" wrote:

> emacs -Q
> insert a multiline comment while editing a file with fortran-mode

But Fortran doesn't have multi-line comments. :)
I know what you mean though, you mean that the desired indentation of
the new line isn't known in advance, because it depends on what you write.

Other modes, such as Python, have similar issues.
There, TAB cycles between possible indent positions.
I don't think I see the point in adding something like that for
fixed-format Fortran though.

> A similar problem exists with multiline statements requiring
> fortran-continuation-string in column 5.

I don't see the issue here.

Previously you would have to enter: RET SPC SPC SPC SPC SPC $
or: RET TAB DEL $
or: RET $ TAB

The 1st is inefficient.
The 2nd is replaced by: RET DEL $   (less typing)
The 3rd still works.

> I do not see the benefit of this new behavior in the context of
> fortran-mode.  Maybe electric-indent-chars should be locally bound to
> nil in fortran-mode.

Seems like a sledgehammer solution, just for the sake of "C" comments.
Even g77 supports "!" comments.

The new method is less typing on average, unless you write more "C"
comments than code.





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-01 22:47 ` Stefan Monnier
@ 2014-07-01 23:49   ` Glenn Morris
  2014-07-02 20:55     ` Roland Winkler
  0 siblings, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2014-07-01 23:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Roland Winkler, 17895

Stefan Monnier wrote:

> [ Don't know enough about Fortran to know what is "insert a multiline
>   comment" in this context

AFAIK, there is no such thing as "multiline comments" in Fortran.
I assume he means he has typed:

C this is a comment

Then he presses RET and wants to write more comments, but point gets
indented to column 6 instead. It's impossible for Fortran mode to know
if he was going to write code (column 6) or a comment (column 0). I
could say the same thing about pressing RET after a code line.

> neither do I know what is a "multiline statement" or why it would
> "require fortran-continuation-string"

If you want to write a continued code line, you put eg a "$" in column 5
of the new line. There's no marker in the previous line, so again it is
impossible for Fortran mode to know that's what you intend when you
press RET.

> Maybe a way to fix this problem, then, would be to make fortran's
> indent-line-function indent to column 0 when called on an empty line in
> one of those contexts.

It is impossible for it to know, as I hopefully explain above.


I really don't think that Fortran mode can do anything here.
The new behavior is different to the old one, but I think it will be a
net win in terms of fewer keypresses in most situations.


(Everyone should use free-format Fortran, where these problems were all
solved 20+ years ago!)





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-01 23:38 ` Glenn Morris
@ 2014-07-02  1:17   ` Stefan Monnier
  2014-07-02  1:51     ` Glenn Morris
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2014-07-02  1:17 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Roland Winkler, 17895

> Other modes, such as Python, have similar issues.

Actually, I think it's different: the problem with Python is that even
once the line is fully written, python-mode can't always decide where to
indent it, because there are several valid choices (and they don't mean
the same thing).

Instead, the problem here seems to only affect empty lines (i.e. lines
where the text hasn't been written yet), and this problem affects
many/most modes.

But I guess if the first non-whitespace char is a capital C,
fortran-mode has a similar problem to python-mode in that it can't know
for sure if the line should be assumed to be a comment (and go to
column-0) or to be some instruction that happens to start with a capital
C (and should go to some further column).

> or: RET $ TAB

And adding $ to electric-indent-chars would even save you from typing
this TAB (which doesn't mean that's what fortran-mode should do, tho.
I have the impression that this kind of old-style Fortran is fairly rare
nowadays).


        Stefan





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-02  1:17   ` Stefan Monnier
@ 2014-07-02  1:51     ` Glenn Morris
  2014-07-02  1:57       ` Glenn Morris
  2014-07-02  2:14       ` Stefan Monnier
  0 siblings, 2 replies; 12+ messages in thread
From: Glenn Morris @ 2014-07-02  1:51 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Roland Winkler, 17895

Stefan Monnier wrote:

> Instead, the problem here seems to only affect empty lines (i.e. lines
> where the text hasn't been written yet)

(How do you type RET and have text already written on the new line...?)

> , and this problem affects many/most modes.

Oh duh, of course.

if foo; then
   ...
   ... when will endif appear...
   ... who knows...
   endif  # oh here it is

> But I guess if the first non-whitespace char is a capital C,
> fortran-mode has a similar problem to python-mode in that it can't know
> for sure if the line should be assumed to be a comment (and go to
> column-0) or to be some instruction that happens to start with a capital
> C (and should go to some further column).

Yep. (CHARACTER for example.)


So I don't really see that there is anything to do here.





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-02  1:51     ` Glenn Morris
@ 2014-07-02  1:57       ` Glenn Morris
  2014-07-02  2:14       ` Stefan Monnier
  1 sibling, 0 replies; 12+ messages in thread
From: Glenn Morris @ 2014-07-02  1:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Roland Winkler, 17895

Glenn Morris wrote:

>> Instead, the problem here seems to only affect empty lines (i.e. lines
>> where the text hasn't been written yet)
>
> (How do you type RET and have text already written on the new line...?)

Wow, I am unusually slow today! :)





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-02  1:51     ` Glenn Morris
  2014-07-02  1:57       ` Glenn Morris
@ 2014-07-02  2:14       ` Stefan Monnier
  1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2014-07-02  2:14 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Roland Winkler, 17895

>> Instead, the problem here seems to only affect empty lines (i.e. lines
>> where the text hasn't been written yet)
> (How do you type RET and have text already written on the new line...?)

When you hit RET in the middle of a line, of course.
And of course electric-indent-mode doesn't only trigger when you hit RET
(and for other keys, there'll usually be text on the current line), and
half the work of electric-indent-mode when triggered by RET is to
reindent the line where the RET was inserted (i.e. the "previous" line),
which is often/usually not empty either.

> So I don't really see that there is anything to do here.

Agreed,


        Stefan





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-01 23:49   ` Glenn Morris
@ 2014-07-02 20:55     ` Roland Winkler
  2014-07-02 21:03       ` Glenn Morris
  0 siblings, 1 reply; 12+ messages in thread
From: Roland Winkler @ 2014-07-02 20:55 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 17895

On Tue Jul 1 2014 Glenn Morris wrote:
> Even g77 supports "!" comments.

For existing code "!" is not always an adequate choice.

> (Everyone should use free-format Fortran, where these problems
> were all solved 20+ years ago!)

All this is obviously not about new code, but it is about
maintaining existing code.
(Also, that's why Emacs comes with fortran-mode and f90-mode.  They
serve different needs!)

I completely agree that in a perfect world rewriting the old code is
the way to go.  But that's not always possible.  I am pretty sure
that such code will still be around and used happily twenty years
from now.





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-02 20:55     ` Roland Winkler
@ 2014-07-02 21:03       ` Glenn Morris
  2014-07-02 21:50         ` Roland Winkler
  0 siblings, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2014-07-02 21:03 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 17895

"Roland Winkler" wrote:

>> (Everyone should use free-format Fortran, where these problems
>> were all solved 20+ years ago!)
>
> All this is obviously not about new code, but it is about
> maintaining existing code.
> (Also, that's why Emacs comes with fortran-mode and f90-mode.  They
> serve different needs!)


I know, I know.
I was just trying to give the bug-gnu-emacs audience who is not familiar
with Fortran an impression of the language based on something that is not
25 years obsolete.



Do you have any concrete suggestions for changing Emacs's fortran-mode
in light of this report? I don't.





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-02 21:03       ` Glenn Morris
@ 2014-07-02 21:50         ` Roland Winkler
  2014-07-03  2:00           ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: Roland Winkler @ 2014-07-02 21:50 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 17895

On Wed Jul 2 2014 Glenn Morris wrote:
> Do you have any concrete suggestions for changing Emacs's
> fortran-mode in light of this report?

For me, in fortran-mode the electric-indent-mode moves point
too fast too far ahead.  I find this beavior distracting in
fortran-mode.  (Yes, the fortran codes I work with do have a good
percentage of comment lines plus some continuation lines.)  That's
why I suggested that electric-indent-chars should be locally bound
to nil in fortran-mode.

If that's not acceptable to you as default behavior, I have right
now nothing else to suggest.  I guess I'll set up the local binding
in my .emacs.  Not a big deal.

We'll see whether anybody else might find the current behavior an
issue.

Roland





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

* bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode
  2014-07-02 21:50         ` Roland Winkler
@ 2014-07-03  2:00           ` Stefan Monnier
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2014-07-03  2:00 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 17895

> For me, in fortran-mode the electric-indent-mode moves point
> too fast too far ahead.  I find this beavior distracting in
> fortran-mode.  (Yes, the fortran codes I work with do have a good
> percentage of comment lines plus some continuation lines.)  That's
> why I suggested that electric-indent-chars should be locally bound
> to nil in fortran-mode.

You can also (electric-indent-local-mode -1) from the fortran-mode-hook.


        Stefan





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

end of thread, other threads:[~2014-07-03  2:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-01 21:31 bug#17895: 24.3.91; electric-indent-mode not quite right with comments in fortran-mode Roland Winkler
2014-07-01 22:47 ` Stefan Monnier
2014-07-01 23:49   ` Glenn Morris
2014-07-02 20:55     ` Roland Winkler
2014-07-02 21:03       ` Glenn Morris
2014-07-02 21:50         ` Roland Winkler
2014-07-03  2:00           ` Stefan Monnier
2014-07-01 23:38 ` Glenn Morris
2014-07-02  1:17   ` Stefan Monnier
2014-07-02  1:51     ` Glenn Morris
2014-07-02  1:57       ` Glenn Morris
2014-07-02  2:14       ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.