;;; cc-defs.el --- compile time definitions for CC Mode
-;; Copyright (C) 1985, 1987, 1992-2011 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
\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))
(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.
(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
(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)
`(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)
(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
;; `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
;; 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.
;;
;; 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)
;; 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
;; 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
(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))
(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
(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
;; 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))))
;;(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