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

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

Re: Fortran code formatting


From: Pascal J. Bourguignon
Subject: Re: Fortran code formatting
Date: Tue, 21 Jul 2015 01:10:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

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]