all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Fortran 90 Code alignments
@ 2003-05-27  7:23 Dr. F.C.Caner
  2003-05-27  8:22 ` Eli Zaretskii
  2003-05-27 14:11 ` Glenn Morris
  0 siblings, 2 replies; 4+ messages in thread
From: Dr. F.C.Caner @ 2003-05-27  7:23 UTC (permalink / raw)


Hello everyone,

I am wondering if there is a way to alingn a fortran 90/95 code
properly. The f90 mode that comes with emacs does not do that AFAIK.
For example, I would like

 real(kind=doublep), dimension(:,:), allocatable :: coords
 real(kind=doublep), dimension(:), allocatable :: disp
 real(kind=doublep), dimension(1:6) :: stress
 real(kind=doublep) :: vertdisp, gaussp

to be 

 real(kind=doublep), dimension(:,:), allocatable :: coords
 real(kind=doublep), dimension(:),   allocatable :: disp
 real(kind=doublep), dimension(1:6)              :: stress
 real(kind=doublep)                              :: vertdisp, gaussp

automatically. Is ther a package, a command or similar that does this?
I know there is no such thing in f90 mode, but may be, I thought,
there is some function that can do that independent of the programming
language. Am I wrong?

Thanks in advance,

FCC.

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

* Re: Fortran 90 Code alignments
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2003-05-27  8:22 UTC (permalink / raw)


> From: ferhun_caner@yahoo.com (Dr. F.C.Caner)
> Newsgroups: gnu.emacs.help
> Date: 27 May 2003 00:23:58 -0700
> 
> I am wondering if there is a way to alingn a fortran 90/95 code
> properly. The f90 mode that comes with emacs does not do that AFAIK.
> For example, I would like
> 
>  real(kind=doublep), dimension(:,:), allocatable :: coords
>  real(kind=doublep), dimension(:), allocatable :: disp
>  real(kind=doublep), dimension(1:6) :: stress
>  real(kind=doublep) :: vertdisp, gaussp
> 
> to be 
> 
>  real(kind=doublep), dimension(:,:), allocatable :: coords
>  real(kind=doublep), dimension(:),   allocatable :: disp
>  real(kind=doublep), dimension(1:6)              :: stress
>  real(kind=doublep)                              :: vertdisp, gaussp
> 
> automatically. Is ther a package, a command or similar that does this?

I have the function indent-relative bound to M-i, and type M-i
whenever I need to align text like you want above.  Is that what you
want?

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

* Re: Fortran 90 Code alignments
  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
  2003-05-28  6:21   ` Dr. F.C.Caner
  1 sibling, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2003-05-27 14:11 UTC (permalink / raw)


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.

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

* Re: Fortran 90 Code alignments
  2003-05-27 14:11 ` Glenn Morris
@ 2003-05-28  6:21   ` Dr. F.C.Caner
  0 siblings, 0 replies; 4+ messages in thread
From: Dr. F.C.Caner @ 2003-05-28  6:21 UTC (permalink / raw)


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.

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

end of thread, other threads:[~2003-05-28  6:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2003-05-28  6:21   ` Dr. F.C.Caner

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.