GNU bug report logs - #6806
Set comment-multi-line in js-mode

Previous Next

Package: emacs;

Reported by: Nathan Weizenbaum <nweiz <at> google.com>

Date: Thu, 5 Aug 2010 20:09:02 UTC

Severity: normal

Found in versions 24.0.50.1, 24.5

Fixed in version 25.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Nathan Weizenbaum <nweiz <at> google.com>, 6806 <at> debbugs.gnu.org
Subject: bug#6806: Set comment-multi-line in js-mode
Date: Tue, 28 Sep 2010 14:11:02 -0400
Stefan Monnier <monnier <at> 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?




This bug report was last modified 8 years and 151 days ago.

Previous Next


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