help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Fortran code formatting


From: Nicolas Bock
Subject: Re: Fortran code formatting
Date: Mon, 20 Jul 2015 17:20:48 -0600

Hi Pascal,

thanks for the detailed answer. I will have a look at the code.

Thanks!

nick

On Mon, Jul 20, 2015 at 5:10 PM, Pascal J. Bourguignon
<pjb@informatimago.com> wrote:
> Nicolas Bock <nicolasbock@gmail.com> writes:
>
>> Hi,
>>
>> is it possible (and if so, how) to let emacs (re-)format Fortran code
>> and fix things such as spacing, e.g.:
>>
>> if ( a == 0 ) then
>>
>> would turn into
>>
>> if(a == 0) then
>>
>> Or
>>
>> x = a+1
>>
>> would turn into
>>
>> x = a + 1
>>
>> Thanks already,
>
> AFAIK, there's no mode doing that.
>
> But it would be easy enough to write some commands to clean up a such
> fortran buffer.
>
> You could use f90ppr:
> http://fortranwiki.org/fortran/show/f90ppr
> and apply it on your source code (possibly modifying it to suit your
> taste).
>
> Dead link at ifremer, but you can get it from:
> ftp://ftp.u-aizu.ac.jp/ftp/pub/lang/fortran/F90/ifremer.fr/
>
>
> The thing is that to do a good job of it, you would have to implement a
> fortran parser in emacs lisp (you could use wisent or bovinator to do
> that).  Then you could rewrite the source with the indentation and
> spacing you prefer.
>
> Alternatively, you may try to play with regexps, but this will not work
> in all cases.
>
> --
> __Pascal Bourguignon__                 http://www.informatimago.com/
> “The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment.” -- Carl Bass CEO Autodesk



reply via email to

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