[Top][All Lists]

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

Re: uncomment-region - bug?

From: Glenn Morris
Subject: Re: uncomment-region - bug?
Date: Sun, 24 Feb 2002 20:25:24 +0000
User-agent: Gnus/5.090005 (Oort Gnus v0.05) Emacs/21.1.95 (i686-pc-linux-gnu)

address@hidden (Kai Gro├čjohann) wrote:

> Paolo Bientinesi <address@hidden> writes:
>> it looks to me that the function uncomment-region does not work in
> Which version of Emacs is this?  I think in Emacs 21, M-; will do
> what you want, though I haven't tried Fortran.

I think it is a (very minor) bug, I've checked in Emacs-21.1.95 and it
doesn't work (hence cross-post to gnu.emacs.bug). fortran.el contains this

(setq comment-start-skip "![ \t]*")

This is sort of correct, because an "!" anywhere on the line *is* the sign
of a comment start in fixed-form Fortran (which fortran.el is intended
for). At least, I *think* this is a widely accepted extension to F77. But
the actual F77 standard only defines comments to be those statements with a
"C" or "*" in column 1. `comment-region' inserts a "c" in column 1 of every
line in the region to comment them out, and so the above
`comment-start-skip' does not match them when `uncomment-region' is called.
I think the best behaviour would be obtained with something like:

(setq comment-start-skip "^[*!c]")

which at least has the virtue of fixing `uncomment-region'.

I think it might be a good idea to do:

(setq comment-padding nil)

in fortran.el as well, rather than the current " ". This is because column
number is important in fixed-form Fortran. Code proper starts in column 7
(column 6 in Emacs-land).
So for example:


      real x, y, z

If a user comments this out with `comment-region', a "c" and a " " get
inserted, shifting the "real" to column 9. If they later call
`uncomment-region', then the "c" and " " get deleted again, and all is
well. But if they happen to *manually* comment a region by just going through
and adding "c" at the start of each line, then if they later call
`uncomment-region', an extra " " gets deleted along with the "c", so that
the "real" above would end up in column 6, which is a Bad Thing. Setting
`comment-padding' to nil would avoid this.

Yes, this is all very archaic (aren't punched cards fun?!), which is why
there is free-form Fortran, supported by f90.el.


reply via email to

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