Function: c-setup-paragraph-variables

c-setup-paragraph-variables is an interactive and byte-compiled function defined in cc-styles.el.gz.

Signature

(c-setup-paragraph-variables)

Documentation

Fix things up for paragraph recognition and filling inside comments and strings by incorporating the values of c-comment-prefix-regexp, sentence-end(var)/sentence-end(fun), paragraph-start and paragraph-separate in the relevant variables.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-styles.el.gz
(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* ((empty-is-prefix (string-match c-current-comment-prefix ""))
	 (nonws-comment-line-prefix
	  (concat "\\(" c-current-comment-prefix "\\)[ \t]*"))
	 (comment-line-prefix (concat "[ \t]*" nonws-comment-line-prefix))
	 (blank-or-comment-line-prefix
	  (concat "[ \t]*"
		  (if empty-is-prefix "" "\\(")
		  nonws-comment-line-prefix
		  (if empty-is-prefix "" "\\)?"))))

    (setq paragraph-start (concat blank-or-comment-line-prefix
				  c-paragraph-start
				  "\\|"
				  page-delimiter)
	  paragraph-separate (concat blank-or-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.
      (set (make-local-variable '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 invalid when not enclosed like "\\($\\)".
		"\\|" "[.?!][]\"')}]* ?\\\\\\($\\)[ \t\n]*"
		"\\)")))