+\f
+(defun c-setup-paragraph-variables ()
+ "Fix things up for paragraph recognition and filling inside comments and
+strings by incorporating the values of `c-comment-prefix-regexp',
+`sentence-end', `paragraph-start' and `paragraph-separate' in the relevant
+variables."
+
+ (interactive)
+ (or c-buffer-is-cc-mode
+ (error "Buffer %s is not a CC Mode buffer (c-setup-paragraph-variables)"
+ (buffer-name)))
+ ;; Set up the values for use in comments.
+ (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 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.
+ "\\'"))))
+
+ ;; Set up the values for use in strings. These are the default
+ ;; paragraph-start/separate values, enhanced to accept escaped EOLs as
+ ;; whitespace. Used in c-beginning/end-of-sentence-in-string in cc-cmds.
+ (setq c-string-par-start
+ ;;(concat "\\(" (default-value 'paragraph-start) "\\)\\|[ \t]*\\\\$"))
+ "\f\\|[ \t]*\\\\?$")
+ (setq c-string-par-separate
+ ;;(concat "\\(" (default-value 'paragraph-separate) "\\)\\|[ \t]*\\\\$"))
+ "[ \t\f]*\\\\?$")
+ (setq c-sentence-end-with-esc-eol
+ (concat "\\(\\(" (c-default-value-sentence-end) "\\)"
+ ;; N.B.: "$" would be illegal when not enclosed like "\\($\\)".
+ "\\|" "[.?!][]\"')}]* ?\\\\\\($\\)[ \t\n]*"
+ "\\)")))
+
+\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.
+
+ ;; 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))))