all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Glenn Morris <gmorris+news@ast.cam.ac.uk>
Subject: Re: Fortran 90 Code alignments
Date: Tue, 27 May 2003 15:11:17 +0100	[thread overview]
Message-ID: <ndsmr0iinu.fsf@xpc14.ast.cam.ac.uk> (raw)
In-Reply-To: 65fef11f.0305262323.18100da3@posting.google.com

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.

  parent reply	other threads:[~2003-05-27 14:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-27  7:23 Fortran 90 Code alignments Dr. F.C.Caner
2003-05-27  8:22 ` Eli Zaretskii
2003-05-27 14:11 ` Glenn Morris [this message]
2003-05-28  6:21   ` Dr. F.C.Caner

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=ndsmr0iinu.fsf@xpc14.ast.cam.ac.uk \
    --to=gmorris+news@ast.cam.ac.uk \
    /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.