GNU bug report logs - #37099
26.2 Comment-dwim

Previous Next

Package: emacs;

Reported by: Charles Jackson <charles.b.jackson <at> protonmail.com>

Date: Tue, 20 Aug 2019 15:41:01 UTC

Severity: wishlist

Tags: wontfix

Found in version 26.2

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: gnu-emacs-bug <at> moderators.isc.org
Subject: Re: bug#37099: 26.2 Comment-dwim
Date: Wed, 21 Aug 2019 16:42:35 -0000 (UTC)
Hello, Charles.

Charles Jackson <charles.b.jackson <at> protonmail.com> wrote:
> [-- text/plain, encoding base64, charset: UTF-8, 8 lines --]

> I would like the comment-dwim function to be able to differentiate
> end-of-line comments from whole-line comments.

OK.  What should happen when a whole-line comment becomes and end-of-line
comment (by inserting text before it), or vice versa?

> For example in java mode it would make sense for // to be the
> end-of-line comment, but if point is on an empty line then comment-dwim
> would insert /* */ with point inside the /* */ like so: /* | */ where |
> is the point location.

Why would this make sense?  For example, how big is the community of
users who would want such a facility.

A general solution to this wish would be surprisingly difficult and
time-consuming to write.  The Emacs source file, newcomment.el (which
contains the command comment-dwim) contains no representation of
different pairs of comment delimiters, and this would have to be added.

It is CC Mode here which maintains the two different pairs of comment
delimiters, /* .... */ and // .... \n.  In a CC Mode mode (such as Java
Mode) you can manually switch between the delimiter pairs with C-c C-k,
c-toggle-comment-style.

It would be relatively easy to add Lisp "advice" to the function
comment-dwim just for Java Mode, which would use c-toggle-comment-style
to set the comment delimiters after having determined the required pair
of comment delimiters.

Again, how useful a facility would this really be?  Useful enough to
justify the time and effort to write a full solution, or rather a
localised need which would best be satisfied with a careful hack (such as
outlined above)?

-- 
Alan Mackenzie (Nuremberg, Germany).





This bug report was last modified 4 years and 118 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.