]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-defs.el
Update copyright year to 2015
[gnu-emacs] / lisp / progmodes / cc-defs.el
index fb9fd406ef823a6184f3a76316b64542e311495c..9eaa4f83ad432fe78bb299032f789e5a3c7978a1 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cc-defs.el --- compile time definitions for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-201 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2015 Free Software Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             1998- Martin Stjernholm
 
 ;; Silence the compiler.
 (cc-bytecomp-defvar c-enable-xemacs-performance-kludge-p) ; In cc-vars.el
-(cc-bytecomp-defun buffer-syntactic-context-depth) ; XEmacs
 (cc-bytecomp-defun region-active-p)    ; XEmacs
-(cc-bytecomp-defvar zmacs-region-stays)        ; XEmacs
-(cc-bytecomp-defvar zmacs-regions)     ; XEmacs
 (cc-bytecomp-defvar mark-active)       ; Emacs
 (cc-bytecomp-defvar deactivate-mark)   ; Emacs
 (cc-bytecomp-defvar inhibit-point-motion-hooks) ; Emacs
 (cc-bytecomp-defvar parse-sexp-lookup-properties) ; Emacs
 (cc-bytecomp-defvar text-property-default-nonsticky) ; Emacs 21
-(cc-bytecomp-defvar lookup-syntax-properties) ; XEmacs
 (cc-bytecomp-defun string-to-syntax)   ; Emacs 21
 
 \f
@@ -93,7 +89,7 @@
 \f
 ;;; Variables also used at compile time.
 
-(defconst c-version "5.32.2"
+(defconst c-version "5.32.5"
   "CC Mode version number.")
 
 (defconst c-version-sym (intern c-version))
@@ -173,6 +169,10 @@ This variant works around bugs in `eval-when-compile' in various
 
   (put 'cc-eval-when-compile 'lisp-indent-hook 0))
 
+(eval-and-compile
+  (defalias 'c--macroexpand-all
+    (if (fboundp 'macroexpand-all)
+        'macroexpand-all 'cl-macroexpand-all)))
 \f
 ;;; Macros.
 
@@ -334,6 +334,8 @@ to it is returned.  This function does not modify the point or the mark."
 (defmacro c-region-is-active-p ()
   ;; Return t when the region is active.  The determination of region
   ;; activeness is different in both Emacs and XEmacs.
+  ;; FIXME? Emacs has region-active-p since 23.1, so maybe this test
+  ;; should be updated.
   (if (cc-bytecomp-boundp 'mark-active)
       ;; Emacs.
       'mark-active
@@ -343,7 +345,7 @@ to it is returned.  This function does not modify the point or the mark."
 (defmacro c-set-region-active (activate)
   ;; Activate the region if ACTIVE is non-nil, deactivate it
   ;; otherwise.  Covers the differences between Emacs and XEmacs.
-  (if (cc-bytecomp-fboundp 'zmacs-activate-region)
+  (if (fboundp 'zmacs-activate-region)
       ;; XEmacs.
       `(if ,activate
           (zmacs-activate-region)
@@ -376,6 +378,13 @@ to it is returned.  This function does not modify the point or the mark."
       `(int-to-char ,integer)
     integer))
 
+(defmacro c-last-command-char ()
+  ;; The last character just typed.  Note that `last-command-event' exists in
+  ;; both Emacs and XEmacs, but with confusingly different meanings.
+  (if (featurep 'xemacs)
+      'last-command-char
+    'last-command-event))
+
 (defmacro c-sentence-end ()
   ;; Get the regular expression `sentence-end'.
   (if (cc-bytecomp-fboundp 'sentence-end)
@@ -473,7 +482,7 @@ various buffer change hooks."
 
   (let ((saved-undo-list (elt saved-state 0)))
     (if (eq buffer-undo-list saved-undo-list)
-       ;; No change was done afterall.
+       ;; No change was done after all.
        (setq buffer-undo-list (cdr saved-undo-list))
 
       (if keep
@@ -700,9 +709,9 @@ be after it."
   ;; `c-parse-state'.
 
   `(progn
-     (if (and ,(cc-bytecomp-fboundp 'buffer-syntactic-context-depth)
+     (if (and ,(fboundp 'buffer-syntactic-context-depth)
              c-enable-xemacs-performance-kludge-p)
-        ,(when (cc-bytecomp-fboundp 'buffer-syntactic-context-depth)
+        ,(when (fboundp 'buffer-syntactic-context-depth)
            ;; XEmacs only.  This can improve the performance of
            ;; c-parse-state to between 3 and 60 times faster when
            ;; braces are hung.  It can also degrade performance by
@@ -774,7 +783,7 @@ be after it."
 ;; In addition to `c-at-vsemi-p-fn', a mode may need to supply a function for
 ;; `c-vsemi-status-unknown-p-fn'.  The macro `c-vsemi-status-unknown-p' is a
 ;; rather recondite kludge.  It exists because the function
-;; `c-beginning-of-statement-1' sometimes tests for VSs as an optimisation,
+;; `c-beginning-of-statement-1' sometimes tests for VSs as an optimization,
 ;; but `c-at-vsemi-p' might well need to call `c-beginning-of-statement-1' in
 ;; its calculations, thus potentially leading to infinite recursion.
 ;;
@@ -1132,7 +1141,7 @@ been put there by c-put-char-property.  POINT remains unchanged."
 ;; Make edebug understand the macros.
 ;(eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
 ;  '(progn
-(def-edebug-spec cc-eval-when-compile t)
+(def-edebug-spec cc-eval-when-compile (&rest def-form))
 (def-edebug-spec c-point t)
 (def-edebug-spec c-set-region-active t)
 (def-edebug-spec c-safe t)
@@ -1249,7 +1258,7 @@ been put there by c-put-char-property.  POINT remains unchanged."
 ;; which introduces a CPP construct and every EOL (or EOB, or character
 ;; preceding //, etc.) which terminates it.  We can instantly "comment
 ;; out" all CPP constructs by giving `c-cpp-delimiter' a syntax-table
-;; propery '(14) (generic comment delimiter).
+;; property '(14) (generic comment delimiter).
 (defmacro c-set-cpp-delimiters (beg end)
   ;; This macro does a hidden buffer change.
   `(progn
@@ -1288,10 +1297,14 @@ been put there by c-put-char-property.  POINT remains unchanged."
   ;; suppressed.
   `(unwind-protect
        (c-save-buffer-state ()
-        (c-clear-cpp-delimiters ,beg ,end)
+        (save-restriction
+          (widen)
+          (c-clear-cpp-delimiters ,beg ,end))
         ,`(c-with-cpps-commented-out ,@forms))
      (c-save-buffer-state ()
-       (c-set-cpp-delimiters ,beg ,end))))
+       (save-restriction
+        (widen)
+        (c-set-cpp-delimiters ,beg ,end)))))
 \f
 (defsubst c-intersect-lists (list alist)
   ;; return the element of ALIST that matches the first element found
@@ -1599,7 +1612,7 @@ non-nil, a caret is prepended to invert the set."
     (let ((buf (generate-new-buffer " test"))
          parse-sexp-lookup-properties
          parse-sexp-ignore-comments
-         lookup-syntax-properties)
+         lookup-syntax-properties)     ; XEmacs
       (with-current-buffer buf
        (set-syntax-table (make-syntax-table))
 
@@ -1818,21 +1831,16 @@ system."
               (t
                ;; Being evaluated interactively.
                (buffer-file-name)))))
-    (and file
-        (file-name-sans-extension
-         (file-name-nondirectory file)))))
+    (and file (file-name-base file))))
 
 (defmacro c-lang-defconst-eval-immediately (form)
   "Can be used inside a VAL in `c-lang-defconst' to evaluate FORM
 immediately, i.e. at the same time as the `c-lang-defconst' form
 itself is evaluated."
   ;; Evaluate at macro expansion time, i.e. in the
-  ;; `cl-macroexpand-all' inside `c-lang-defconst'.
+  ;; `c--macroexpand-all' inside `c-lang-defconst'.
   (eval form))
 
-;; Only used at compile time - suppress "might not be defined at runtime".
-(declare-function cl-macroexpand-all "cl-extra" (form &optional env))
-
 (defmacro c-lang-defconst (name &rest args)
   "Set the language specific values of the language constant NAME.
 The second argument can optionally be a docstring.  The rest of the
@@ -1874,7 +1882,7 @@ constant.  A file is identified by its base name."
 
   (let* ((sym (intern (symbol-name name) c-lang-constants))
         ;; Make `c-lang-const' expand to a straightforward call to
-        ;; `c-get-lang-constant' in `cl-macroexpand-all' below.
+        ;; `c-get-lang-constant' in `c--macroexpand-all' below.
         ;;
         ;; (The default behavior, i.e. to expand to a call inside
         ;; `eval-when-compile' should be equivalent, since that macro
@@ -1937,7 +1945,7 @@ constant.  A file is identified by its base name."
        ;; reason, but we also use this expansion handle
        ;; `c-lang-defconst-eval-immediately' and to register
        ;; dependencies on the `c-lang-const's in VAL.)
-       (setq val (cl-macroexpand-all val))
+       (setq val (c--macroexpand-all val))
 
        (setq bindings (cons (cons assigned-mode val) bindings)
              args (cdr args))))
@@ -2212,7 +2220,7 @@ quoted."
                     ;;(message (concat "Loading %s to get the source "
                     ;;                 "value for language constant %s")
                     ;;         file name)
-                    (load file))
+                    (load file nil t))
 
                   (unless (setq assignment-entry (cdar file-entry))
                     ;; The load didn't fill in the source for the