Subject: bug#16971: 24.3.50; comment-beginning behaves differently in current newcomment.el, leads to error in comment-indent-new-line

From: Dmitry Gutov <[email-masked]>
Date: Tue, 11 Mar 2014 06:18:41 +0200

>> Anyway in *scratch* buffer, it was like (where '|' marks cursor position):
>>
>> 1) With current newcomment.el (December 2013):
>>
>>     (foo ; bar |baz
>>
>>      M-j =>
>>
>>     (foo ; bar
>>     baz

Apparently, that's because comment-start-skip in emacs-lisp-mode doesn't
match `; ', it needs a preceding character, so it matches e.g. ` ; '.

One fix would be to change it from
"\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *" to
"\\(\\(\\=\\|^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *".

(not sure if there'll be other consequences of this)

Another - revert the revision 114486 and just make `comment-beginning'
use `syntax-ppss' after finding prospective comment starter points with
`comment-search-backward', to check if the state at (match-end 0) is
"inside comment".