unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Fortran code formatting
@ 2015-07-20 22:03 Nicolas Bock
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Bock @ 2015-07-20 22:03 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

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,

nick



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

* Re: Fortran code formatting
       [not found] <mailman.7198.1437429856.904.help-gnu-emacs@gnu.org>
@ 2015-07-20 23:10 ` Pascal J. Bourguignon
  2015-07-20 23:20   ` Nicolas Bock
  0 siblings, 1 reply; 3+ messages in thread
From: Pascal J. Bourguignon @ 2015-07-20 23:10 UTC (permalink / raw)
  To: help-gnu-emacs

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


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

* Re: Fortran code formatting
  2015-07-20 23:10 ` Fortran code formatting Pascal J. Bourguignon
@ 2015-07-20 23:20   ` Nicolas Bock
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Bock @ 2015-07-20 23:20 UTC (permalink / raw)
  To: Pascal J. Bourguignon; +Cc: help-gnu-emacs@gnu.org

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



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

end of thread, other threads:[~2015-07-20 23:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.7198.1437429856.904.help-gnu-emacs@gnu.org>
2015-07-20 23:10 ` Fortran code formatting Pascal J. Bourguignon
2015-07-20 23:20   ` Nicolas Bock
2015-07-20 22:03 Nicolas Bock

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