[Top][All Lists]

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

Re: Fortran 90 Code alignments

From: Glenn Morris
Subject: Re: Fortran 90 Code alignments
Date: Tue, 27 May 2003 15:11:17 +0100
User-agent: Gnus (, GNU Emacs (

Dr. F.C.Caner wrote:

[aligning f90 code]

> may be, I thought, there is some function that can do that
> independent of the programming language. Am I wrong?

It's Emacs, of course you're not wrong! :)

There are probably various ways to do what you ask. I use align.el,
which is a part of Emacs. I have the following in my .emacs. I
probably haven't done it the most elegant way, but It Works For Me.

(require 'align)
(add-to-list 'align-open-comment-modes 'f90-mode)
(add-to-list 'align-dq-string-modes    'f90-mode)
(add-to-list 'align-sq-string-modes    'f90-mode)

(add-hook 'f90-mode-hook
          '(lambda ()
             (setq align-mode-rules-list
                      (regexp . "\\(\\s-+\\)([^ :]+).*::"))
                      (regexp . "\\(\\s-*\\),\\s-+.*::")
                      (spacing   . 0))
                      (regexp    . "\\(\\s-*\\),\\s-*dimension.*::")
                      (spacing   . 0)
                      (case-fold . t))
                      (regexp    . "\\(\\s-*\\),\\s-*allocatable.*::")
                      (spacing   . 0)
                      (case-fold . t))
                      (regexp    . "\\(\\s-*\\),\\s-*intent.*::")
                      (spacing   . 0)
                      (case-fold . t))
                      (regexp    . "\\(\\s-*\\),\\s-*parameter.*::")
                      (spacing   . 0)
                      (case-fold . t))
                      (regexp    . "\\(\\s-*\\),\\s-*save.*::")
                      (spacing   . 0)
                      (case-fold . t))
                     (f90-colon-in-declaration       ; must come last
                      (regexp . "\\(\\s-+\\):: "))))))

(global-set-key "\C-ca" 'align)

Then just mark the region of interest, and hit C-c a.

reply via email to

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