Function: c-add-style

c-add-style is an autoloaded, interactive and byte-compiled function defined in cc-styles.el.gz.

Signature

(c-add-style STYLE DESCRIPTION &optional SET-P)

Documentation

Add a style to c-style-alist, or update an existing one.

STYLE is a string identifying the style to add or update. DESCRIPTION is an association list describing the style and must be of the form:

  ([BASESTYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])

See the variable c-style-alist for the semantics of BASESTYLE, VARIABLE and VALUE. This function also sets the current style to STYLE using c-set-style if the optional SET-P flag is non-nil.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-styles.el.gz
;;;###autoload
(defun c-add-style (style description &optional set-p)
  "Add a style to `c-style-alist', or update an existing one.
STYLE is a string identifying the style to add or update.  DESCRIPTION
is an association list describing the style and must be of the form:

  ([BASESTYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])

See the variable `c-style-alist' for the semantics of BASESTYLE,
VARIABLE and VALUE.  This function also sets the current style to
STYLE using `c-set-style' if the optional SET-P flag is non-nil."
  (interactive
   (let ((stylename (completing-read "Style to add: " c-style-alist
				     nil nil nil 'c-set-style-history))
         (descr (eval-minibuffer "Style description: ")))
     (list stylename descr
	   (y-or-n-p "Set the style too? "))))
  (setq style (downcase style))
  (let ((s (assoc style c-style-alist)))
    (if s
        (setcdr s (copy-alist description)) ; replace
      (setq c-style-alist (cons (cons style description) c-style-alist))))
  (and set-p (c-set-style style)))