unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* f90 comments indentation
@ 2003-10-16  2:28 Shriram Ramanathan
  2003-10-16 18:12 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Shriram Ramanathan @ 2003-10-16  2:28 UTC (permalink / raw)


Hi,

I am writing f90 programs and I have turned auto-fill mode on.  I want my
comments to be indented to where my earlier comment line starts.  So, for
example, what I want is this (irrespective of the comment column)

real, (kind=long), dimension(3,3) :: abcd ! This is a test
                                          ! comment

But, what I get is

real, (kind=long), dimension(3,3) :: abcd ! This is a test
! comment

Can someone help me with this ?

Thanks in advance,
shriram.

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

* Re: f90 comments indentation
  2003-10-16  2:28 f90 comments indentation Shriram Ramanathan
@ 2003-10-16 18:12 ` Stefan Monnier
  2003-10-17 17:31   ` Glenn Morris
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2003-10-16 18:12 UTC (permalink / raw)


> I am writing f90 programs and I have turned auto-fill mode on.  I want my
> comments to be indented to where my earlier comment line starts.  So, for
> example, what I want is this (irrespective of the comment column)

> real, (kind=long), dimension(3,3) :: abcd ! This is a test
>                                           ! comment

> But, what I get is

> real, (kind=long), dimension(3,3) :: abcd ! This is a test
> ! comment

If this is what you get after hitting SPC (which triggered auto-fill),
then it's a bug that you should report with M-x report-emacs-bug (although
you might want to check whether it's already fixed in a more recent version
of Emacs first).
If that's what you get after hitting TAB on the second line, then it's
a problem with indentation of comments (which is sadly partly separate from
the indentation that takes place during auto-fill) and there might be
some convention that you need to follow (such as using some other comment
marker, or using two or three ! or ...).


        Stefan

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

* Re: f90 comments indentation
  2003-10-16 18:12 ` Stefan Monnier
@ 2003-10-17 17:31   ` Glenn Morris
  0 siblings, 0 replies; 3+ messages in thread
From: Glenn Morris @ 2003-10-17 17:31 UTC (permalink / raw)


Stefan Monnier wrote:

>> I am writing f90 programs and I have turned auto-fill mode on. I
>> want my comments to be indented to where my earlier comment line
>> starts. So, for example, what I want is this (irrespective of the
>> comment column)
>
>> real, (kind=long), dimension(3,3) :: abcd ! This is a test
>>                                           ! comment
>
>> But, what I get is
>
>> real, (kind=long), dimension(3,3) :: abcd ! This is a test
>> ! comment
>
> If this is what you get after hitting SPC (which triggered auto-fill),
> then it's a bug that you should report with M-x report-emacs-bug

That would not be a bug, because by default (controllable through
f90-indented-comment-re) f90-mode indents "!" comments as code, not to
comment-column.

> If that's what you get after hitting TAB on the second line, then
> it's a problem with indentation of comments (which is sadly partly
> separate from the indentation that takes place during auto-fill) and
> there might be some convention that you need to follow (such as
> using some other comment marker, or using two or three ! or ...).

(setq f90-indented-comment-re "!!")

would get "!" comments indented to comment-column, but would not
necessarily align them as the OP wants (if the non-comment portion of
the first line extended beyond comment-column). There's no option in
f90 for that style, but there probably could (and maybe should) be. In
the meantime, combining the above setting with something like the
following seems to work:

(defadvice f90-indent-line (around set-comment-column activate)
  "Set comment-column so as to align consecutive trailing comments."
  (let ((comment-column comment-column)
        col f90-cache-position)
    (save-excursion
      (beginning-of-line)
      (skip-chars-forward " \t")
      (when (and (looking-at "!") (zerop (forward-line -1)))
        (setq f90-cache-position (point))
        (end-of-line)
        (while (and (f90-in-comment)
                    (search-backward "!" f90-cache-position t))
          (setq col (current-column)))
        (or (looking-at f90-indented-comment-re)
            (and col (setq comment-column col)))))
    ad-do-it))

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

end of thread, other threads:[~2003-10-17 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-16  2:28 f90 comments indentation Shriram Ramanathan
2003-10-16 18:12 ` Stefan Monnier
2003-10-17 17:31   ` Glenn Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).