summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/cc-bytecomp.el41
-rw-r--r--lisp/progmodes/cc-defs.el47
-rw-r--r--lisp/progmodes/cc-langs.el7
3 files changed, 49 insertions, 46 deletions
diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el
index 81b7a822b82..ab53c39fbde 100644
--- a/lisp/progmodes/cc-bytecomp.el
+++ b/lisp/progmodes/cc-bytecomp.el
@@ -284,9 +284,6 @@ perhaps a `cc-bytecomp-restore-environment' is forgotten somewhere"))
(cc-bytecomp-setup-environment)
t))))
-(defvar cc-bytecomp-noruntime-functions nil
- "Saved value of `byte-compile-noruntime-functions'.")
-
(defmacro cc-require (cc-part)
"Force loading of the corresponding .el file in the current directory
during compilation, but compile in a `require'. Don't use within
@@ -296,19 +293,37 @@ Having cyclic cc-require's will result in infinite recursion. That's
somewhat intentional."
`(progn
(eval-when-compile
- (if (boundp 'byte-compile-noruntime-functions) ; in case load uncompiled
- (setq cc-bytecomp-noruntime-functions
- byte-compile-noruntime-functions))
(cc-bytecomp-load (symbol-name ,cc-part)))
- ;; Hack to suppress spurious "might not be defined at runtime" warnings.
- ;; The basic issue is that
- ;; (eval-when-compile (require 'foo))
- ;; (require 'foo)
- ;; produces bogus noruntime warnings about functions from foo.
- (eval-when-compile
- (setq byte-compile-noruntime-functions cc-bytecomp-noruntime-functions))
(require ,cc-part)))
+(defmacro cc-conditional-require (cc-part condition)
+ "If the CONDITION is satisfied at compile time, (i) force the
+file CC-PART.el in the current directory to be loaded at compile
+time, (ii) generate code to load the file at load time.
+
+CC-PART will normally be a quoted name such as 'cc-fix.
+CONDITION should not be quoted."
+ (if (eval condition)
+ (progn
+ (cc-bytecomp-load (symbol-name (eval cc-part)))
+ `(require ,cc-part))
+ '(progn)))
+
+(defmacro cc-conditional-require-after-load (cc-part file condition)
+ "If the CONDITION is satified at compile time, (i) force the
+file CC-PART.el in the current directory to be loaded at compile
+time, (ii) generate an `eval-after-load' form to load CC-PART.el
+after the loading of FILE.
+
+CC-PART will normally be a quoted name such as 'cc-fix. FILE
+should be a string. CONDITION should not be quoted."
+ (if (eval condition)
+ (progn
+ (cc-bytecomp-load (symbol-name (eval cc-part)))
+ `(eval-after-load ,file
+ '(require ,cc-part)))
+ '(progn)))
+
(defmacro cc-provide (feature)
"A replacement for the `provide' form that restores the environment
after the compilation. Don't use within `eval-when-compile'."
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 6bd58159fce..ac4aa19e565 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -75,37 +75,22 @@
;; cc-fix.el contains compatibility macros that should be used if
;; needed.
-(eval-and-compile
- (if (or (/= (regexp-opt-depth "\\(\\(\\)\\)") 2)
- (not (fboundp 'push)))
- (cc-load "cc-fix")))
-
-(when (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS
- ; to make the call to f-l-c-k throw an error.
- (eval-after-load "font-lock"
- '(if (and (not (featurep 'cc-fix)) ; only load the file once.
- (let (font-lock-keywords)
- (font-lock-compile-keywords '("\\<\\>"))
- font-lock-keywords)) ; did the previous call foul this up?
- (load "cc-fix"))))
-
-;; The above takes care of the delayed loading, but this is necessary
-;; to ensure correct byte compilation.
-(eval-when-compile
- (if (and (featurep 'xemacs)
- (not (featurep 'cc-fix))
- (progn
- (require 'font-lock)
- (let (font-lock-keywords)
- (font-lock-compile-keywords '("\\<\\>"))
- font-lock-keywords)))
- (cc-load "cc-fix")))
-
-;; XEmacs 21.4 doesn't have `delete-dups'.
-(eval-and-compile
- (if (and (not (fboundp 'delete-dups))
- (not (featurep 'cc-fix)))
- (cc-load "cc-fix")))
+(cc-conditional-require
+ 'cc-fix (or (/= (regexp-opt-depth "\\(\\(\\)\\)") 2)
+ (not (fboundp 'push))
+ ;; XEmacs 21.4 doesn't have `delete-dups'.
+ (not (fboundp 'delete-dups))))
+
+(cc-conditional-require-after-load
+ 'cc-fix "font-lock"
+ (and
+ (featurep 'xemacs)
+ (progn
+ (require 'font-lock)
+ (let (font-lock-keywords)
+ (font-lock-compile-keywords '("\\<\\>"))
+ font-lock-keywords))))
+
;;; Variables also used at compile time.
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 7cda5ceaf1d..5b670833d45 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -403,7 +403,9 @@ The syntax tables aren't stored directly since they're quite large."
table)))
(c-lang-defvar c++-template-syntax-table
(and (c-lang-const c++-make-template-syntax-table)
- (funcall (c-lang-const c++-make-template-syntax-table))))
+ ;; The next eval remove a superfluous ' from '(lambda. This
+ ;; gets rid of compilation warnings.
+ (funcall (eval (c-lang-const c++-make-template-syntax-table)))))
(c-lang-defconst c-make-no-parens-syntax-table
;; A variant of the standard syntax table which is used to find matching
@@ -426,7 +428,8 @@ The syntax tables aren't stored directly since they're quite large."
table))))
(c-lang-defvar c-no-parens-syntax-table
(and (c-lang-const c-make-no-parens-syntax-table)
- (funcall (c-lang-const c-make-no-parens-syntax-table))))
+ ;; See comment in `c++template-syntax-table' about the next `eval'.
+ (funcall (eval (c-lang-const c-make-no-parens-syntax-table)))))
(c-lang-defconst c-identifier-syntax-modifications
"A list that describes the modifications that should be done to the