/[emacs]/emacs/lisp/progmodes/cc-styles.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/cc-styles.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by mast, Mon Apr 22 00:35:36 2002 UTC revision 1.25 by mast, Sat Jun 8 23:37:37 2002 UTC
# Line 247  the existing style.") Line 247  the existing style.")
247      (cond      (cond
248       ;; first special variable       ;; first special variable
249       ((eq attr 'c-offsets-alist)       ((eq attr 'c-offsets-alist)
250        (mapcar        (let ((offsets (cond ((eq dont-override t)
251         (function                              c-offsets-alist)
252          (lambda (langentry)                             (dont-override
253            (let ((langelem (car langentry))                              (default-value 'c-offsets-alist)))))
254                  (offset (cdr langentry)))          (mapcar (lambda (langentry)
255              (unless (and dont-override                    (let ((langelem (car langentry))
256                           (assq langelem c-offsets-alist))                          (offset (cdr langentry)))
257                (c-set-offset langelem offset))                      (unless (assq langelem offsets)
258              )))                        (c-set-offset langelem offset))))
259         (if dont-override (reverse val) val)))                  val)))
260       ;; second special variable       ;; second special variable
261       ((eq attr 'c-special-indent-hook)       ((eq attr 'c-special-indent-hook)
262        (let ((add-func (if dont-override        ;; Maybe we should ignore dont-override here and always add new
263                            (lambda (func)        ;; hooks?
264                              (unless (memq func c-special-indent-hook)        (unless (cond ((eq dont-override t)
265                                (add-hook 'c-special-indent-hook func t)))                       c-special-indent-hook)
266                          (lambda (func)                      (dont-override
267                            (add-hook 'c-special-indent-hook func)))))                       (default-value 'c-special-indent-hook)))
268          (if (listp val)          (if (listp val)
269              (mapcar add-func (if dont-override (reverse val) val))              (mapcar (lambda (func)
270            (funcall add-func val))))                        (add-hook 'c-special-indent-hook func t t))
271                        val)
272              (add-hook 'c-special-indent-hook val t t))))
273       ;; all other variables       ;; all other variables
274       (t (when (or (not dont-override)       (t (when (or (not dont-override)
275                    (not (memq attr c-style-variables))                    (not (memq attr c-style-variables))
276                    (eq (symbol-value attr) 'set-from-style))                    (eq (if (eq dont-override t)
277                              (symbol-value attr)
278                            (default-value attr))
279                          'set-from-style))
280            (set attr val)            (set attr val)
281            ;; Must update a number of other variables if            ;; Must update a number of other variables if
282            ;; c-comment-prefix-regexp is set.            ;; c-comment-prefix-regexp is set.
# Line 309  for details of setting up styles. Line 314  for details of setting up styles.
314  The variable `c-indentation-style' always contains the buffer's current  The variable `c-indentation-style' always contains the buffer's current
315  style name.  style name.
316    
317  If the optional argument DONT-OVERRIDE is non-nil, no style variables  If the optional argument DONT-OVERRIDE is t, no style variables that
318  that already have values will be overridden.  I.e. in the case of  already have values will be overridden.  I.e. in the case of
319  `c-offsets-alist', syntactic symbols will only be added, and in the  `c-offsets-alist', syntactic symbols will only be added, and in the
320  case of all other style variables, only those set to `set-from-style'  case of all other style variables, only those set to `set-from-style'
321  will be reassigned.  will be reassigned.
322    
323  Obviously, specifying DONT-OVERRIDE is useful mainly when the initial  If DONT-OVERRIDE is neither nil nor t, only those style variables that
324  style is chosen for a CC Mode buffer by a major mode.  Since this is  have default (i.e. non-buffer local) values will keep their settings
325  done internally by CC Mode, there's hardly ever a reason to use it."  while the rest will be overridden.  This is useful to avoid overriding
326    global settings done in ~/.emacs when setting a style from a mode hook
327    \(providing the style variables are buffer local, which is the
328    default).
329    
330    Obviously, setting DONT-OVERRIDE to t is useful mainly when the
331    initial style is chosen for a CC Mode buffer by a major mode.  Since
332    that is done internally by CC Mode, it typically won't have any effect
333    when used elsewhere."
334    (interactive    (interactive
335     (list (let ((completion-ignore-case t)     (list (let ((completion-ignore-case t)
336                 (prompt (format "Which %s indentation style? "                 (prompt (format "Which %s indentation style? "
# Line 348  done internally by CC Mode, there's hard Line 361  done internally by CC Mode, there's hard
361      (mapcar (lambda (elem)      (mapcar (lambda (elem)
362                (c-set-style-1 elem dont-override))                (c-set-style-1 elem dont-override))
363              ;; Need to go through the variables backwards when we              ;; Need to go through the variables backwards when we
364              ;; don't override.              ;; don't override any settings.
365              (if dont-override (nreverse vars) vars)))              (if (eq dont-override t) (nreverse vars) vars)))
366    (setq c-indentation-style stylename)    (setq c-indentation-style stylename)
367    (c-keep-region-active))    (c-keep-region-active))
368    

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26