help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: comment-kill and the state of the world


From: Stefan Monnier
Subject: Re: comment-kill and the state of the world
Date: Fri, 24 Oct 2003 15:41:30 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> So, how _do_ people kill their comments?

Using standard editing commands, I guess.
I myself tend to use C-k, I think.

Stefan> The only non-dispatch part of the code is the part that inserts
Stefan> a comment on an empty line.  Are you saying that we should move
Stefan> that code out into its own function?  That'd be fine by me.

> I think it should be moved to comment-indent.

There are two parts:
1 - move the code out of comment-dwim so that comment-dwim is really just
    a dispatch function.
2 - move the code into comment-indent.

Part 1 can be done safely and easily without any objection.
Part 2 means changing the behavior of the comment-indent command (which does
not bother me but might bother RMS or other users, so you'd have to report
it as a bug or feature request).  `comment-indent' is also used as
a function called from comment-indent-new-line and that code (and its
interaction with comment-indent) is pretty delicate, so the patch would have
to be written carefully a thoroughly tested, which I have no intent to do
unless there's a good reason for it (but feel free to do it).  If the merge
into comment-indent is well done it could definitely be a good thing (and
who knows, it might clean things up).

Could you explain why you'd want the code to be moved into comment-indent?

Ian> Second, do you have any advice for me when I _want_ them to behave
Ian> the same?
Stefan> Which difference are you referring to ?  Since I have trouble
Stefan> understanding your problems, please try to be very precise and
Stefan> concrete.
> Let's say the language's comment delimiters look like this: {- -} .  I
> can configure comment-dwim to leave appropriate amount of whitespace and
> put the point in the right place, so the situation after an empty
> comment is inserted looks like this: {- | -} .  But that won't affect
> non-empty lines, because that is handled by comment-indent.  And vice
> versa.

By "configure comment-dwim", I assume you mean "configure comment-padding".

Note that if you "configure comment-dwim" by changing comment-end and
comment-start instead (by setting them to "{-  " and "  -}" for example),
it will work the same way for comment-indent.

Sometimes you want it to behave the same in both case, sometimes you want it
to behave differently, which is why there are two ways to configure the
spacing.  Admittedly, the `comment-padding' way is easier and very different
from the other, so it's pretty ugly, but that's the way it worked in
Emacs-20, so I had to support it in Emacs-21.  RMS would probably accept
a patch for a new config option something like `comment-padding-foo' which
would be used for comments on non-empty lines and could be set to nil to mean
use the same value as `comment-padding'.  You'd have to come up with a good
name for the variable, tho.  It's just that the need hasn't come up yet
because configuring comment-start and comment-end works as well in all
the actual cases I've come across.

Ian> BTW, another bug is that comment-indent uses
Ian> (indent-according-to-mode) to position the comment when
Ian> comment-indent-function returns nil.  That makes no sense when
Ian> there's preceding code on the line
Stefan> Indeed, that's a clear bug.  Does the patch below fix it for you
Stefan> ?
> Yes.

Thank you.


        Stefan


reply via email to

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