[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6806: Set comment-multi-line in js-mode
From: |
Chong Yidong |
Subject: |
bug#6806: Set comment-multi-line in js-mode |
Date: |
Tue, 28 Sep 2010 14:11:02 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> My fix doesn't actually fix the "/* */" issue, unfortunately. However, it
>> doesn't break "//" either; note that comment-multi-line is t for e.g.
>> c-mode, and comment-indent-new-line works for "//" there.
>
> Indeed, I misremembered. Feel free to install this patch.
The patch doesn't do the right thing. The reported problem is that if
you enter "/*" in a js-mode buffer and do M-x comment-indent-new-line,
Emacs inserts another "/*".
This problem is not limited to js-mode. It afflicts C++ also. Try
this:
C-x C-f foo.cc RET
/*
M-x comment-indent-new-line RET
Emacs inserts another /*. The reason is this stretch of code in
newcomment.el:1311:
(normalp
(string-match (regexp-quote (comment-string-strip
comment-start t t))
comstart))
(comment-end
(if normalp comment-end
;; The comment starter is not the normal comment-start
;; so we can't just use comment-end.
(save-excursion
(goto-char compos)
(if (not (comment-forward)) comment-end
(comment-string-strip
(buffer-substring
(save-excursion (comment-enter-backward) (point))
(point))
nil t)))))
When the default comment-start is "//" but the current comment begins in
"/*", this code tries to find the appropriate comment-end by doing
comment-forward. But if the comment-end "*/" is not already present in
the buffer, it fails.
Any suggestion?