summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/bytecomp.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r--lisp/emacs-lisp/bytecomp.el51
1 files changed, 34 insertions, 17 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 6aff16143b3..1094b1b8cb1 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -358,7 +358,7 @@ Elements of the list may be be:
(defvar byte-compile-interactive-only-functions
'(beginning-of-buffer end-of-buffer replace-string replace-regexp
- insert-file)
+ insert-file insert-buffer insert-file-literally)
"List of commands that are not meant to be called from Lisp.")
(defvar byte-compile-not-obsolete-var nil
@@ -3355,12 +3355,12 @@ That command is designed for interactive use only" fn))
"Execute forms in BODY, potentially guarded by CONDITION.
CONDITION is a variable whose value is a test in an `if' or `cond'.
BODY is the code to compile first arm of the if or the body of the
-cond clause. If CONDITION's value is of the form `(foundp 'foo)'
-or `(boundp 'foo)', the relevant warnings from BODY about foo
+cond clause. If CONDITION's value is of the form (fboundp 'foo)
+or (boundp 'foo), the relevant warnings from BODY about foo's
being undefined will be suppressed.
-If CONDITION's value is `(featurep 'xemacs)', that suppresses all
-warnings during execution of BODY."
+If CONDITION's value is (not (featurep 'emacs)) or (featurep 'xemacs),
+that suppresses all warnings during execution of BODY."
(declare (indent 1) (debug t))
`(let* ((fbound
(if (eq 'fboundp (car-safe ,condition))
@@ -3379,8 +3379,10 @@ warnings during execution of BODY."
(if bound
(cons bound byte-compile-bound-variables)
byte-compile-bound-variables))
+ ;; Suppress all warnings, for code not used in Emacs.
(byte-compile-warnings
- (if (equal ,condition '(featurep 'xemacs))
+ (if (member ,condition '((featurep 'xemacs)
+ (not (featurep 'emacs))))
nil byte-compile-warnings)))
(unwind-protect
(progn ,@body)
@@ -3409,7 +3411,8 @@ warnings during execution of BODY."
(byte-compile-form (nth 2 form) for-effect))
(byte-compile-goto 'byte-goto donetag)
(byte-compile-out-tag elsetag)
- (byte-compile-body (cdr (cdr (cdr form))) for-effect)
+ (byte-compile-maybe-guarded (list 'not clause)
+ (byte-compile-body (cdr (cdr (cdr form))) for-effect))
(byte-compile-out-tag donetag))))
(setq for-effect nil))
@@ -3450,24 +3453,38 @@ warnings during execution of BODY."
(args (cdr form)))
(if (null args)
(byte-compile-form-do-effect t)
- (while (cdr args)
- (byte-compile-form (car args))
+ (byte-compile-and-recursion args failtag))))
+
+;; Handle compilation of a nontrivial `and' call.
+;; We use tail recursion so we can use byte-compile-maybe-guarded.
+(defun byte-compile-and-recursion (rest failtag)
+ (if (cdr rest)
+ (progn
+ (byte-compile-form (car rest))
(byte-compile-goto-if nil for-effect failtag)
- (setq args (cdr args)))
- (byte-compile-form-do-effect (car args))
- (byte-compile-out-tag failtag))))
+ (byte-compile-maybe-guarded (car rest)
+ (byte-compile-and-recursion (cdr rest) failtag)))
+ (byte-compile-form-do-effect (car rest))
+ (byte-compile-out-tag failtag)))
(defun byte-compile-or (form)
(let ((wintag (byte-compile-make-tag))
(args (cdr form)))
(if (null args)
(byte-compile-form-do-effect nil)
- (while (cdr args)
- (byte-compile-form (car args))
+ (byte-compile-or-recursion args wintag))))
+
+;; Handle compilation of a nontrivial `or' call.
+;; We use tail recursion so we can use byte-compile-maybe-guarded.
+(defun byte-compile-or-recursion (rest wintag)
+ (if (cdr rest)
+ (progn
+ (byte-compile-form (car rest))
(byte-compile-goto-if t for-effect wintag)
- (setq args (cdr args)))
- (byte-compile-form-do-effect (car args))
- (byte-compile-out-tag wintag))))
+ (byte-compile-maybe-guarded (list 'not (car rest))
+ (byte-compile-or-recursion (cdr rest) wintag)))
+ (byte-compile-form-do-effect (car rest))
+ (byte-compile-out-tag wintag)))
(defun byte-compile-while (form)
(let ((endtag (byte-compile-make-tag))