Function: c-set-style-1

c-set-style-1 is a byte-compiled function defined in cc-styles.el.gz.

Signature

(c-set-style-1 CONSCELL DONT-OVERRIDE)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-styles.el.gz
;; Functions that manipulate styles
(defun c-set-style-1 (conscell dont-override)
  ;; Set the style for one variable
  (let ((attr (car conscell))
	(val  (cdr conscell)))
    (cond
     ;; first special variable
     ((eq attr 'c-offsets-alist)
      (let ((offsets (cond ((eq dont-override t)
			    c-offsets-alist)
			   (dont-override
			    (default-value 'c-offsets-alist)))))
	(mapcar (lambda (langentry)
		  (let ((langelem (car langentry))
			(offset (cdr langentry)))
		    (unless (assq langelem offsets)
		      (c-set-offset langelem offset))))
		val)))
     ;; second special variable
     ((eq attr 'c-special-indent-hook)
      ;; Maybe we should ignore dont-override here and always add new
      ;; hooks?
      (unless (cond ((eq dont-override t)
		     c-special-indent-hook)
		    (dont-override
		     (default-value 'c-special-indent-hook)))
	(if (listp val)
	    (mapcar (lambda (func)
		      (add-hook 'c-special-indent-hook func t t))
		    val)
	  (add-hook 'c-special-indent-hook val t t))))
     ;; all other variables
     (t (when (or (not dont-override)
		  (not (memq attr c-style-variables))
		  (eq (if (eq dont-override t)
			  (symbol-value attr)
			(default-value attr))
		      'set-from-style))
	  (set attr val)
	  ;; Must update a number of other variables if
	  ;; c-comment-prefix-regexp is set.
	  (if (eq attr 'c-comment-prefix-regexp)
	      (c-setup-paragraph-variables)))))))