Topic: indent file

Hello!

Feature request - add "indent whole file" menu.
Or even better like in slickedit http://www.slickedit.com/products/slick … s/#xmlhtml

Thank you

Re: indent file

There isn't an explicit menu option, but one could use "Select All" (Control-A) and then simply hit the Tab key to indent a whole file.

I agree, though.  A "beautifier" feature would certainly be nice to have.  I'll have a look at how it can be done.

Jeff Armstrong
Approximatrix, LLC

Re: indent file

Indent - simple adds [Tab] as for now. I mean smart tabs (line http://www.emacswiki.org/SmartTabs)

Re: indent file

Sorry, I didn't understand your original description of "indent whole file."  It should be relatively easy and safe to implement.

Jeff Armstrong
Approximatrix, LLC

Re: indent file

I just wanted to point out that this feature will be present in version 2.16.  It is currently working for free-format Fortran, and fixed-format Fortran support is being implemented right now.

Jeff Armstrong
Approximatrix, LLC

Re: indent file

Great work! Thanks!

Re: indent file

I did want to point out that the Smart Indent feature will not automatically wrap lines when necessary after performing indentation.  When using the feature, lines may exceed the Fortran column limit, especially under fixed-format Fortran.  I struggled a bit with whether the feature should provide automatic wrapping, but I think that handling the line continuation might best be left to the user as the automatic process may lead to some "ugly" continuation placement.

Any thoughts from users?

Jeff Armstrong
Approximatrix, LLC

Re: indent file

Are the continuation rules for,
   (1)  '&' at the end of a line or
   (2)  'C' in character position 1..

..strictly restricted to .for and .f90/.f95 code, or are they interchangeable?

I've neither experimented with thjs nor even ever used the '&' continuation method - though I really should start doing so.
If that can be used in all flavours of FORTRAN then my suggestion would be to adopt it for linewraps in auto-indenting.

Problem is, though, where exactly to break a line. 
I'm sure most of us do this just before or just after = signs or + - * / arithmetic operators, or // concatenation symbols, and try always to do it outside not inside quoted strings, etc, but there must be a lot of rules that need to be thought up to make this automatic.

Another way might be deliberately to trigger an error, eg by wrapping the line without a line-wrap instructio, or perhaps better by not doing so but inserting instead an extra line with an illegal character, to force a compile error that will bring the user straight to each place where line-wrap is needed.  This might me made optional.
---
J.

Re: indent file

Problem is, though, where exactly to break a line.

That's the problem I was referring to.  Algorithmically speaking, it's simple enough to just split a line exceeding the length limit in an acceptable (from a strict standards point of view) position.  The problem actually becomes where to do it that it makes sense from a human perspective.  You could probably set some arbitrary rules, but there are so many edge cases. 

For example, what if a continuation already exists, and 4 characters exist on the continued line.  When Smart Indent runs, it finds that the first line is now too long again and continues it on a second line, but there's already a third line.  Something along the lines of (and this is purely an example):

         WRITE (1000, 1200) "Here's a string with some output variables", X, Y, Z,
     .                      A, B ,C

Smart Indent with automatic wrapping, however, might do something like:

                 WRITE (1000, 1200) "Here's a string with some output variables", 
     &           X, Y, Z,
     .                      A, B ,C

The above is just an example (I probably got the columns wrong), but it shows why automatically wrapping is probably a bad idea.

Jeff Armstrong
Approximatrix, LLC