[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fortran 90 Code alignments
From: |
Dr. F.C.Caner |
Subject: |
Re: Fortran 90 Code alignments |
Date: |
27 May 2003 23:21:11 -0700 |
Glenn: Thanks, it seems to work OK. Best, FCC.
Glenn Morris <gmorris+news@ast.cam.ac.uk> wrote in message
news:<ndsmr0iinu.fsf@xpc14.ast.cam.ac.uk>...
> 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
> '((f90-bracket-in-declaration
> (regexp . "\\(\\s-+\\)([^ :]+).*::"))
> (f90-comma-in-declaration
> (regexp . "\\(\\s-*\\),\\s-+.*::")
> (spacing . 0))
> (f90-dimension-in-declaration
> (regexp . "\\(\\s-*\\),\\s-*dimension.*::")
> (spacing . 0)
> (case-fold . t))
> (f90-alloc-in-declaration
> (regexp . "\\(\\s-*\\),\\s-*allocatable.*::")
> (spacing . 0)
> (case-fold . t))
> (f90-intent-in-declaration
> (regexp . "\\(\\s-*\\),\\s-*intent.*::")
> (spacing . 0)
> (case-fold . t))
> (f90-parameter-in-declaration
> (regexp . "\\(\\s-*\\),\\s-*parameter.*::")
> (spacing . 0)
> (case-fold . t))
> (f90-save-in-declaration
> (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.