unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: comment-kill and the state of the world
Date: Fri, 24 Oct 2003 15:41:30 GMT	[thread overview]
Message-ID: <jwvznfqslow.fsf-monnier+gnu.emacs.help@vor.iro.umontreal.ca> (raw)
In-Reply-To: 87vfqfd35x.fsf@newsguy.com

> 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	other threads:[~2003-10-24 15:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-16 17:54 comment-kill and the state of the world Ian Zimmerman
2003-10-16 19:11 ` Stefan Monnier
2003-10-17 16:37   ` Ian Zimmerman
2003-10-17 20:01     ` Stefan Monnier
2003-10-18 17:42       ` Ian Zimmerman
2003-10-19 23:14         ` Stefan Monnier
2003-10-23 22:01           ` Ian Zimmerman
2003-10-24 15:41             ` Stefan Monnier [this message]
2003-10-24 17:17               ` Ian Zimmerman
2003-10-24 19:48                 ` Stefan Monnier
2003-10-30 23:59                   ` Ian Zimmerman

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvznfqslow.fsf-monnier+gnu.emacs.help@vor.iro.umontreal.ca \
    --to=monnier@iro.umontreal.ca \
    /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.
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).