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: Sat, 15 Mar 2014 07:25:08 +0200

AFAICS, only `lisp-mode-variables' and `scheme-mode-variables' set 
`comment-start-skip' to a value that looks for a character before the 
comment (and they're also the only two uses of 
`font-lock-comment-start-skip').

The patch below is probably the cleaner fix. I'll install it in a couple 
of days if no one objects.

=== modified file 'lisp/emacs-lisp/lisp-mode.el'
--- lisp/emacs-lisp/lisp-mode.el	2014-02-10 01:34:22 +0000
+++ lisp/emacs-lisp/lisp-mode.el	2014-03-15 05:21:12 +0000
@@ -449,15 +449,10 @@
    (setq-local outline-level 'lisp-outline-level)
    (setq-local add-log-current-defun-function #'lisp-current-defun-name)
    (setq-local comment-start ";")
-  ;; Look within the line for a ; following an even number of backslashes
-  ;; after either a non-backslash or the line beginning.
-  (setq-local comment-start-skip 
"\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
-  ;; Font lock mode uses this only when it KNOWS a comment is starting.
-  (setq-local font-lock-comment-start-skip ";+ *")
+  (setq-local comment-start-skip ";+ *")
    (setq-local comment-add 1)		;default to `;;' in comment-region
    (setq-local comment-column 40)
-  ;; Don't get confused by `;' in doc strings when paragraph-filling.
-  (setq-local comment-use-global-state t)
+  (setq-local comment-use-syntax t)
    (setq-local imenu-generic-expression lisp-imenu-generic-expression)
    (setq-local multibyte-syntax-as-symbol t)
    ;; (setq-local syntax-begin-function 'beginning-of-defun)  ;;Bug#16247.

=== modified file 'lisp/progmodes/scheme.el'
--- lisp/progmodes/scheme.el	2014-01-01 07:43:34 +0000
+++ lisp/progmodes/scheme.el	2014-03-15 05:15:57 +0000
@@ -140,11 +140,8 @@
    (setq-local add-log-current-defun-function #'lisp-current-defun-name)
    (setq-local comment-start ";")
    (setq-local comment-add 1)
-  ;; Look within the line for a ; following an even number of backslashes
-  ;; after either a non-backslash or the line beginning.
-  (setq-local comment-start-skip
-	      "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+[ \t]*")
-  (setq-local font-lock-comment-start-skip ";+ *")
+  (setq-local comment-start-skip ";+[ \t]*")
+  (setq-local comment-use-syntax t)
    (setq-local comment-column 40)
    (setq-local parse-sexp-ignore-comments t)
    (setq-local lisp-indent-function 'scheme-indent-function)