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

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

bug#37099: 26.2 Comment-dwim


From: Alan Mackenzie
Subject: bug#37099: 26.2 Comment-dwim
Date: Wed, 21 Aug 2019 16:42:35 -0000 (UTC)
User-agent: tin/2.4.2-20171224 ("Lochhead") (UNIX) (FreeBSD/11.2-RELEASE-p9 (amd64))

Hello, Charles.

Charles Jackson <charles.b.jackson@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).






reply via email to

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