cc-vars.el 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776
  1. ;;; cc-vars.el --- user customization variables for CC Mode
  2. ;; Copyright (C) 1985, 1987, 1992-2012 Free Software Foundation, Inc.
  3. ;; Authors: 2002- Alan Mackenzie
  4. ;; 1998- Martin Stjernholm
  5. ;; 1992-1999 Barry A. Warsaw
  6. ;; 1987 Dave Detlefs
  7. ;; 1987 Stewart Clamen
  8. ;; 1985 Richard M. Stallman
  9. ;; Maintainer: bug-cc-mode@gnu.org
  10. ;; Created: 22-Apr-1997 (split from cc-mode.el)
  11. ;; Keywords: c languages
  12. ;; Package: cc-mode
  13. ;; This file is part of GNU Emacs.
  14. ;; GNU Emacs is free software: you can redistribute it and/or modify
  15. ;; it under the terms of the GNU General Public License as published by
  16. ;; the Free Software Foundation, either version 3 of the License, or
  17. ;; (at your option) any later version.
  18. ;; GNU Emacs is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;; You should have received a copy of the GNU General Public License
  23. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  24. ;;; Commentary:
  25. ;;; Code:
  26. (eval-when-compile
  27. (let ((load-path
  28. (if (and (boundp 'byte-compile-dest-file)
  29. (stringp byte-compile-dest-file))
  30. (cons (file-name-directory byte-compile-dest-file) load-path)
  31. load-path)))
  32. (load "cc-bytecomp" nil t)))
  33. (cc-require 'cc-defs)
  34. ;; Silence the compiler.
  35. (cc-bytecomp-defun get-char-table) ; XEmacs
  36. (cc-eval-when-compile
  37. (require 'custom)
  38. (require 'widget))
  39. (cc-eval-when-compile
  40. ;; Need the function form of `backquote', which isn't standardized
  41. ;; between Emacsen. It's called `bq-process' in XEmacs, and
  42. ;; `backquote-process' in Emacs. `backquote-process' returns a
  43. ;; slightly more convoluted form, so let `bq-process' be the norm.
  44. (if (fboundp 'backquote-process)
  45. (cc-bytecomp-defmacro bq-process (form)
  46. `(cdr (backquote-process ,form)))))
  47. ;;; Helpers
  48. ;; This widget exists in newer versions of the Custom library
  49. (or (get 'other 'widget-type)
  50. (define-widget 'other 'sexp
  51. "Matches everything, but doesn't let the user edit the value.
  52. Useful as last item in a `choice' widget."
  53. :tag "Other"
  54. :format "%t%n"
  55. :value 'other))
  56. ;; The next defun will supersede c-const-symbol.
  57. (eval-and-compile
  58. (defun c-constant-symbol (sym len)
  59. "Create an uneditable symbol for customization buffers.
  60. SYM is the name of the symbol, LEN the length of the field (in
  61. characters) the symbol will be displayed in. LEN must be big
  62. enough.
  63. This returns a (const ....) structure, suitable for embedding
  64. within a customization type."
  65. (or (symbolp sym) (error "c-constant-symbol: %s is not a symbol" sym))
  66. (let* ((name (symbol-name sym))
  67. (l (length name))
  68. (disp (concat name ":" (make-string (- len l 1) ?\ ))))
  69. `(const
  70. :size ,len
  71. :format ,disp
  72. :value ,sym))))
  73. (define-widget 'c-const-symbol 'item
  74. "An uneditable lisp symbol. This is obsolete -
  75. use c-constant-symbol instead."
  76. :value nil
  77. :tag "Symbol"
  78. :format "%t: %v\n%d"
  79. :match (lambda (widget value) (symbolp value))
  80. :value-to-internal
  81. (lambda (widget value)
  82. (let ((s (if (symbolp value)
  83. (symbol-name value)
  84. value))
  85. (l (widget-get widget :size)))
  86. (if l
  87. (setq s (concat s (make-string (- l (length s)) ?\ ))))
  88. s))
  89. :value-to-external
  90. (lambda (widget value)
  91. (if (stringp value)
  92. (intern (progn
  93. (string-match "\\`[^ ]*" value)
  94. (match-string 0 value)))
  95. value)))
  96. (define-widget 'c-integer-or-nil 'sexp
  97. "An integer or the value nil."
  98. :value nil
  99. :tag "Optional integer"
  100. :match (lambda (widget value) (or (integerp value) (null value))))
  101. (define-widget 'c-symbol-list 'sexp
  102. "A single symbol or a list of symbols."
  103. :tag "Symbols separated by spaces"
  104. :validate 'widget-field-validate
  105. :match
  106. (lambda (widget value)
  107. (or (symbolp value)
  108. (catch 'ok
  109. (while (listp value)
  110. (unless (symbolp (car value))
  111. (throw 'ok nil))
  112. (setq value (cdr value)))
  113. (null value))))
  114. :value-to-internal
  115. (lambda (widget value)
  116. (cond ((null value)
  117. "")
  118. ((symbolp value)
  119. (symbol-name value))
  120. ((consp value)
  121. (mapconcat (lambda (symbol)
  122. (symbol-name symbol))
  123. value
  124. " "))
  125. (t
  126. value)))
  127. :value-to-external
  128. (lambda (widget value)
  129. (if (stringp value)
  130. (let (list end)
  131. (while (string-match "\\S +" value end)
  132. (setq list (cons (intern (match-string 0 value)) list)
  133. end (match-end 0)))
  134. (if (and list (not (cdr list)))
  135. (car list)
  136. (nreverse list)))
  137. value)))
  138. (defvar c-style-variables
  139. '(c-basic-offset c-comment-only-line-offset c-indent-comment-alist
  140. c-indent-comments-syntactically-p c-block-comment-prefix
  141. c-comment-prefix-regexp c-doc-comment-style c-cleanup-list
  142. c-hanging-braces-alist c-hanging-colons-alist
  143. c-hanging-semi&comma-criteria c-backslash-column c-backslash-max-column
  144. c-special-indent-hook c-label-minimum-indentation c-offsets-alist)
  145. "List of the style variables.")
  146. (defvar c-fallback-style nil)
  147. (defsubst c-set-stylevar-fallback (name val)
  148. (put name 'c-stylevar-fallback val)
  149. (setq c-fallback-style (cons (cons name val) c-fallback-style)))
  150. (defmacro defcustom-c-stylevar (name val doc &rest args)
  151. "Define a style variable NAME with VAL and DOC.
  152. More precisely, convert the given `:type FOO', mined out of ARGS,
  153. to an aggregate `:type (radio STYLE (PREAMBLE FOO))', append some
  154. some boilerplate documentation to DOC, arrange for the fallback
  155. value of NAME to be VAL, and call `custom-declare-variable' to
  156. do the rest of the work.
  157. STYLE stands for the choice where the value is taken from some
  158. style setting. PREAMBLE is optionally prepended to FOO; that is,
  159. if FOO contains :tag or :value, the respective two-element list
  160. component is ignored."
  161. (declare (debug (symbolp form stringp &rest)))
  162. (let* ((expanded-doc (concat doc "
  163. This is a style variable. Apart from the valid values described
  164. above, it can be set to the symbol `set-from-style'. In that case,
  165. it takes its value from the style system (see `c-default-style' and
  166. `c-style-alist') when a CC Mode buffer is initialized. Otherwise,
  167. the value set here overrides the style system (there is a variable
  168. `c-old-style-variable-behavior' that changes this, though)."))
  169. (typ (eval (plist-get args :type)))
  170. (type (if (consp typ) typ (list typ)))
  171. (head (car type))
  172. (tail (cdr type))
  173. (newt (append (unless (plist-get tail :tag)
  174. '(:tag "Override style settings"))
  175. (unless (plist-get tail :value)
  176. `(:value ,(eval val)))
  177. tail))
  178. (aggregate `'(radio
  179. (const :tag "Use style settings" set-from-style)
  180. ,(cons head newt))))
  181. `(progn
  182. (c-set-stylevar-fallback ',name ,val)
  183. (custom-declare-variable
  184. ',name ''set-from-style
  185. ,expanded-doc
  186. ,@(plist-put args :type aggregate)))))
  187. (defun c-valid-offset (offset)
  188. "Return non-nil if OFFSET is a valid offset for a syntactic symbol.
  189. See `c-offsets-alist'."
  190. (or (eq offset '+)
  191. (eq offset '-)
  192. (eq offset '++)
  193. (eq offset '--)
  194. (eq offset '*)
  195. (eq offset '/)
  196. (integerp offset)
  197. (functionp offset)
  198. (and (symbolp offset) (boundp offset))
  199. (and (vectorp offset)
  200. (= (length offset) 1)
  201. (integerp (elt offset 0)))
  202. (and (consp offset)
  203. (not (eq (car offset) 'quote)) ; Detect misquoted lists.
  204. (progn
  205. (when (memq (car offset) '(first min max add))
  206. (setq offset (cdr offset)))
  207. (while (and (consp offset)
  208. (c-valid-offset (car offset)))
  209. (setq offset (cdr offset)))
  210. (null offset)))))
  211. ;;; User variables
  212. (defcustom c-strict-syntax-p nil
  213. "*If non-nil, all syntactic symbols must be found in `c-offsets-alist'.
  214. If the syntactic symbol for a particular line does not match a symbol
  215. in the offsets alist, or if no non-nil offset value can be determined
  216. for a symbol, an error is generated, otherwise no error is reported
  217. and the syntactic symbol is ignored.
  218. This variable is considered obsolete; it doesn't work well with lineup
  219. functions that return nil to support the feature of using lists on
  220. syntactic symbols in `c-offsets-alist'. Please keep it set to nil."
  221. :type 'boolean
  222. :group 'c)
  223. (defcustom c-echo-syntactic-information-p nil
  224. "*If non-nil, syntactic info is echoed when the line is indented."
  225. :type 'boolean
  226. :group 'c)
  227. (defcustom c-report-syntactic-errors nil
  228. "*If non-nil, certain syntactic errors are reported with a ding
  229. and a message, for example when an \"else\" is indented for which
  230. there's no corresponding \"if\".
  231. Note however that CC Mode doesn't make any special effort to check for
  232. syntactic errors; that's the job of the compiler. The reason it can
  233. report cases like the one above is that it can't find the correct
  234. anchoring position to indent the line in that case."
  235. :type 'boolean
  236. :group 'c)
  237. (defcustom-c-stylevar c-basic-offset 4
  238. "*Amount of basic offset used by + and - symbols in `c-offsets-alist'.
  239. Also used as the indentation step when `c-syntactic-indentation' is
  240. nil."
  241. :type 'integer
  242. :group 'c)
  243. ;;;###autoload(put 'c-basic-offset 'safe-local-variable 'integerp)
  244. (defcustom c-tab-always-indent t
  245. "*Controls the operation of the TAB key.
  246. If t, hitting TAB always just indents the current line. If nil, hitting
  247. TAB indents the current line if point is at the left margin or in the
  248. line's indentation, otherwise it calls `c-insert-tab-function' to
  249. insert a `real' tab character. If some other value (neither nil nor t),
  250. then inserts a tab only within literals (comments and strings), but
  251. always reindents the line.
  252. Note: the variable `c-comment-only-line-offset' also controls the
  253. indentation of lines containing only comments."
  254. :type '(radio
  255. (const :tag "TAB key always indents, never inserts TAB" t)
  256. (const :tag "TAB key indents in left margin, otherwise inserts TAB" nil)
  257. (other :tag "TAB key inserts TAB in literals, otherwise indents" other))
  258. :group 'c)
  259. (defcustom c-insert-tab-function 'insert-tab
  260. "*Function used when inserting a tab for \\[c-indent-command].
  261. Only used when `c-tab-always-indent' indicates a `real' tab character
  262. should be inserted. Value must be a function taking no arguments.
  263. The default, `insert-tab', inserts either a tab or the equivalent
  264. number of spaces depending on the value of `indent-tabs-mode'."
  265. :type 'function
  266. :group 'c)
  267. (defcustom c-syntactic-indentation t
  268. "*Whether the indentation should be controlled by the syntactic context.
  269. If t, the indentation functions indent according to the syntactic
  270. context, using the style settings specified by `c-offsets-alist'.
  271. If nil, every line is just indented to the same level as the previous
  272. one, and the \\[c-indent-command] command adjusts the indentation in
  273. steps specified by `c-basic-offset'. The indentation style has no
  274. effect in this mode, nor any of the indentation associated variables,
  275. e.g. `c-special-indent-hook'."
  276. :type 'boolean
  277. :group 'c)
  278. (make-variable-buffer-local 'c-syntactic-indentation)
  279. (put 'c-syntactic-indentation 'safe-local-variable 'booleanp)
  280. (defcustom c-syntactic-indentation-in-macros t
  281. "*Enable syntactic analysis inside macros.
  282. If this is nil, all lines inside macro definitions are analyzed as
  283. `cpp-macro-cont'. Otherwise they are analyzed syntactically, just
  284. like normal code, and `cpp-define-intro' is used to create the
  285. additional indentation of the bodies of \"#define\" macros.
  286. Having this enabled simplifies editing of large multiline macros, but
  287. it might complicate editing if CC Mode doesn't recognize the context
  288. of the macro content. The default context inside the macro is the
  289. same as the top level, so if it contains \"bare\" statements they
  290. might be indented wrongly, although there are special cases that
  291. handle this in most cases. If this problem occurs, it's usually
  292. countered easily by surrounding the statements by a block \(or even
  293. better with the \"do { ... } while \(0)\" trick)."
  294. :type 'boolean
  295. :group 'c)
  296. (put 'c-syntactic-indentation-in-macros 'safe-local-variable 'booleanp)
  297. (defcustom c-defun-tactic 'go-outward
  298. "*Whether functions are recognized inside, e.g., a class.
  299. This is used by `c-beginning-of-defun' and like functions.
  300. Its value is one of:
  301. t -- Functions are recognized only at the top level.
  302. go-outward -- Nested functions are also recognized. Should a function
  303. command hit the beginning/end of a nested scope, it will
  304. carry on at the less nested level."
  305. :version "24.1"
  306. :type '(radio
  307. (const :tag "Functions are at the top-level" t)
  308. (const :tag "Functions are also recognized inside declaration scopes" go-outward))
  309. :group 'c)
  310. (defcustom-c-stylevar c-comment-only-line-offset 0
  311. "*Extra offset for line which contains only the start of a comment.
  312. Can contain an integer or a cons cell of the form:
  313. (NON-ANCHORED-OFFSET . ANCHORED-OFFSET)
  314. Where NON-ANCHORED-OFFSET is the amount of offset given to
  315. non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is
  316. the amount of offset to give column-zero anchored comment-only lines.
  317. Just an integer as value is equivalent to (<val> . -1000).
  318. Note that this variable only has effect when the `c-lineup-comment'
  319. lineup function is used on the `comment-intro' syntactic symbol (the
  320. default)."
  321. :type '(choice (integer :tag "Non-anchored offset" 0)
  322. (cons :tag "Non-anchored & anchored offset"
  323. :value (0 . 0)
  324. (integer :tag "Non-anchored offset")
  325. (integer :tag "Anchored offset")))
  326. :group 'c)
  327. (defcustom-c-stylevar c-indent-comment-alist
  328. '((anchored-comment . (column . 0))
  329. (end-block . (space . 1))
  330. (cpp-end-block . (space . 2)))
  331. "*Specifies how \\[indent-for-comment] calculates the comment start column.
  332. This is an association list that contains entries of the form:
  333. (LINE-TYPE . INDENT-SPEC)
  334. LINE-TYPE specifies a type of line as described below, and INDENT-SPEC
  335. says what \\[indent-for-comment] should do when used on that type of line.
  336. The recognized values for LINE-TYPE are:
  337. empty-line -- The line is empty.
  338. anchored-comment -- The line contains a comment that starts in column 0.
  339. end-block -- The line contains a solitary block closing brace.
  340. cpp-end-block -- The line contains a preprocessor directive that
  341. closes a block, i.e. either \"#endif\" or \"#else\".
  342. other -- The line does not match any other entry
  343. currently on the list.
  344. An INDENT-SPEC is a cons cell of the form:
  345. (ACTION . VALUE)
  346. ACTION says how \\[indent-for-comment] should align the comment, and
  347. VALUE is interpreted depending on ACTION. ACTION can be any of the
  348. following:
  349. space -- Put VALUE spaces between the end of the line and the start
  350. of the comment.
  351. column -- Start the comment at the column VALUE. If the line is
  352. longer than that, the comment is preceded by a single
  353. space. If VALUE is nil, `comment-column' is used.
  354. align -- Align the comment with one on the previous line, if there
  355. is any. If the line is too long, the comment is preceded
  356. by a single space. If there isn't a comment start on the
  357. previous line, the behavior is specified by VALUE, which
  358. in turn is interpreted as an INDENT-SPEC.
  359. If a LINE-TYPE is missing, then \\[indent-for-comment] indents the comment
  360. according to `comment-column'.
  361. Note that a non-nil value on `c-indent-comments-syntactically-p'
  362. overrides this variable, so empty lines are indented syntactically
  363. in that case, i.e. as if \\[c-indent-command] was used instead."
  364. :type
  365. (let ((space '(cons :tag "space"
  366. :format "%v"
  367. :value (space . 1)
  368. (const :format "space " space)
  369. (integer :format "%v")))
  370. (column '(cons :tag "column"
  371. :format "%v"
  372. (const :format "column " column)
  373. (c-integer-or-nil :format "%v"))))
  374. `(set ,@(mapcar
  375. (lambda (elt)
  376. `(cons :format "%v"
  377. ,(c-constant-symbol elt 20)
  378. (choice
  379. :format "%[Choice%] %v"
  380. :value (column . nil)
  381. ,space
  382. ,column
  383. (cons :tag "align"
  384. :format "%v"
  385. (const :format "align " align)
  386. (choice
  387. :format "%[Choice%] %v"
  388. :value (column . nil)
  389. ,space
  390. ,column)))))
  391. '(empty-line anchored-comment end-block cpp-end-block other))))
  392. :group 'c)
  393. (defcustom-c-stylevar c-indent-comments-syntactically-p nil
  394. "*Specifies how \\[indent-for-comment] should handle comment-only lines.
  395. When this variable is non-nil, comment-only lines are indented
  396. according to syntactic analysis via `c-offsets-alist'. Otherwise, the
  397. comment is indented as if it was preceded by code. Note that this
  398. variable does not affect how the normal line indentation treats
  399. comment-only lines."
  400. :type 'boolean
  401. :group 'c)
  402. (make-obsolete-variable 'c-comment-continuation-stars
  403. 'c-block-comment-prefix "21.1")
  404. ;; Although c-comment-continuation-stars is obsolete, we look at it in
  405. ;; some places in CC Mode anyway, so make the compiler ignore it
  406. ;; during our compilation.
  407. ;; [This is unclean; better to use `symbol-value'. --ttn]
  408. ;;(cc-bytecomp-obsolete-var c-comment-continuation-stars)
  409. ;;(cc-bytecomp-defvar c-comment-continuation-stars)
  410. (defcustom-c-stylevar c-block-comment-prefix
  411. (if (boundp 'c-comment-continuation-stars)
  412. (symbol-value 'c-comment-continuation-stars)
  413. "* ")
  414. "*Specifies the line prefix of continued C-style block comments.
  415. You should set this variable to the literal string that gets inserted
  416. at the front of continued block style comment lines. This should
  417. either be the empty string, or some characters without preceding
  418. spaces. To adjust the alignment under the comment starter, put an
  419. appropriate value on the `c' syntactic symbol (see the
  420. `c-offsets-alist' variable).
  421. It's only used when a one-line block comment is broken into two or
  422. more lines for the first time; otherwise the appropriate prefix is
  423. adapted from the comment. This variable is not used for C++ line
  424. style comments."
  425. :type 'string
  426. :group 'c)
  427. (defcustom-c-stylevar c-comment-prefix-regexp
  428. '((pike-mode . "//+!?\\|\\**")
  429. (awk-mode . "#+")
  430. (other . "//+\\|\\**"))
  431. "*Regexp to match the line prefix inside comments.
  432. This regexp is used to recognize the fill prefix inside comments for
  433. correct paragraph filling and other things.
  434. If this variable is a string, it will be used in all CC Mode major
  435. modes. It can also be an association list, to associate specific
  436. regexps to specific major modes. The symbol for the major mode is
  437. looked up in the association list, and its value is used as the line
  438. prefix regexp. If it's not found, then the symbol `other' is looked
  439. up and its value is used instead.
  440. The regexp should match the prefix used in both C++ style line
  441. comments and C style block comments, but it does not need to match a
  442. block comment starter. In other words, it should at least match
  443. \"//\" for line comments and the string in `c-block-comment-prefix',
  444. which is sometimes inserted by CC Mode inside block comments. It
  445. should not match any surrounding whitespace.
  446. Note that CC Mode uses this variable to set many other variables that
  447. handle the paragraph filling. That's done at mode initialization or
  448. when you switch to a style which sets this variable. Thus, if you
  449. change it in some other way, e.g. interactively in a CC Mode buffer,
  450. you will need to do \\[c-setup-paragraph-variables] afterwards so that
  451. the other variables are updated with the new value.
  452. Note also that when CC Mode starts up, all variables are initialized
  453. before the mode hooks are run. It's therefore necessary to make a
  454. call to `c-setup-paragraph-variables' explicitly if you change this
  455. variable in a mode hook."
  456. :type '(radio
  457. (regexp :tag "Regexp for all modes")
  458. (list
  459. :tag "Mode-specific regexps"
  460. (set
  461. :inline t :format "%v"
  462. (cons :format "%v"
  463. (const :format "C " c-mode) (regexp :format "%v"))
  464. (cons :format "%v"
  465. (const :format "C++ " c++-mode) (regexp :format "%v"))
  466. (cons :format "%v"
  467. (const :format "ObjC " objc-mode) (regexp :format "%v"))
  468. (cons :format "%v"
  469. (const :format "Java " java-mode) (regexp :format "%v"))
  470. (cons :format "%v"
  471. (const :format "IDL " idl-mode) (regexp :format "%v"))
  472. (cons :format "%v"
  473. (const :format "Pike " pike-mode) (regexp :format "%v"))
  474. (cons :format "%v"
  475. (const :format "AWK " awk-mode) (regexp :format "%v")))
  476. (cons :format " %v"
  477. (const :format "Other " other) (regexp :format "%v"))))
  478. :group 'c)
  479. (defcustom-c-stylevar c-doc-comment-style
  480. '((java-mode . javadoc)
  481. (pike-mode . autodoc)
  482. (c-mode . gtkdoc))
  483. "*Specifies documentation comment style(s) to recognize.
  484. This is primarily used to fontify doc comments and the markup within
  485. them, e.g. Javadoc comments.
  486. The value can be any of the following symbols for various known doc
  487. comment styles:
  488. javadoc -- Javadoc style for \"/** ... */\" comments (default in Java mode).
  489. autodoc -- Pike autodoc style for \"//! ...\" comments (default in Pike mode).
  490. gtkdoc -- GtkDoc style for \"/** ... **/\" comments (default in C mode).
  491. The value may also be a list of doc comment styles, in which case all
  492. of them are recognized simultaneously (presumably with markup cues
  493. that don't conflict).
  494. The value may also be an association list to specify different doc
  495. comment styles for different languages. The symbol for the major mode
  496. is then looked up in the alist, and the value of that element is
  497. interpreted as above if found. If it isn't found then the symbol
  498. `other' is looked up and its value is used instead.
  499. Note that CC Mode uses this variable to set other variables that
  500. handle fontification etc. That's done at mode initialization or when
  501. you switch to a style which sets this variable. Thus, if you change
  502. it in some other way, e.g. interactively in a CC Mode buffer, you will
  503. need to do \\[java-mode] (or whatever mode you're currently using) to
  504. reinitialize.
  505. Note also that when CC Mode starts up, the other variables are
  506. modified before the mode hooks are run. If you change this variable
  507. in a mode hook, you have to call `c-setup-doc-comment-style'
  508. afterwards to redo that work."
  509. ;; Symbols other than those documented above may be used on this
  510. ;; variable. If a variable exists that has that name with
  511. ;; "-font-lock-keywords" appended, its value is prepended to the
  512. ;; font lock keywords list. If it's a function then it's called and
  513. ;; the result is prepended.
  514. :type '(radio
  515. (c-symbol-list :tag "Doc style(s) in all modes")
  516. (list
  517. :tag "Mode-specific doc styles"
  518. (set
  519. :inline t :format "%v"
  520. (cons :format "%v"
  521. (const :format "C " c-mode)
  522. (c-symbol-list :format "%v"))
  523. (cons :format "%v"
  524. (const :format "C++ " c++-mode)
  525. (c-symbol-list :format "%v"))
  526. (cons :format "%v"
  527. (const :format "ObjC " objc-mode)
  528. (c-symbol-list :format "%v"))
  529. (cons :format "%v"
  530. (const :format "Java " java-mode)
  531. (c-symbol-list :format "%v"))
  532. (cons :format "%v"
  533. (const :format "IDL " idl-mode)
  534. (c-symbol-list :format "%v"))
  535. (cons :format "%v"
  536. (const :format "Pike " pike-mode)
  537. (c-symbol-list :format "%v"))
  538. (cons :format "%v"
  539. (const :format "AWK " awk-mode)
  540. (c-symbol-list :format "%v"))
  541. (cons :format "%v"
  542. (const :format "Other " other)
  543. (c-symbol-list :format "%v")))))
  544. :group 'c)
  545. (defcustom c-ignore-auto-fill '(string cpp code)
  546. "*List of contexts in which automatic filling never occurs.
  547. If Auto Fill mode is active, it will be temporarily disabled if point
  548. is in any context on this list. It's e.g. useful to enable Auto Fill
  549. in comments only, but not in strings or normal code. The valid
  550. contexts are:
  551. string -- inside a string or character literal
  552. c -- inside a C style block comment
  553. c++ -- inside a C++ style line comment
  554. cpp -- inside a preprocessor directive
  555. code -- anywhere else, i.e. in normal code"
  556. :type '(set
  557. (const :tag "String literals" string)
  558. (const :tag "C style block comments" c)
  559. (const :tag "C++ style line comments" c++)
  560. (const :tag "Preprocessor directives" cpp)
  561. (const :tag "Normal code" code))
  562. :group 'c)
  563. (defcustom-c-stylevar c-cleanup-list '(scope-operator)
  564. "*List of various C/C++/ObjC constructs to \"clean up\".
  565. The following clean ups only take place when the auto-newline feature
  566. is turned on, as evidenced by the `/la' appearing next to the mode
  567. name:
  568. brace-else-brace -- Clean up \"} else {\" constructs by placing
  569. entire construct on a single line. This clean
  570. up only takes place when there is nothing but
  571. white space between the braces and the `else'.
  572. Clean up occurs when the open brace after the
  573. `else' is typed.
  574. brace-elseif-brace -- Similar to brace-else-brace, but clean up
  575. \"} else if (...) {\" constructs. Clean up
  576. occurs after the open parenthesis and the open
  577. brace.
  578. brace-catch-brace -- Similar to brace-elseif-brace, but clean up
  579. \"} catch (...) {\" constructs.
  580. empty-defun-braces -- Clean up empty defun braces by placing the
  581. braces on the same line. Clean up occurs when
  582. the defun closing brace is typed.
  583. one-liner-defun -- If the code inside a function body can fit in
  584. a single line, then remove any newlines
  585. between that line and the defun braces so that
  586. the whole body becomes a single line.
  587. `c-max-one-liner-length' gives the maximum
  588. length allowed for the resulting line. Clean
  589. up occurs when the closing brace is typed.
  590. defun-close-semi -- Clean up the terminating semi-colon on defuns
  591. by placing the semi-colon on the same line as
  592. the closing brace. Clean up occurs when the
  593. semi-colon is typed.
  594. list-close-comma -- Clean up commas following braces in array
  595. and aggregate initializers. Clean up occurs
  596. when the comma is typed.
  597. scope-operator -- Clean up double colons which may designate
  598. a C++ scope operator split across multiple
  599. lines. Note that certain C++ constructs can
  600. generate ambiguous situations. This clean up
  601. only takes place when there is nothing but
  602. whitespace between colons. Clean up occurs
  603. when the second colon is typed.
  604. The following clean ups always take place when they are on this list,
  605. regardless of the auto-newline feature, since they typically don't
  606. involve auto-newline inserted newlines:
  607. space-before-funcall -- Insert exactly one space before the opening
  608. parenthesis of a function call. Clean up
  609. occurs when the opening parenthesis is typed.
  610. compact-empty-funcall -- Clean up any space before the function call
  611. opening parenthesis if and only if the
  612. argument list is empty. This is typically
  613. useful together with `space-before-funcall' to
  614. get the style \"foo (bar)\" and \"foo()\".
  615. Clean up occurs when the closing parenthesis
  616. is typed.
  617. comment-close-slash -- When a slash is typed after the comment prefix
  618. on a bare line in a c-style comment, the comment
  619. is closed by cleaning up preceding space and
  620. inserting a star if needed."
  621. :type '(set
  622. (const :tag "Put \"} else {\" on one line (brace-else-brace)"
  623. brace-else-brace)
  624. (const :tag "Put \"} else if (...) {\" on one line (brace-elseif-brace)"
  625. brace-elseif-brace)
  626. (const :tag "Put \"} catch (...) {\" on one line (brace-catch-brace)"
  627. brace-catch-brace)
  628. (const :tag "Put empty defun braces on one line (empty-defun-braces)"
  629. empty-defun-braces)
  630. (const :tag "Put short function bodies on one line (one-liner-defun)"
  631. one-liner-defun)
  632. (const :tag "Put \"};\" ending defuns on one line (defun-close-semi)"
  633. defun-close-semi)
  634. (const :tag "Put \"},\" in aggregates on one line (list-close-comma)"
  635. list-close-comma)
  636. (const :tag "Put C++ style \"::\" on one line (scope-operator)"
  637. scope-operator)
  638. (const :tag "Put a space before funcall parens, e.g. \"foo (bar)\" (space-before-funcall)"
  639. space-before-funcall)
  640. (const :tag "Remove space before empty funcalls, e.g. \"foo()\" (compact-empty-funcall)"
  641. compact-empty-funcall)
  642. (const :tag "Make / on a bare line of a C-style comment close it (comment-close-slash)"
  643. comment-close-slash))
  644. :group 'c)
  645. (defcustom-c-stylevar c-hanging-braces-alist '((brace-list-open)
  646. (brace-entry-open)
  647. (statement-cont)
  648. (substatement-open after)
  649. (block-close . c-snug-do-while)
  650. (extern-lang-open after)
  651. (namespace-open after)
  652. (module-open after)
  653. (composition-open after)
  654. (inexpr-class-open after)
  655. (inexpr-class-close before)
  656. (arglist-cont-nonempty))
  657. "*Controls the insertion of newlines before and after braces
  658. when the auto-newline feature is active. This variable contains an
  659. association list with elements of the following form:
  660. \(SYNTACTIC-SYMBOL . ACTION).
  661. When a brace (either opening or closing) is inserted, the syntactic
  662. context it defines is looked up in this list, and if found, the
  663. associated ACTION is used to determine where newlines are inserted.
  664. If the context is not found, the default is to insert a newline both
  665. before and after the brace.
  666. SYNTACTIC-SYMBOL can be statement-cont, brace-list-intro,
  667. inexpr-class-open, inexpr-class-close, and any of the *-open and
  668. *-close symbols. See `c-offsets-alist' for details, except for
  669. inexpr-class-open and inexpr-class-close, which doesn't have any
  670. corresponding symbols there. Those two symbols are used for the
  671. opening and closing braces, respectively, of anonymous inner classes
  672. in Java.
  673. ACTION can be either a function symbol or a list containing any
  674. combination of the symbols `before' or `after'. If the list is empty,
  675. no newlines are inserted either before or after the brace.
  676. When ACTION is a function symbol, the function is called with a two
  677. arguments: the syntactic symbol for the brace and the buffer position
  678. at which the brace was inserted. The function must return a list as
  679. described in the preceding paragraph. Note that during the call to
  680. the function, the variable `c-syntactic-context' is set to the entire
  681. syntactic context for the brace line."
  682. :type
  683. `(set ,@(mapcar
  684. (lambda (elt)
  685. `(cons :format "%v"
  686. ,(c-constant-symbol elt 24)
  687. (choice :format "%[Choice%] %v"
  688. :value (before after)
  689. (set :menu-tag "Before/after"
  690. :format "Newline %v brace\n"
  691. (const :format "%v, " before)
  692. (const :format "%v " after))
  693. (function :menu-tag "Function"
  694. :format "Run function: %v"))))
  695. '(defun-open defun-close
  696. class-open class-close
  697. inline-open inline-close
  698. block-open block-close
  699. statement-cont substatement-open statement-case-open
  700. brace-list-open brace-list-close
  701. brace-list-intro brace-entry-open
  702. extern-lang-open extern-lang-close
  703. namespace-open namespace-close
  704. module-open module-close
  705. composition-open composition-close
  706. inexpr-class-open inexpr-class-close
  707. arglist-cont-nonempty)))
  708. :group 'c)
  709. (defcustom c-max-one-liner-length 80
  710. "Maximum length of line that clean-up \"one-liner-defun\" will compact to.
  711. Zero or nil means no limit."
  712. :type 'integer
  713. :group 'c)
  714. (defcustom-c-stylevar c-hanging-colons-alist nil
  715. "*Controls the insertion of newlines before and after certain colons.
  716. This variable contains an association list with elements of the
  717. following form: (SYNTACTIC-SYMBOL . ACTION).
  718. SYNTACTIC-SYMBOL can be any of: case-label, label, access-label,
  719. member-init-intro, or inher-intro.
  720. See the variable `c-hanging-braces-alist' for the semantics of this
  721. variable. Note however that making ACTION a function symbol is
  722. currently not supported for this variable."
  723. :type
  724. `(set ,@(mapcar
  725. (lambda (elt)
  726. `(cons :format "%v"
  727. ,(c-constant-symbol elt 20)
  728. (set :format "Newline %v colon\n"
  729. (const :format "%v, " before)
  730. (const :format "%v" after))))
  731. '(case-label label access-label member-init-intro inher-intro)))
  732. :group 'c)
  733. (defcustom-c-stylevar c-hanging-semi&comma-criteria
  734. '(c-semi&comma-inside-parenlist)
  735. "*List of functions that decide whether to insert a newline or not.
  736. The functions in this list are called, in order, whenever the
  737. auto-newline minor mode is activated (as evidenced by a `/a' or `/ah'
  738. string in the mode line), and a semicolon or comma is typed (see
  739. `c-electric-semi&comma'). Each function in this list is called with
  740. no arguments, and should return one of the following values:
  741. nil -- no determination made, continue checking
  742. 'stop -- do not insert a newline, and stop checking
  743. (anything else) -- insert a newline, and stop checking
  744. If every function in the list is called with no determination made,
  745. then no newline is inserted."
  746. :type '(repeat function)
  747. :group 'c)
  748. (defcustom-c-stylevar c-backslash-column 48
  749. "*Minimum alignment column for line continuation backslashes.
  750. This is used by the functions that automatically insert or align the
  751. line continuation backslashes in multiline macros. If any line in the
  752. macro exceeds this column then the next tab stop from that line is
  753. used as alignment column instead. See also `c-backslash-max-column'."
  754. :type 'integer
  755. :group 'c)
  756. ;;;###autoload(put 'c-backslash-column 'safe-local-variable 'integerp)
  757. (defcustom-c-stylevar c-backslash-max-column 72
  758. "*Maximum alignment column for line continuation backslashes.
  759. This is used by the functions that automatically insert or align the
  760. line continuation backslashes in multiline macros. If any line in the
  761. macro exceeds this column then the backslashes for the other lines
  762. will be aligned at this column."
  763. :type 'integer
  764. :group 'c)
  765. (defcustom c-auto-align-backslashes t
  766. "*Align automatically inserted line continuation backslashes.
  767. When line continuation backslashes are inserted automatically for line
  768. breaks in multiline macros, e.g. by \\[c-context-line-break], they are
  769. aligned with the other backslashes in the same macro if this flag is
  770. set. Otherwise the inserted backslashes are preceded by a single
  771. space."
  772. :type 'boolean
  773. :group 'c)
  774. (defcustom c-backspace-function 'backward-delete-char-untabify
  775. "*Function called by `c-electric-backspace' when deleting backwards."
  776. :type 'function
  777. :group 'c)
  778. (defcustom c-delete-function 'delete-char
  779. "*Function called by `c-electric-delete-forward' when deleting forwards."
  780. :type 'function
  781. :group 'c)
  782. (defcustom c-require-final-newline
  783. ;; C and C++ mandate that all nonempty files should end with a
  784. ;; newline. Objective-C refers to C for all things it doesn't
  785. ;; specify, so the same holds there. The other languages do not
  786. ;; require it (at least not explicitly in a normative text).
  787. '((c-mode . t)
  788. (c++-mode . t)
  789. (objc-mode . t))
  790. "*Controls whether a final newline is ensured when the file is saved.
  791. The value is an association list that for each language mode specifies
  792. the value to give to `require-final-newline' at mode initialization;
  793. see that variable for details about the value. If a language isn't
  794. present on the association list, CC Mode won't touch
  795. `require-final-newline' in buffers for that language."
  796. :type `(set (cons :format "%v"
  797. (const :format "C " c-mode)
  798. (symbol :format "%v" :value ,require-final-newline))
  799. (cons :format "%v"
  800. (const :format "C++ " c++-mode)
  801. (symbol :format "%v" :value ,require-final-newline))
  802. (cons :format "%v"
  803. (const :format "ObjC " objc-mode)
  804. (symbol :format "%v" :value ,require-final-newline))
  805. (cons :format "%v"
  806. (const :format "Java " java-mode)
  807. (symbol :format "%v" :value ,require-final-newline))
  808. (cons :format "%v"
  809. (const :format "IDL " idl-mode)
  810. (symbol :format "%v" :value ,require-final-newline))
  811. (cons :format "%v"
  812. (const :format "Pike " pike-mode)
  813. (symbol :format "%v" :value ,require-final-newline))
  814. (cons :format "%v"
  815. (const :format "AWK " awk-mode)
  816. (symbol :format "%v" :value ,require-final-newline)))
  817. :group 'c)
  818. (defcustom c-electric-pound-behavior nil
  819. "*List of behaviors for electric pound insertion.
  820. Only currently supported behavior is `alignleft'."
  821. :type '(set (const alignleft))
  822. :group 'c)
  823. (defcustom c-special-indent-hook nil
  824. "*Hook for user defined special indentation adjustments.
  825. This hook gets called after each line is indented by the mode. It is only
  826. called if `c-syntactic-indentation' is non-nil."
  827. :type 'hook
  828. :group 'c)
  829. (defcustom-c-stylevar c-label-minimum-indentation 1
  830. "*Minimum indentation for lines inside code blocks.
  831. This variable typically only affects code using the `gnu' style, which
  832. mandates a minimum of one space in front of every line inside code
  833. blocks. Specifically, the function `c-gnu-impose-minimum' on your
  834. `c-special-indent-hook' is what enforces this."
  835. :type 'integer
  836. :group 'c)
  837. (defcustom c-progress-interval 5
  838. "*Interval used to update progress status during long re-indentation.
  839. If a number, percentage complete gets updated after each interval of
  840. that many seconds. To inhibit all messages during indentation, set
  841. this variable to nil."
  842. :type 'integer
  843. :group 'c)
  844. (defcustom c-objc-method-arg-min-delta-to-bracket 2
  845. "*Minimum number of chars to the opening bracket.
  846. Consider this ObjC snippet:
  847. [foo blahBlah: fred
  848. |<-x->|barBaz: barney
  849. If `x' is less than this number then `c-lineup-ObjC-method-call-colons'
  850. will defer the indentation decision to the next function. By default
  851. this is `c-lineup-ObjC-method-call', which would align it like:
  852. [foo blahBlahBlah: fred
  853. thisIsTooDamnLong: barney
  854. This behavior can be overridden by customizing the indentation of
  855. `objc-method-call-cont' in the \"objc\" style."
  856. :type 'integer
  857. :group 'c)
  858. (defcustom c-objc-method-arg-unfinished-offset 4
  859. "*Offset relative to bracket if first selector is on a new line.
  860. [aaaaaaaaa
  861. |<-x->|bbbbbbb: cccccc
  862. ddddd: eeee];"
  863. :type 'integer
  864. :group 'c)
  865. (defcustom c-objc-method-parameter-offset 4
  866. "*Offset for selector parameter on a new line (relative to first selector.
  867. [aaaaaaa bbbbbbbbbb:
  868. |<-x->|cccccccc
  869. ddd: eeee
  870. ffff: ggg];"
  871. :type 'integer
  872. :group 'c)
  873. (defcustom c-default-style '((java-mode . "java") (awk-mode . "awk")
  874. (other . "gnu"))
  875. "*Style which gets installed by default when a file is visited.
  876. The value of this variable can be any style defined in
  877. `c-style-alist', including styles you add. The value can also be an
  878. association list of major mode symbols to style names.
  879. When the value is a string, all CC Mode major modes will install this
  880. style by default.
  881. When the value is an alist, the major mode symbol is looked up in it
  882. and the associated style is installed. If the major mode is not
  883. listed in the alist, then the symbol `other' is looked up in it, and
  884. if found, the style in that entry is used. If `other' is not found in
  885. the alist, then \"gnu\" style is used.
  886. The default style gets installed before your mode hooks run, so you
  887. can always override the use of `c-default-style' by making calls to
  888. `c-set-style' in the appropriate mode hook."
  889. :type '(radio
  890. (string :tag "Style in all modes")
  891. (set :tag "Mode-specific styles"
  892. (cons :format "%v"
  893. (const :format "C " c-mode) (string :format "%v"))
  894. (cons :format "%v"
  895. (const :format "C++ " c++-mode) (string :format "%v"))
  896. (cons :format "%v"
  897. (const :format "ObjC " objc-mode) (string :format "%v"))
  898. (cons :format "%v"
  899. (const :format "Java " java-mode) (string :format "%v"))
  900. (cons :format "%v"
  901. (const :format "IDL " idl-mode) (string :format "%v"))
  902. (cons :format "%v"
  903. (const :format "Pike " pike-mode) (string :format "%v"))
  904. (cons :format "%v"
  905. (const :format "AWK " awk-mode) (string :format "%v"))
  906. (cons :format "%v"
  907. (const :format "Other " other) (string :format "%v"))))
  908. :group 'c)
  909. ;; *) At the start of a statement or declaration means in more detail:
  910. ;; At the closest preceding statement/declaration that starts at boi
  911. ;; and doesn't have a label or comment at that position. If there's
  912. ;; no such statement within the same block, then back up to the
  913. ;; surrounding block or statement, add the appropriate
  914. ;; statement-block-intro, defun-block-intro or substatement syntax
  915. ;; symbol and continue searching.
  916. (c-set-stylevar-fallback 'c-offsets-alist
  917. '((string . c-lineup-dont-change)
  918. ;; Anchor pos: Beg of previous line.
  919. (c . c-lineup-C-comments)
  920. ;; Anchor pos: Beg of the comment.
  921. (defun-open . 0)
  922. ;; Anchor pos: When inside a class: Boi at the func decl start.
  923. ;; When at top level: Bol at the func decl start. When inside
  924. ;; a code block (only possible in Pike): At the func decl
  925. ;; start(*).
  926. (defun-close . 0)
  927. ;; Anchor pos: At the defun block open if it's at boi,
  928. ;; otherwise boi at the func decl start.
  929. (defun-block-intro . +)
  930. ;; Anchor pos: At the block open(*).
  931. (class-open . 0)
  932. ;; Anchor pos: Boi at the class decl start.
  933. (class-close . 0)
  934. ;; Anchor pos: Boi at the class decl start.
  935. (inline-open . +)
  936. ;; Anchor pos: None for functions (inclass got the relpos
  937. ;; then), boi at the lambda start for lambdas.
  938. (inline-close . 0)
  939. ;; Anchor pos: Inexpr functions: At the lambda block open if
  940. ;; it's at boi, else at the statement(*) at boi of the start of
  941. ;; the lambda construct. Otherwise: At the inline block open
  942. ;; if it's at boi, otherwise boi at the func decl start.
  943. (func-decl-cont . +)
  944. ;; Anchor pos: Boi at the func decl start.
  945. (knr-argdecl-intro . +)
  946. ;; Anchor pos: Boi at the topmost intro line.
  947. (knr-argdecl . 0)
  948. ;; Anchor pos: At the beginning of the first K&R argdecl.
  949. (topmost-intro . 0)
  950. ;; Anchor pos: Bol at the last line of previous construct.
  951. (topmost-intro-cont . c-lineup-topmost-intro-cont)
  952. ;;Anchor pos: Bol at the topmost annotation line
  953. (annotation-top-cont . 0)
  954. ;;Anchor pos: Bol at the topmost annotation line
  955. (annotation-var-cont . +)
  956. ;; Anchor pos: Boi at the topmost intro line.
  957. (member-init-intro . +)
  958. ;; Anchor pos: Boi at the func decl arglist open.
  959. (member-init-cont . c-lineup-multi-inher)
  960. ;; Anchor pos: Beg of the first member init.
  961. (inher-intro . +)
  962. ;; Anchor pos: Boi at the class decl start.
  963. (inher-cont . c-lineup-multi-inher)
  964. ;; Anchor pos: Java: At the implements/extends keyword start.
  965. ;; Otherwise: At the inher start colon, or boi at the class
  966. ;; decl start if the first inherit clause hangs and it's not a
  967. ;; func-local inherit clause (when does that occur?).
  968. (block-open . 0)
  969. ;; Anchor pos: Inexpr statement: At the statement(*) at boi of
  970. ;; the start of the inexpr construct. Otherwise: None.
  971. (block-close . 0)
  972. ;; Anchor pos: Inexpr statement: At the inexpr block open if
  973. ;; it's at boi, else at the statement(*) at boi of the start of
  974. ;; the inexpr construct. Block hanging on a case/default
  975. ;; label: At the closest preceding label that starts at boi.
  976. ;; Otherwise: At the block open(*).
  977. (brace-list-open . 0)
  978. ;; Anchor pos: Boi at the brace list decl start, but a starting
  979. ;; "typedef" token is ignored.
  980. (brace-list-close . 0)
  981. ;; Anchor pos: At the brace list decl start(*).
  982. (brace-list-intro . +)
  983. ;; Anchor pos: At the brace list decl start(*).
  984. (brace-list-entry . 0)
  985. ;; Anchor pos: At the first non-ws char after the open paren if
  986. ;; the first token is on the same line, otherwise boi at that
  987. ;; token.
  988. (brace-entry-open . 0)
  989. ;; Anchor pos: Same as brace-list-entry.
  990. (statement . 0)
  991. ;; Anchor pos: After a `;' in the condition clause of a for
  992. ;; statement: At the first token after the starting paren.
  993. ;; Otherwise: At the preceding statement(*).
  994. (statement-cont . +)
  995. ;; Anchor pos: After the first token in the condition clause of
  996. ;; a for statement: At the first token after the starting
  997. ;; paren. Otherwise: At the containing statement(*).
  998. (statement-block-intro . +)
  999. ;; Anchor pos: In inexpr statement block: At the inexpr block
  1000. ;; open if it's at boi, else at the statement(*) at boi of the
  1001. ;; start of the inexpr construct. In a block hanging on a
  1002. ;; case/default label: At the closest preceding label that
  1003. ;; starts at boi. Otherwise: At the start of the containing
  1004. ;; block(*).
  1005. (statement-case-intro . +)
  1006. ;; Anchor pos: At the case/default label(*).
  1007. (statement-case-open . 0)
  1008. ;; Anchor pos: At the case/default label(*).
  1009. (substatement . +)
  1010. ;; Anchor pos: At the containing statement(*).
  1011. (substatement-open . +)
  1012. ;; Anchor pos: At the containing statement(*).
  1013. (substatement-label . 2)
  1014. ;; Anchor pos: At the containing statement(*).
  1015. (case-label . 0)
  1016. ;; Anchor pos: At the start of the switch block(*).
  1017. (access-label . -)
  1018. ;; Anchor pos: Same as inclass.
  1019. (label . 2)
  1020. ;; Anchor pos: At the start of the containing block(*).
  1021. (do-while-closure . 0)
  1022. ;; Anchor pos: At the corresponding while statement(*).
  1023. (else-clause . 0)
  1024. ;; Anchor pos: At the corresponding if statement(*).
  1025. (catch-clause . 0)
  1026. ;; Anchor pos: At the previous try or catch statement clause(*).
  1027. (comment-intro . (c-lineup-knr-region-comment c-lineup-comment))
  1028. ;; Anchor pos: None.
  1029. (arglist-intro . +)
  1030. ;; Anchor pos: At the containing statement(*).
  1031. ;; 2nd pos: At the open paren.
  1032. (arglist-cont . (c-lineup-gcc-asm-reg 0))
  1033. ;; Anchor pos: At the first token after the open paren.
  1034. (arglist-cont-nonempty . (c-lineup-gcc-asm-reg c-lineup-arglist))
  1035. ;; Anchor pos: At the containing statement(*).
  1036. ;; 2nd pos: At the open paren.
  1037. (arglist-close . +)
  1038. ;; Anchor pos: At the containing statement(*).
  1039. ;; 2nd pos: At the open paren.
  1040. (stream-op . c-lineup-streamop)
  1041. ;; Anchor pos: Boi at the first stream op in the statement.
  1042. (inclass . +)
  1043. ;; Anchor pos: At the class open brace if it's at boi,
  1044. ;; otherwise boi at the class decl start.
  1045. (cpp-macro . [0])
  1046. ;; Anchor pos: None.
  1047. (cpp-macro-cont . +)
  1048. ;; Anchor pos: At the macro start (always at boi).
  1049. (cpp-define-intro . (c-lineup-cpp-define +))
  1050. ;; Anchor pos: None.
  1051. (friend . 0)
  1052. ;; Anchor pos: None.
  1053. (objc-method-intro . [0])
  1054. ;; Anchor pos: Boi.
  1055. (objc-method-args-cont . c-lineup-ObjC-method-args)
  1056. ;; Anchor pos: At the method start (always at boi).
  1057. (objc-method-call-cont . (c-lineup-ObjC-method-call-colons
  1058. c-lineup-ObjC-method-call +))
  1059. ;; Anchor pos: At the open bracket.
  1060. (extern-lang-open . 0)
  1061. (namespace-open . 0)
  1062. (module-open . 0)
  1063. (composition-open . 0)
  1064. ;; Anchor pos: Boi at the extern/namespace/etc keyword.
  1065. (extern-lang-close . 0)
  1066. (namespace-close . 0)
  1067. (module-close . 0)
  1068. (composition-close . 0)
  1069. ;; Anchor pos: Boi at the corresponding extern/namespace/etc keyword.
  1070. (inextern-lang . +)
  1071. (innamespace . +)
  1072. (inmodule . +)
  1073. (incomposition . +)
  1074. ;; Anchor pos: At the extern/namespace/etc block open brace if
  1075. ;; it's at boi, otherwise boi at the keyword.
  1076. (template-args-cont . (c-lineup-template-args +))
  1077. ;; Anchor pos: Boi at the decl start. This might be changed;
  1078. ;; the logical position is clearly the opening '<'.
  1079. (inlambda . c-lineup-inexpr-block)
  1080. ;; Anchor pos: None.
  1081. (lambda-intro-cont . +)
  1082. ;; Anchor pos: Boi at the lambda start.
  1083. (inexpr-statement . +)
  1084. ;; Anchor pos: None.
  1085. (inexpr-class . +)
  1086. ;; Anchor pos: None.
  1087. ))
  1088. (defcustom c-offsets-alist nil
  1089. "Association list of syntactic element symbols and indentation offsets.
  1090. As described below, each cons cell in this list has the form:
  1091. (SYNTACTIC-SYMBOL . OFFSET)
  1092. When a line is indented, CC Mode first determines the syntactic
  1093. context of it by generating a list of symbols called syntactic
  1094. elements. The global variable `c-syntactic-context' is bound to the
  1095. that list. Each element in the list is in turn a list where the first
  1096. element is a syntactic symbol which tells what kind of construct the
  1097. indentation point is located within. More elements in the syntactic
  1098. element lists are optional. If there is one more and it isn't nil,
  1099. then it's the anchor position for that construct.
  1100. After generating the syntactic context for the line, CC Mode
  1101. calculates the absolute indentation: First the base indentation is
  1102. found by using the anchor position for the first syntactic element
  1103. that provides one. If none does, zero is used as base indentation.
  1104. Then CC Mode looks at each syntactic element in the context in turn.
  1105. It compares the car of the syntactic element against the
  1106. SYNTACTIC-SYMBOL's in `c-offsets-alist'. When it finds a match, it
  1107. adds OFFSET to the base indentation. The sum of this calculation is
  1108. the absolute offset for line being indented.
  1109. If the syntactic element does not match any in the `c-offsets-alist',
  1110. the element is ignored.
  1111. OFFSET can specify an offset in several different ways:
  1112. If OFFSET is nil then it's ignored.
  1113. If OFFSET is an integer then it's used as relative offset, i.e. it's
  1114. added to the base indentation.
  1115. If OFFSET is one of the symbols `+', `-', `++', `--', `*', or `/'
  1116. then a positive or negative multiple of `c-basic-offset' is added to
  1117. the base indentation; 1, -1, 2, -2, 0.5, and -0.5, respectively.
  1118. If OFFSET is a symbol with a value binding then that value, which
  1119. must be an integer, is used as relative offset.
  1120. If OFFSET is a vector then its first element, which must be an
  1121. integer, is used as an absolute indentation column. This overrides
  1122. the previous base indentation and the relative offsets applied to
  1123. it, and it becomes the new base indentation.
  1124. If OFFSET is a function or a lambda expression then it's called with
  1125. a single argument containing the cons of the syntactic symbol and
  1126. the anchor position (or nil if there is none). The return value
  1127. from the function is then reinterpreted as an offset specification.
  1128. If OFFSET is a list then its elements are evaluated recursively as
  1129. offset specifications. If the first element is any of the symbols
  1130. below then it isn't evaluated but instead specifies how the
  1131. remaining offsets in the list should be combined. If it's something
  1132. else then the list is combined according the method `first'. The
  1133. valid combination methods are:
  1134. `first' -- Use the first offset (that doesn't evaluate to nil).
  1135. `min' -- Use the minimum of all the offsets. All must be either
  1136. relative or absolute - they can't be mixed.
  1137. `max' -- Use the maximum of all the offsets. All must be either
  1138. relative or absolute - they can't be mixed.
  1139. `add' -- Add all the evaluated offsets together. Exactly one of
  1140. them may be absolute, in which case the result is
  1141. absolute. Any relative offsets that preceded the
  1142. absolute one in the list will be ignored in that case.
  1143. `c-offsets-alist' is a style variable. This means that the offsets on
  1144. this variable are normally taken from the style system in CC Mode
  1145. \(see `c-default-style' and `c-style-alist'). However, any offsets
  1146. put explicitly on this list will override the style system when a CC
  1147. Mode buffer is initialized \(there is a variable
  1148. `c-old-style-variable-behavior' that changes this, though).
  1149. Here is the current list of valid syntactic element symbols:
  1150. string -- Inside multi-line string.
  1151. c -- Inside a multi-line C style block comment.
  1152. defun-open -- Brace that opens a function definition.
  1153. defun-close -- Brace that closes a function definition.
  1154. defun-block-intro -- The first line in a top-level defun.
  1155. class-open -- Brace that opens a class definition.
  1156. class-close -- Brace that closes a class definition.
  1157. inline-open -- Brace that opens an in-class inline method.
  1158. inline-close -- Brace that closes an in-class inline method.
  1159. func-decl-cont -- The region between a function definition's
  1160. argument list and the function opening brace
  1161. (excluding K&R argument declarations). In C, you
  1162. cannot put anything but whitespace and comments
  1163. between them; in C++ and Java, throws declarations
  1164. and other things can appear in this context.
  1165. knr-argdecl-intro -- First line of a K&R C argument declaration.
  1166. knr-argdecl -- Subsequent lines in a K&R C argument declaration.
  1167. topmost-intro -- The first line in a topmost construct definition.
  1168. topmost-intro-cont -- Topmost definition continuation lines.
  1169. annotation-top-cont -- Topmost definition continuation line where only
  1170. annotations are on previous lines.
  1171. annotation-var-cont -- A continuation of a C (or like) statement where
  1172. only annotations are on previous lines.
  1173. member-init-intro -- First line in a member initialization list.
  1174. member-init-cont -- Subsequent member initialization list lines.
  1175. inher-intro -- First line of a multiple inheritance list.
  1176. inher-cont -- Subsequent multiple inheritance lines.
  1177. block-open -- Statement block open brace.
  1178. block-close -- Statement block close brace.
  1179. brace-list-open -- Open brace of an enum or static array list.
  1180. brace-list-close -- Close brace of an enum or static array list.
  1181. brace-list-intro -- First line in an enum or static array list.
  1182. brace-list-entry -- Subsequent lines in an enum or static array list.
  1183. brace-entry-open -- Subsequent lines in an enum or static array
  1184. list that start with an open brace.
  1185. statement -- A C (or like) statement.
  1186. statement-cont -- A continuation of a C (or like) statement.
  1187. statement-block-intro -- The first line in a new statement block.
  1188. statement-case-intro -- The first line in a case \"block\".
  1189. statement-case-open -- The first line in a case block starting with brace.
  1190. substatement -- The first line after an if/while/for/do/else.
  1191. substatement-open -- The brace that opens a substatement block.
  1192. substatement-label -- Labeled line after an if/while/for/do/else.
  1193. case-label -- A \"case\" or \"default\" label.
  1194. access-label -- C++ private/protected/public access label.
  1195. label -- Any ordinary label.
  1196. do-while-closure -- The \"while\" that ends a do/while construct.
  1197. else-clause -- The \"else\" of an if/else construct.
  1198. catch-clause -- The \"catch\" or \"finally\" of a try/catch construct.
  1199. comment-intro -- A line containing only a comment introduction.
  1200. arglist-intro -- The first line in an argument list.
  1201. arglist-cont -- Subsequent argument list lines when no
  1202. arguments follow on the same line as the
  1203. arglist opening paren.
  1204. arglist-cont-nonempty -- Subsequent argument list lines when at
  1205. least one argument follows on the same
  1206. line as the arglist opening paren.
  1207. arglist-close -- The solo close paren of an argument list.
  1208. stream-op -- Lines continuing a stream operator construct.
  1209. inclass -- The construct is nested inside a class definition.
  1210. Used together with e.g. `topmost-intro'.
  1211. cpp-macro -- The start of a C preprocessor macro definition.
  1212. cpp-macro-cont -- Inside a multi-line C preprocessor macro definition.
  1213. friend -- A C++ friend declaration.
  1214. objc-method-intro -- The first line of an Objective-C method definition.
  1215. objc-method-args-cont -- Lines continuing an Objective-C method definition.
  1216. objc-method-call-cont -- Lines continuing an Objective-C method call.
  1217. extern-lang-open -- Brace that opens an \"extern\" block.
  1218. extern-lang-close -- Brace that closes an \"extern\" block.
  1219. inextern-lang -- Analogous to the `inclass' syntactic symbol,
  1220. but used inside \"extern\" blocks.
  1221. namespace-open, namespace-close, innamespace
  1222. -- Similar to the three `extern-lang' symbols, but for
  1223. C++ \"namespace\" blocks.
  1224. module-open, module-close, inmodule
  1225. -- Similar to the three `extern-lang' symbols, but for
  1226. CORBA IDL \"module\" blocks.
  1227. composition-open, composition-close, incomposition
  1228. -- Similar to the three `extern-lang' symbols, but for
  1229. CORBA CIDL \"composition\" blocks.
  1230. template-args-cont -- C++ template argument list continuations.
  1231. inlambda -- In the header or body of a lambda function.
  1232. lambda-intro-cont -- Continuation of the header of a lambda function.
  1233. inexpr-statement -- The statement is inside an expression.
  1234. inexpr-class -- The class is inside an expression. Used e.g. for
  1235. Java anonymous classes."
  1236. :type
  1237. `(set :format "%{%t%}:
  1238. Override style setting
  1239. | Syntax Offset
  1240. %v"
  1241. ,@(mapcar
  1242. (lambda (elt)
  1243. `(cons :format "%v"
  1244. :value ,elt
  1245. ,(c-constant-symbol (car elt) 25)
  1246. (sexp :format "%v"
  1247. :validate
  1248. (lambda (widget)
  1249. (unless (c-valid-offset (widget-value widget))
  1250. (widget-put widget :error "Invalid offset")
  1251. widget)))))
  1252. (get 'c-offsets-alist 'c-stylevar-fallback)))
  1253. :group 'c)
  1254. ;; The syntactic symbols that can occur inside code blocks. Used by
  1255. ;; `c-gnu-impose-minimum'.
  1256. (defconst c-inside-block-syms
  1257. '(defun-block-intro block-open block-close statement statement-cont
  1258. statement-block-intro statement-case-intro statement-case-open
  1259. substatement substatement-open substatement-label case-label label
  1260. do-while-closure else-clause catch-clause inlambda annotation-var-cont))
  1261. (defcustom c-style-variables-are-local-p t
  1262. "*Whether style variables should be buffer local by default.
  1263. If non-nil, then all indentation style related variables will be made
  1264. buffer local by default. If nil, they will remain global. Variables
  1265. are made buffer local when this file is loaded, and once buffer
  1266. localized, they cannot be made global again.
  1267. This variable must be set appropriately before CC Mode is loaded.
  1268. The list of variables to buffer localize are:
  1269. c-basic-offset
  1270. c-comment-only-line-offset
  1271. c-indent-comment-alist
  1272. c-indent-comments-syntactically-p
  1273. c-block-comment-prefix
  1274. c-comment-prefix-regexp
  1275. c-doc-comment-style
  1276. c-cleanup-list
  1277. c-hanging-braces-alist
  1278. c-hanging-colons-alist
  1279. c-hanging-semi&comma-criteria
  1280. c-backslash-column
  1281. c-backslash-max-column
  1282. c-label-minimum-indentation
  1283. c-offsets-alist
  1284. c-special-indent-hook
  1285. c-indentation-style"
  1286. :type 'boolean
  1287. :safe 'booleanp
  1288. :group 'c)
  1289. (defcustom c-mode-hook nil
  1290. "*Hook called by `c-mode'."
  1291. :type 'hook
  1292. :group 'c)
  1293. (defcustom c++-mode-hook nil
  1294. "*Hook called by `c++-mode'."
  1295. :type 'hook
  1296. :group 'c)
  1297. (defcustom objc-mode-hook nil
  1298. "*Hook called by `objc-mode'."
  1299. :type 'hook
  1300. :group 'c)
  1301. (defcustom java-mode-hook nil
  1302. "*Hook called by `java-mode'."
  1303. :type 'hook
  1304. :group 'c)
  1305. (defcustom idl-mode-hook nil
  1306. "*Hook called by `idl-mode'."
  1307. :type 'hook
  1308. :group 'c)
  1309. (defcustom pike-mode-hook nil
  1310. "*Hook called by `pike-mode'."
  1311. :type 'hook
  1312. :group 'c)
  1313. (defcustom awk-mode-hook nil
  1314. "*Hook called by `awk-mode'."
  1315. :type 'hook
  1316. :group 'c)
  1317. (defcustom c-mode-common-hook nil
  1318. "*Hook called by all CC Mode modes for common initializations."
  1319. :type 'hook
  1320. :group 'c)
  1321. (defcustom c-initialization-hook nil
  1322. "*Hook called when the CC Mode package gets initialized.
  1323. This hook is only run once per Emacs session and can be used as a
  1324. `load-hook' or in place of using `eval-after-load'."
  1325. :type 'hook
  1326. :group 'c)
  1327. (defcustom c-enable-xemacs-performance-kludge-p nil
  1328. "*Enables a XEmacs only hack that may improve speed for some coding styles.
  1329. For styles that hang top-level opening braces (as is common with JDK
  1330. Java coding styles) this can improve performance between 3 and 60
  1331. times for core indentation functions (e.g. `c-parse-state'). For
  1332. styles that conform to the Emacs recommendation of putting these
  1333. braces in column zero, this can degrade performance about as much.
  1334. This variable only has effect in XEmacs."
  1335. :type 'boolean
  1336. :group 'c)
  1337. (defvar c-old-style-variable-behavior nil
  1338. "*Enables the old style variable behavior when non-nil.
  1339. Normally the values of the style variables will override the style
  1340. settings specified by the variables `c-default-style' and
  1341. `c-style-alist'. However, in CC Mode 5.25 and earlier, it was the
  1342. other way around, meaning that changes made to the style variables
  1343. from e.g. Customize would not take effect unless special precautions
  1344. were taken. That was confusing, especially for novice users.
  1345. It's believed that despite this change, the new behavior will still
  1346. produce the same results for most old CC Mode configurations, since
  1347. all style variables are per default set in a special non-override
  1348. state. Set this variable only if your configuration has stopped
  1349. working due to this change.")
  1350. (define-widget 'c-extra-types-widget 'radio
  1351. "Internal CC Mode widget for the `*-font-lock-extra-types' variables."
  1352. :args '((const :tag "none" nil)
  1353. (repeat :tag "types" regexp)))
  1354. (defun c-make-font-lock-extra-types-blurb (mode1 mode2 example)
  1355. (concat "\
  1356. *List of extra types (aside from the type keywords) to recognize in "
  1357. mode1 " mode.
  1358. Each list item should be a regexp matching a single identifier.
  1359. " example "
  1360. Note that items on this list that don't include any regexp special
  1361. characters are automatically optimized using `regexp-opt', so you
  1362. should not use `regexp-opt' explicitly to build regexps here.
  1363. On decoration level 3 (and higher, where applicable), a method is used
  1364. that finds most types and declarations by syntax alone. This variable
  1365. is still used as a first step, but other types are recognized
  1366. correctly anyway in most cases. Therefore this variable should be
  1367. fairly restrictive and not contain patterns that are uncertain.
  1368. Note that this variable is only consulted when the major mode is
  1369. initialized. If you change it later you have to reinitialize CC Mode
  1370. by doing \\[" mode2 "].
  1371. Despite the name, this variable is not only used for font locking but
  1372. also elsewhere in CC Mode to tell types from other identifiers."))
  1373. ;; Note: Most of the variables below are also defined in font-lock.el
  1374. ;; in older versions of Emacs, so depending on the load order we might
  1375. ;; not install the values below. There's no kludge to cope with this
  1376. ;; (as opposed to the *-font-lock-keywords-* variables) since the old
  1377. ;; values work fairly well anyway.
  1378. (defcustom c-font-lock-extra-types
  1379. '("\\sw+_t"
  1380. ;; Defined in C99:
  1381. "bool" "complex" "imaginary"
  1382. ;; Standard library types (except those matched by the _t pattern):
  1383. "FILE" "lconv" "tm" "va_list" "jmp_buf"
  1384. ;; I do not appreciate the following very Emacs-specific luggage
  1385. ;; in the default value, but otoh it can hardly get in the way for
  1386. ;; other users, and removing it would cause unnecessary grief for
  1387. ;; the old timers that are used to it. /mast
  1388. "Lisp_Object")
  1389. (c-make-font-lock-extra-types-blurb "C" "c-mode"
  1390. "For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word \"FILE\"
  1391. and words ending in \"_t\" are treated as type names.")
  1392. :type 'c-extra-types-widget
  1393. :group 'c)
  1394. (defcustom c++-font-lock-extra-types
  1395. '("\\sw+_t"
  1396. ;; C library types (except those matched by the _t pattern):
  1397. "FILE" "lconv" "tm" "va_list" "jmp_buf"
  1398. ;; Some standard C++ types that came from font-lock.el.
  1399. ;; Experienced C++ users says there's no clear benefit in
  1400. ;; extending this to all the types in the standard library, at
  1401. ;; least not when they'll be recognized without "std::" too.
  1402. "istream" "istreambuf"
  1403. "ostream" "ostreambuf"
  1404. "ifstream" "ofstream" "fstream"
  1405. "strstream" "strstreambuf" "istrstream" "ostrstream"
  1406. "ios"
  1407. "string" "rope"
  1408. "list" "slist"
  1409. "deque" "vector" "bit_vector"
  1410. "set" "multiset"
  1411. "map" "multimap"
  1412. "hash"
  1413. "hash_set" "hash_multiset"
  1414. "hash_map" "hash_multimap"
  1415. "stack" "queue" "priority_queue"
  1416. "type_info"
  1417. "iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator"
  1418. "reference" "const_reference")
  1419. (c-make-font-lock-extra-types-blurb "C++" "c++-mode"
  1420. "For example, a value of (\"string\") means the word \"string\" is treated
  1421. as a type name.")
  1422. :type 'c-extra-types-widget
  1423. :group 'c)
  1424. (defcustom objc-font-lock-extra-types
  1425. (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*"))
  1426. (c-make-font-lock-extra-types-blurb "ObjC" "objc-mode" (concat
  1427. "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means
  1428. capitalized words are treated as type names (the requirement for a
  1429. lower case char is to avoid recognizing all-caps macro and constant
  1430. names)."))
  1431. :type 'c-extra-types-widget
  1432. :group 'c)
  1433. (defcustom java-font-lock-extra-types
  1434. (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw"))
  1435. (c-make-font-lock-extra-types-blurb "Java" "java-mode" (concat
  1436. "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means
  1437. capitalized words are treated as type names (the requirement for a
  1438. lower case char is to avoid recognizing all-caps constant names)."))
  1439. :type 'c-extra-types-widget
  1440. :group 'c)
  1441. (defcustom idl-font-lock-extra-types nil
  1442. (c-make-font-lock-extra-types-blurb "IDL" "idl-mode" "")
  1443. :type 'c-extra-types-widget
  1444. :group 'c)
  1445. (defcustom pike-font-lock-extra-types
  1446. (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*"))
  1447. (c-make-font-lock-extra-types-blurb "Pike" "pike-mode" (concat
  1448. "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means
  1449. capitalized words are treated as type names (the requirement for a
  1450. lower case char is to avoid recognizing all-caps macro and constant
  1451. names)."))
  1452. :type 'c-extra-types-widget
  1453. :group 'c)
  1454. ;; Non-customizable variables, still part of the interface to CC Mode
  1455. (defvar c-macro-with-semi-re nil
  1456. ;; Regular expression which matches a (#define'd) symbol whose expansion
  1457. ;; ends with a semicolon.
  1458. ;;
  1459. ;; This variable should be set by `c-make-macros-with-semi-re' rather than
  1460. ;; directly.
  1461. )
  1462. (make-variable-buffer-local 'c-macro-with-semi-re)
  1463. (defun c-make-macro-with-semi-re ()
  1464. ;; Convert `c-macro-names-with-semicolon' into the regexp
  1465. ;; `c-macro-with-semi-re' (or just copy it if it's already a re).
  1466. (setq c-macro-with-semi-re
  1467. (and
  1468. c-opt-cpp-macro-define
  1469. (cond
  1470. ((stringp c-macro-names-with-semicolon)
  1471. (copy-sequence c-macro-names-with-semicolon))
  1472. ((consp c-macro-names-with-semicolon)
  1473. (concat
  1474. "\\<"
  1475. (regexp-opt c-macro-names-with-semicolon)
  1476. "\\>")) ; N.B. the PAREN param of regexp-opt isn't supported by
  1477. ; all XEmacsen.
  1478. ((null c-macro-names-with-semicolon)
  1479. nil)
  1480. (t (error "c-make-macro-with-semi-re: invalid \
  1481. c-macro-names-with-semicolon: %s"
  1482. c-macro-names-with-semicolon))))))
  1483. (defvar c-macro-names-with-semicolon
  1484. '("Q_OBJECT" "Q_PROPERTY" "Q_DECLARE" "Q_ENUMS")
  1485. "List of #defined symbols whose expansion ends with a semicolon.
  1486. Alternatively it can be a string, a regular expression which
  1487. matches all such symbols.
  1488. The \"symbols\" must be syntactically valid identifiers in the
  1489. target language \(C, C++, Objective C), or \(as the case may be)
  1490. the regular expression must match only valid identifiers.
  1491. If you change this variable's value, call the function
  1492. `c-make-macros-with-semi-re' to set the necessary internal
  1493. variables.
  1494. Note that currently \(2008-11-04) this variable is a prototype,
  1495. and is likely to disappear or change its form soon.")
  1496. (make-variable-buffer-local 'c-macro-names-with-semicolon)
  1497. (defvar c-file-style nil
  1498. "Variable interface for setting style via File Local Variables.
  1499. In a file's Local Variable section, you can set this variable to a
  1500. string suitable for `c-set-style'. When the file is visited, CC Mode
  1501. will set the style of the file to this value automatically.
  1502. Note that file style settings are applied before file offset settings
  1503. as designated in the variable `c-file-offsets'.")
  1504. (make-variable-buffer-local 'c-file-style)
  1505. ;;;###autoload(put 'c-file-style 'safe-local-variable 'string-or-null-p)
  1506. (defvar c-file-offsets nil
  1507. "Variable interface for setting offsets via File Local Variables.
  1508. In a file's Local Variable section, you can set this variable to an
  1509. association list similar to the values allowed in `c-offsets-alist'.
  1510. When the file is visited, CC Mode will institute these offset settings
  1511. automatically.
  1512. Note that file offset settings are applied after file style settings
  1513. as designated in the variable `c-file-style'.")
  1514. (make-variable-buffer-local 'c-file-offsets)
  1515. ;; It isn't possible to specify a doc-string without specifying an
  1516. ;; initial value with `defvar', so the following two variables have been
  1517. ;; given doc-strings by setting the property `variable-documentation'
  1518. ;; directly. It's really good not to have an initial value for
  1519. ;; variables like these that always should be dynamically bound, so it's
  1520. ;; worth the inconvenience.
  1521. (cc-bytecomp-defvar c-syntactic-context)
  1522. (defvar c-syntactic-context)
  1523. (put 'c-syntactic-context 'variable-documentation
  1524. "Variable containing the syntactic analysis list for a line of code.
  1525. It is a list with one element for each syntactic symbol pertinent to the
  1526. line, for example \"((defun-block-intro 1) (comment-intro))\".
  1527. It is dynamically bound when calling \(i) a brace hanging \"action
  1528. function\"; \(ii) a semicolon/comma hanging \"criteria function\"; \(iii) a
  1529. \"line-up function\"; \(iv) a c-special-indent-hook function. It is also
  1530. used internally by CC Mode.
  1531. c-syntactic-context is always bound dynamically. It must NEVER be set
  1532. statically (e.g. with `setq').")
  1533. (cc-bytecomp-defvar c-syntactic-element)
  1534. (defvar c-syntactic-element)
  1535. (put 'c-syntactic-element 'variable-documentation
  1536. "Variable containing the current syntactic element during calls to
  1537. the lineup functions. The value is one of the elements in the list in
  1538. `c-syntactic-context' and is a list with the symbol name in the first
  1539. position, followed by zero or more elements containing any additional
  1540. info associated with the syntactic symbol. There are accessor functions
  1541. `c-langelem-sym', `c-langelem-pos', `c-langelem-col', and
  1542. `c-langelem-2nd-pos' to access the list.
  1543. Specifically, the element returned by `c-langelem-pos' is the anchor
  1544. position, or nil if there isn't any. See the comments in the
  1545. `c-offsets-alist' variable and the CC Mode manual for more detailed info
  1546. about the data each syntactic symbol provides.
  1547. This is always bound dynamically. It should never be set
  1548. statically (e.g. with `setq').")
  1549. (defvar c-indentation-style nil
  1550. "Name of the currently installed style.
  1551. Don't change this directly; call `c-set-style' instead, or set the variable
  1552. `c-file-style' in the file's Local Variable list.")
  1553. (defvar c-current-comment-prefix nil
  1554. "The current comment prefix regexp.
  1555. Set from `c-comment-prefix-regexp' at mode initialization.")
  1556. (make-variable-buffer-local 'c-current-comment-prefix)
  1557. ;; N.B. The next three variables are initialized in
  1558. ;; c-setup-paragraph-variables. Their initializations here are "just in
  1559. ;; case". ACM, 2004/2/15. They are NOT buffer local (yet?).
  1560. (defvar c-string-par-start
  1561. ;; (concat "\\(" (default-value 'paragraph-start) "\\)\\|[ \t]*\\\\$")
  1562. "\f\\|[ \t]*\\\\?$"
  1563. "Value of paragraph-start used when scanning strings.
  1564. It treats escaped EOLs as whitespace.")
  1565. (defvar c-string-par-separate
  1566. ;; (concat "\\(" (default-value 'paragraph-separate) "\\)\\|[ \t]*\\\\$")
  1567. "[ \t\f]*\\\\?$"
  1568. "Value of paragraph-separate used when scanning strings.
  1569. It treats escaped EOLs as whitespace.")
  1570. (defvar c-sentence-end-with-esc-eol
  1571. (concat "\\(\\(" (c-default-value-sentence-end) "\\)"
  1572. ;; N.B.: "$" would be illegal when not enclosed like "\\($\\)".
  1573. "\\|" "[.?!][]\"')}]* ?\\\\\\($\\)[ \t\n]*"
  1574. "\\)")
  1575. "Value used like sentence-end used when scanning strings.
  1576. It treats escaped EOLs as whitespace.")
  1577. (cc-provide 'cc-vars)
  1578. ;;; cc-vars.el ends here