Variable: c-comment-prefix-regexp

c-comment-prefix-regexp is a customizable and buffer-local variable defined in cc-vars.el.gz.

Documentation

Regexp to match the line prefix inside comments.

This regexp is used to recognize the fill prefix inside comments for correct paragraph filling and other things.

If this variable is a string, it will be used in all CC Mode major modes. It can also be an association list, to associate specific regexps to specific major modes. The symbol for the major mode is looked up in the association list, and its value is used as the line prefix regexp. If it's not found, then the symbol other is looked up and its value is used instead.

The regexp should match the prefix used in both C++ style line comments and C style block comments, but it does not need to match a block comment starter. In other words, it should at least match
"//" for line comments and the string in c-block-comment-prefix,
which is sometimes inserted by CC Mode inside block comments. It should not match any surrounding whitespace.

Note that CC Mode uses this variable to set many other variables that handle the paragraph filling. That's done at mode initialization or when you switch to a style which sets this variable. Thus, if you change it in some other way, e.g. interactively in a CC Mode buffer, you will need to do M-x c-setup-paragraph-variables (c-setup-paragraph-variables) afterwards so that the other variables are updated with the new value.

Note also that when CC Mode starts up, all variables are initialized before the mode hooks are run. It's therefore necessary to make a call to c-setup-paragraph-variables explicitly if you change this variable in a mode hook.

This is a style variable. Apart from the valid values described above, it can be set to the symbol set-from-style. In that case, it takes its value from the style system (see c-default-style and c-style-alist) when a CC Mode buffer is initialized. Otherwise, the value set here overrides the style system (there is a variable c-old-style-variable-behavior that changes this, though).

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-vars.el.gz
(defcustom-c-stylevar c-comment-prefix-regexp
  '((pike-mode . "//+!?\\|\\**")
    (awk-mode . "#+")
    (other . "//+\\|\\**"))
  "Regexp to match the line prefix inside comments.
This regexp is used to recognize the fill prefix inside comments for
correct paragraph filling and other things.

If this variable is a string, it will be used in all CC Mode major
modes.  It can also be an association list, to associate specific
regexps to specific major modes.  The symbol for the major mode is
looked up in the association list, and its value is used as the line
prefix regexp.  If it's not found, then the symbol `other' is looked
up and its value is used instead.

The regexp should match the prefix used in both C++ style line
comments and C style block comments, but it does not need to match a
block comment starter.  In other words, it should at least match
\"//\" for line comments and the string in `c-block-comment-prefix',
which is sometimes inserted by CC Mode inside block comments.  It
should not match any surrounding whitespace.

Note that CC Mode uses this variable to set many other variables that
handle the paragraph filling.  That's done at mode initialization or
when you switch to a style which sets this variable.  Thus, if you
change it in some other way, e.g. interactively in a CC Mode buffer,
you will need to do \\[c-setup-paragraph-variables] afterwards so that
the other variables are updated with the new value.

Note also that when CC Mode starts up, all variables are initialized
before the mode hooks are run.  It's therefore necessary to make a
call to `c-setup-paragraph-variables' explicitly if you change this
variable in a mode hook."
  :type '(radio
	  (regexp :tag "Regexp for all modes")
	  (list
	   :tag "Mode-specific regexps"
	   (set
	    :inline t :format "%v"
	    (cons :format "%v"
		  (const :format "C     " c-mode) (regexp :format "%v"))
	    (cons :format "%v"
		  (const :format "C++   " c++-mode) (regexp :format "%v"))
	    (cons :format "%v"
		  (const :format "ObjC  " objc-mode) (regexp :format "%v"))
	    (cons :format "%v"
		  (const :format "Java  " java-mode) (regexp :format "%v"))
	    (cons :format "%v"
		  (const :format "IDL   " idl-mode) (regexp :format "%v"))
	    (cons :format "%v"
		  (const :format "Pike  " pike-mode) (regexp :format "%v"))
	    (cons :format "%v"
		  (const :format "AWK   " awk-mode) (regexp :format "%v")))
	   (cons :format "    %v"
		 (const :format "Other " other) (regexp :format "%v"))))
  :group 'c)