Mercurial > hg > xemacs-beta
comparison lisp/cc-mode/cc-styles.el @ 177:6075d714658b r20-3b15
Import from CVS: tag r20-3b15
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:51:16 +0200 |
parents | 2d532a89d707 |
children | bfd6434d15b3 |
comparison
equal
deleted
inserted
replaced
176:6866abce6aaf | 177:6075d714658b |
---|---|
5 ;; Authors: 1992-1997 Barry A. Warsaw | 5 ;; Authors: 1992-1997 Barry A. Warsaw |
6 ;; 1987 Dave Detlefs and Stewart Clamen | 6 ;; 1987 Dave Detlefs and Stewart Clamen |
7 ;; 1985 Richard M. Stallman | 7 ;; 1985 Richard M. Stallman |
8 ;; Maintainer: cc-mode-help@python.org | 8 ;; Maintainer: cc-mode-help@python.org |
9 ;; Created: 22-Apr-1997 (split from cc-mode.el) | 9 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
10 ;; Version: 5.13 | 10 ;; Version: 5.14 |
11 ;; Keywords: c languages oop | 11 ;; Keywords: c languages oop |
12 | 12 |
13 ;; This file is part of GNU Emacs. | 13 ;; This file is part of GNU Emacs. |
14 | 14 |
15 ;; GNU Emacs is free software; you can redistribute it and/or modify | 15 ;; GNU Emacs is free software; you can redistribute it and/or modify |
126 )) | 126 )) |
127 ) | 127 ) |
128 ("java" | 128 ("java" |
129 (c-basic-offset . 2) | 129 (c-basic-offset . 2) |
130 (c-comment-only-line-offset . (0 . 0)) | 130 (c-comment-only-line-offset . (0 . 0)) |
131 ;; the following preserves Javadoc starter lines | |
132 (c-hanging-comment-starter-p . nil) | |
131 (c-offsets-alist . ((topmost-intro-cont . +) | 133 (c-offsets-alist . ((topmost-intro-cont . +) |
132 (statement-block-intro . +) | 134 (statement-block-intro . +) |
133 (knr-argdecl-intro . 5) | 135 (knr-argdecl-intro . 5) |
134 (substatement-open . +) | 136 (substatement-open . +) |
135 (label . 0) | 137 (label . 0) |
207 | 209 |
208 (defun c-set-style-2 (style basestyles) | 210 (defun c-set-style-2 (style basestyles) |
209 ;; Recursively set the base style. If no base style is given, the | 211 ;; Recursively set the base style. If no base style is given, the |
210 ;; default base style is "cc-mode" and the recursion stops. Be sure | 212 ;; default base style is "cc-mode" and the recursion stops. Be sure |
211 ;; to detect loops. | 213 ;; to detect loops. |
212 (if (not (string-equal style "cc-mode")) | |
213 (let ((base (if (stringp (car basestyles)) | |
214 (downcase (car basestyles)) | |
215 "cc-mode"))) | |
216 (if (memq base basestyles) | |
217 (error "Style loop detected: %s in %s" base basestyles)) | |
218 (c-set-style-2 base (cons base basestyles)))) | |
219 (let ((vars (cdr (or (assoc (downcase style) c-style-alist) | 214 (let ((vars (cdr (or (assoc (downcase style) c-style-alist) |
220 (assoc (upcase style) c-style-alist) | 215 (assoc (upcase style) c-style-alist) |
221 (assoc style c-style-alist) | 216 (assoc style c-style-alist) |
222 (error "Undefined style: %s" style))))) | 217 (error "Undefined style: %s" style))))) |
218 (if (not (string-equal style "cc-mode")) | |
219 (let ((base (if (stringp (car vars)) | |
220 (prog1 | |
221 (downcase (car vars)) | |
222 (setq vars (cdr vars))) | |
223 "cc-mode"))) | |
224 (if (memq base basestyles) | |
225 (error "Style loop detected: %s in %s" base basestyles)) | |
226 (c-set-style-2 base (cons base basestyles)))) | |
223 (mapcar 'c-set-style-1 vars))) | 227 (mapcar 'c-set-style-1 vars))) |
224 | 228 |
225 (defvar c-set-style-history nil) | 229 (defvar c-set-style-history nil) |
226 | 230 |
227 ;;;###autoload | 231 ;;;###autoload |
237 (prompt (format "Which %s indentation style? " | 241 (prompt (format "Which %s indentation style? " |
238 mode-name))) | 242 mode-name))) |
239 (completing-read prompt c-style-alist nil t | 243 (completing-read prompt c-style-alist nil t |
240 (cons c-indentation-style 0) | 244 (cons c-indentation-style 0) |
241 'c-set-style-history)))) | 245 'c-set-style-history)))) |
246 (c-initialize-builtin-style) | |
242 (c-set-style-2 stylename nil) | 247 (c-set-style-2 stylename nil) |
243 (setq c-indentation-style stylename) | 248 (setq c-indentation-style stylename) |
244 (c-keep-region-active)) | 249 (c-keep-region-active)) |
245 | 250 |
246 ;;;###autoload | 251 ;;;###autoload |
575 c-hanging-comment-ender-p | 580 c-hanging-comment-ender-p |
576 c-offsets-alist | 581 c-offsets-alist |
577 ))) | 582 ))) |
578 ;; the default style is now GNU. This can be overridden in | 583 ;; the default style is now GNU. This can be overridden in |
579 ;; c-mode-common-hook or {c,c++,objc,java}-mode-hook. | 584 ;; c-mode-common-hook or {c,c++,objc,java}-mode-hook. |
580 (c-set-style c-site-default-style)))) | 585 (c-set-style c-site-default-style))) |
586 (if c-style-variables-are-local-p | |
587 (c-make-styles-buffer-local))) | |
588 | |
581 | 589 |
582 (defun c-make-styles-buffer-local () | 590 (defun c-make-styles-buffer-local () |
583 "Make all CC Mode style variables buffer local. | 591 "Make all CC Mode style variables buffer local. |
584 If you edit primarily one style of C (or C++, Objective-C, Java) code, | 592 If you edit primarily one style of C (or C++, Objective-C, Java) code, |
585 you probably want style variables to be global. This is the default. | 593 you probably want style variables to be global. This is the default. |