summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-bytecomp.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2015-12-29 21:39:08 -0800
committerJohn Wiegley <johnw@newartisans.com>2015-12-29 21:39:08 -0800
commitec0a80cc283badc7f7fd5ef78512dde6d34b1355 (patch)
tree7190e0fb3d4aa06018d8cf997f06b806fb09a9c8 /lisp/progmodes/cc-bytecomp.el
parentd259328fb87db8cc67d52771efcfa653e52c5b71 (diff)
parente823c34072bf045800d91e12c7ddb61fa23c6e30 (diff)
downloademacs-25-merge.tar.gz
Merge emacs-25 into master (using imerge)emacs-25-merge
Diffstat (limited to 'lisp/progmodes/cc-bytecomp.el')
-rw-r--r--lisp/progmodes/cc-bytecomp.el46
1 files changed, 33 insertions, 13 deletions
diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el
index 81b7a822b82..d3b4db74c16 100644
--- a/lisp/progmodes/cc-bytecomp.el
+++ b/lisp/progmodes/cc-bytecomp.el
@@ -252,6 +252,11 @@ perhaps a `cc-bytecomp-restore-environment' is forgotten somewhere"))
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Done"))))
+(defun cc-bytecomp-load (cc-part)
+ ;; A dummy function which will immediately be overwritten by the
+ ;; following at load time. This should suppress the byte compiler
+ ;; error that the function is "not known to be defined".
+)
(eval
;; This eval is to avoid byte compilation of the function below.
;; There's some bug in XEmacs 21.4.6 that can cause it to dump core
@@ -284,9 +289,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 +298,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 satisfied 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'."