]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-vars.el
Don't modify buffer by unprettification
[gnu-emacs] / lisp / progmodes / cc-vars.el
index d2a5d11763538123b72c260d839e5c1657adc023..9afece9e30be51fe4feda38f7fab20303825120c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cc-vars.el --- user customization variables for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-201 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2015 Free Software Foundation, Inc.
 
 ;; Authors:    2002- Alan Mackenzie
 ;;             1998- Martin Stjernholm
 
 (cc-require 'cc-defs)
 
-;; Silence the compiler.
-(cc-bytecomp-defun get-char-table)     ; XEmacs
-
 (cc-eval-when-compile
   (require 'custom)
   (require 'widget))
 
-(cc-eval-when-compile
-  ;; Need the function form of `backquote', which isn't standardized
-  ;; between Emacsen.  It's called `bq-process' in XEmacs, and
-  ;; `backquote-process' in Emacs.  `backquote-process' returns a
-  ;; slightly more convoluted form, so let `bq-process' be the norm.
-  (if (fboundp 'backquote-process)
-      (cc-bytecomp-defmacro bq-process (form)
-       `(cdr (backquote-process ,form)))))
-
-\f
 ;;; Helpers
 
-;; This widget exists in newer versions of the Custom library
-(or (get 'other 'widget-type)
-    (define-widget 'other 'sexp
-      "Matches everything, but doesn't let the user edit the value.
+
+;; Emacs has 'other since at least version 21.1.
+;; FIXME this is probably broken, since the widget is defined
+;; in wid-edit, which this file does not load.  So we will always
+;; define the widget, even when we don't need to.
+(when (featurep 'xemacs)
+  (or (get 'other 'widget-type)
+      (define-widget 'other 'sexp
+       "Matches everything, but doesn't let the user edit the value.
 Useful as last item in a `choice' widget."
-      :tag "Other"
-      :format "%t%n"
-      :value 'other))
+       :tag "Other"
+       :format "%t%n"
+       :value 'other)))
 
 ;; The next defun will supersede c-const-symbol.
 (eval-and-compile
@@ -279,17 +271,23 @@ nil."
   :group 'c)
 ;;;###autoload(put 'c-basic-offset 'safe-local-variable 'integerp)
 
+
 (defcustom c-tab-always-indent t
   "*Controls the operation of the TAB key.
 If t, hitting TAB always just indents the current line.  If nil, hitting
 TAB indents the current line if point is at the left margin or in the
-line's indentation, otherwise it calls `c-insert-tab-function' to
-insert a `real' tab character.  If some other value (neither nil nor t),
-then inserts a tab only within literals (comments and strings), but
-always reindents the line.
-
-Note: the variable `c-comment-only-line-offset' also controls the
-indentation of lines containing only comments."
+line's indentation, otherwise it inserts a `real' tab character \(see
+note).  If some other value \(not nil or t), then tab is inserted only
+within literals \(comments and strings), but the line is always
+reindented.
+
+Note: The value of `indent-tabs-mode' will determine whether a real
+tab character will be inserted, or the equivalent number of spaces.
+When inserting a tab, actually the function stored in the variable
+`c-insert-tab-function' is called.
+
+Note: indentation of lines containing only comments is also controlled
+by the `c-comment-only-line-offset' variable."
   :type '(radio
          (const :tag "TAB key always indents, never inserts TAB" t)
          (const :tag "TAB key indents in left margin, otherwise inserts TAB" nil)
@@ -340,6 +338,21 @@ better with the \"do { ... } while \(0)\" trick)."
   :group 'c)
 (put 'c-syntactic-indentation-in-macros 'safe-local-variable 'booleanp)
 
+(defcustom c-defun-tactic 'go-outward
+  "*Whether functions are recognized inside, e.g., a class.
+This is used by `c-beginning-of-defun' and like functions.
+
+Its value is one of:
+ t           -- Functions are recognized only at the top level.
+ go-outward  -- Nested functions are also recognized.  Should a function
+                command hit the beginning/end of a nested scope, it will
+                carry on at the less nested level."
+  :version "24.1"
+  :type '(radio
+         (const :tag "Functions are at the top-level" t)
+         (const :tag "Functions are also recognized inside declaration scopes" go-outward))
+  :group 'c)
+
 (defcustom-c-stylevar c-comment-only-line-offset 0
   "*Extra offset for line which contains only the start of a comment.
 Can contain an integer or a cons cell of the form:
@@ -406,7 +419,7 @@ If a LINE-TYPE is missing, then \\[indent-for-comment] indents the comment
 according to `comment-column'.
 
 Note that a non-nil value on `c-indent-comments-syntactically-p'
-overrides this variable, so empty lines are indentented syntactically
+overrides this variable, so empty lines are indented syntactically
 in that case, i.e. as if \\[c-indent-command] was used instead."
   :type
   (let ((space '(cons :tag "space"
@@ -528,7 +541,7 @@ variable in a mode hook."
                  (const :format "IDL   " idl-mode) (regexp :format "%v"))
            (cons :format "%v"
                  (const :format "Pike  " pike-mode) (regexp :format "%v"))
-            (cons :format "%v"
+           (cons :format "%v"
                  (const :format "AWK   " awk-mode) (regexp :format "%v")))
           (cons :format "    %v"
                 (const :format "Other " other) (regexp :format "%v"))))
@@ -572,7 +585,7 @@ in a mode hook, you have to call `c-setup-doc-comment-style'
 afterwards to redo that work."
   ;; Symbols other than those documented above may be used on this
   ;; variable.  If a variable exists that has that name with
-  ;; "-font-lock-keywords" appended, it's value is prepended to the
+  ;; "-font-lock-keywords" appended, its value is prepended to the
   ;; font lock keywords list.  If it's a function then it's called and
   ;; the result is prepended.
   :type '(radio
@@ -820,7 +833,7 @@ string in the mode line), and a semicolon or comma is typed (see
 no arguments, and should return one of the following values:
 
   nil             -- no determination made, continue checking
-  'stop           -- do not insert a newline, and stop checking
+  `stop'          -- do not insert a newline, and stop checking
   (anything else) -- insert a newline, and stop checking
 
 If every function in the list is called with no determination made,
@@ -913,7 +926,7 @@ Only currently supported behavior is `alignleft'."
 (defcustom c-special-indent-hook nil
   "*Hook for user defined special indentation adjustments.
 This hook gets called after each line is indented by the mode.  It is only
-called if `c-syntactic-indentation' is non-nil."
+called when `c-syntactic-indentation' is non-nil."
   :type 'hook
   :group 'c)
 
@@ -949,7 +962,7 @@ this is `c-lineup-ObjC-method-call', which would align it like:
        [foo blahBlahBlah: fred
             thisIsTooDamnLong: barney
 
-This behaviour can be overridden by customizing the indentation of
+This behavior can be overridden by customizing the indentation of
 `objc-method-call-cont' in the \"objc\" style."
   :type 'integer
   :group 'c)
@@ -1163,7 +1176,7 @@ can always override the use of `c-default-style' by making calls to
        (objc-method-args-cont . c-lineup-ObjC-method-args)
        ;; Anchor pos: At the method start (always at boi).
        (objc-method-call-cont . (c-lineup-ObjC-method-call-colons
-                               c-lineup-ObjC-method-call +))
+                               c-lineup-ObjC-method-call +))
        ;; Anchor pos: At the open bracket.
        (extern-lang-open      . 0)
        (namespace-open        . 0)
@@ -1313,7 +1326,7 @@ Here is the current list of valid syntactic element symbols:
  statement-case-open    -- The first line in a case block starting with brace.
  substatement           -- The first line after an if/while/for/do/else.
  substatement-open      -- The brace that opens a substatement block.
- substatement-label     -- Labelled line after an if/while/for/do/else.
+ substatement-label     -- Labeled line after an if/while/for/do/else.
  case-label             -- A \"case\" or \"default\" label.
  access-label           -- C++ private/protected/public access label.
  label                  -- Any ordinary label.
@@ -1608,6 +1621,55 @@ names)."))
 
 \f
 ;; Non-customizable variables, still part of the interface to CC Mode
+(defvar c-macro-with-semi-re nil
+  ;; Regular expression which matches a (#define'd) symbol whose expansion
+  ;; ends with a semicolon.
+  ;;
+  ;; This variable should be set by `c-make-macros-with-semi-re' rather than
+  ;; directly.
+)
+(make-variable-buffer-local 'c-macro-with-semi-re)
+
+(defvar c-macro-names-with-semicolon
+  '("Q_OBJECT" "Q_PROPERTY" "Q_DECLARE" "Q_ENUMS")
+  "List of #defined symbols whose expansion ends with a semicolon.
+Alternatively it can be a string, a regular expression which
+matches all such symbols.
+
+The \"symbols\" must be syntactically valid identifiers in the
+target language \(C, C++, Objective C), or \(as the case may be)
+the regular expression must match only valid identifiers.
+
+If you change this variable's value, call the function
+`c-make-macros-with-semi-re' to set the necessary internal
+variables.
+
+Note that currently \(2008-11-04) this variable is a prototype,
+and is likely to disappear or change its form soon.")
+(make-variable-buffer-local 'c-macro-names-with-semicolon)
+
+(defun c-make-macro-with-semi-re ()
+  ;; Convert `c-macro-names-with-semicolon' into the regexp
+  ;; `c-macro-with-semi-re' (or just copy it if it's already a re).
+  (setq c-macro-with-semi-re
+       (and
+        (boundp 'c-opt-cpp-macro-define)
+        c-opt-cpp-macro-define
+        (cond
+         ((stringp c-macro-names-with-semicolon)
+          (copy-sequence c-macro-names-with-semicolon))
+         ((consp c-macro-names-with-semicolon)
+          (concat
+           "\\<"
+           (regexp-opt c-macro-names-with-semicolon)
+           "\\>"))   ; N.B. the PAREN param of regexp-opt isn't supported by
+                     ; all XEmacsen.
+         ((null c-macro-names-with-semicolon)
+          nil)
+         (t (error "c-make-macro-with-semi-re: invalid \
+c-macro-names-with-semicolon: %s"
+                   c-macro-names-with-semicolon))))))
+
 (defvar c-file-style nil
   "Variable interface for setting style via File Local Variables.
 In a file's Local Variable section, you can set this variable to a
@@ -1710,4 +1772,8 @@ It treats escaped EOLs as whitespace.")
 \f
 (cc-provide 'cc-vars)
 
+;; Local Variables:
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
 ;;; cc-vars.el ends here