+\f
+(defun c-setup-paragraph-variables ()
+ "Fix things up for paragraph recognition and filling inside comments by
+incorporating the value of `c-comment-prefix-regexp' in the relevant
+variables."
+ ;;
+ ;; This function does not do any hidden buffer changes.
+
+ (interactive)
+
+ (setq c-current-comment-prefix
+ (if (listp c-comment-prefix-regexp)
+ (cdr-safe (or (assoc major-mode c-comment-prefix-regexp)
+ (assoc 'other c-comment-prefix-regexp)))
+ c-comment-prefix-regexp))
+
+ (let ((comment-line-prefix
+ (concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*")))
+
+ (setq paragraph-start (concat comment-line-prefix
+ c-paragraph-start
+ "\\|"
+ page-delimiter)
+ paragraph-separate (concat comment-line-prefix
+ c-paragraph-separate
+ "\\|"
+ page-delimiter)
+ paragraph-ignore-fill-prefix t
+ adaptive-fill-mode t
+ adaptive-fill-regexp
+ (concat comment-line-prefix
+ (if (default-value 'adaptive-fill-regexp)
+ (concat "\\("
+ (default-value 'adaptive-fill-regexp)
+ "\\)")
+ "")))
+
+ (when (boundp 'adaptive-fill-first-line-regexp)
+ ;; XEmacs (20.x) adaptive fill mode doesn't have this.
+ (make-local-variable 'adaptive-fill-first-line-regexp)
+ (setq adaptive-fill-first-line-regexp
+ (concat "\\`" comment-line-prefix
+ ;; Maybe we should incorporate the old value here,
+ ;; but then we have to do all sorts of kludges to
+ ;; deal with the \` and \' it probably contains.
+ "\\'")))))
+
+\f
+;; Helper for setting up Filladapt mode. It's not used by CC Mode itself.
+
+(cc-bytecomp-defvar filladapt-token-table)
+(cc-bytecomp-defvar filladapt-token-match-table)
+(cc-bytecomp-defvar filladapt-token-conversion-table)
+
+(defun c-setup-filladapt ()
+ "Convenience function to configure Kyle E. Jones' Filladapt mode for
+CC Mode by making sure the proper entries are present on
+`filladapt-token-table', `filladapt-token-match-table', and
+`filladapt-token-conversion-table'. This is intended to be used on
+`c-mode-common-hook' or similar."
+ ;; This function is intended to be used explicitly by the end user
+ ;; only.
+ ;;
+ ;; This function does not do any hidden buffer changes.
+
+ ;; The default configuration already handles C++ comments, but we
+ ;; need to add handling of C block comments. A new filladapt token
+ ;; `c-comment' is added for that.
+ (let (p)
+ (setq p filladapt-token-table)
+ (while (and p (not (eq (car-safe (cdr-safe (car-safe p))) 'c-comment)))
+ (setq p (cdr-safe p)))
+ (if p
+ (setcar (car p) c-current-comment-prefix)
+ (setq filladapt-token-table
+ (append (list (car filladapt-token-table)
+ (list c-current-comment-prefix 'c-comment))
+ (cdr filladapt-token-table)))))
+ (unless (assq 'c-comment filladapt-token-match-table)
+ (setq filladapt-token-match-table
+ (append '((c-comment c-comment))
+ filladapt-token-match-table)))
+ (unless (assq 'c-comment filladapt-token-conversion-table)
+ (setq filladapt-token-conversion-table
+ (append '((c-comment . exact))
+ filladapt-token-conversion-table))))