From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Fortran code formatting
Date: Tue, 21 Jul 2015 01:10:09 +0200 [thread overview]
Message-ID: <87r3o22zou.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.7198.1437429856.904.help-gnu-emacs@gnu.org
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
next parent reply other threads:[~2015-07-20 23:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.7198.1437429856.904.help-gnu-emacs@gnu.org>
2015-07-20 23:10 ` Pascal J. Bourguignon [this message]
2015-07-20 23:20 ` Fortran code formatting Nicolas Bock
2015-07-20 22:03 Nicolas Bock
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r3o22zou.fsf@kuiper.lan.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.