From 26cc7ed550f2964a6e6b0258187e204c2f05f32d Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 18 Nov 2006 21:07:17 +0000 Subject: (byte-compile-maybe-guarded): Check `and' conditions for function or variable bindings. --- lisp/emacs-lisp/bytecomp.el | 55 +++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'lisp/emacs-lisp/bytecomp.el') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 02a88c13973..342ae2ab33a 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -3398,35 +3398,42 @@ being undefined will be suppressed. 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)) - (and (eq 'quote (car-safe (nth 1 ,condition))) - ;; Ignore if the symbol is already on the - ;; unresolved list. - (not (assq (nth 1 (nth 1 ,condition)) ; the relevant symbol - byte-compile-unresolved-functions)) - (nth 1 (nth 1 ,condition))))) - (bound (if (or (eq 'boundp (car-safe ,condition)) - (eq 'default-boundp (car-safe ,condition))) - (and (eq 'quote (car-safe (nth 1 ,condition))) - (nth 1 (nth 1 ,condition))))) - ;; Maybe add to the bound list. - (byte-compile-bound-variables - (if bound - (cons bound byte-compile-bound-variables) - byte-compile-bound-variables)) - ;; Suppress all warnings, for code not used in Emacs. - (byte-compile-warnings + `(let* ((byte-compile-warnings + ;; Suppress all warnings, for code not used in Emacs. (if (member ,condition '((featurep 'xemacs) (not (featurep 'emacs)))) - nil byte-compile-warnings))) + nil + byte-compile-warnings)) + (byte-compile-bound-variables byte-compile-bound-variables) + binding fbound-list) + (mapc (lambda (subcondition) + (cond ((eq 'fboundp (car-safe subcondition)) + (setq binding (and (eq 'quote (car-safe (nth 1 subcondition))) + ;; Ignore if the symbol is already on the + ;; unresolved list. + (not (assq (nth 1 (nth 1 subcondition)) + byte-compile-unresolved-functions)) + (nth 1 (nth 1 subcondition)))) + (if binding (setq fbound-list (cons binding fbound-list)))) + ((or (eq 'boundp (car-safe subcondition)) + (eq 'default-boundp (car-safe subcondition))) + (setq binding (and (eq 'quote (car-safe (nth 1 subcondition))) + (nth 1 (nth 1 subcondition)))) + (if binding (setq byte-compile-bound-variables + (cons binding byte-compile-bound-variables)))))) + ;; Inspect each element in an `and' condition; otherwise, + ;; inspect the condition itself. + (if (eq 'and (car-safe ,condition)) + (cdr ,condition) + (list ,condition))) (unwind-protect (progn ,@body) ;; Maybe remove the function symbol from the unresolved list. - (if fbound - (setq byte-compile-unresolved-functions - (delq (assq fbound byte-compile-unresolved-functions) - byte-compile-unresolved-functions)))))) + (mapc (lambda (fun) + (setq byte-compile-unresolved-functions + (delq (assq fun byte-compile-unresolved-functions) + byte-compile-unresolved-functions))) + fbound-list)))) (defun byte-compile-if (form) (byte-compile-form (car (cdr form))) -- cgit v1.2.3 From 8195ef65f0098b9347e22349fbfa292150d5ad2b Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sun, 19 Nov 2006 15:19:39 +0000 Subject: (byte-compile-if): Revert last change. --- lisp/emacs-lisp/bytecomp.el | 55 ++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 31 deletions(-) (limited to 'lisp/emacs-lisp/bytecomp.el') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 342ae2ab33a..02a88c13973 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -3398,42 +3398,35 @@ being undefined will be suppressed. 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* ((byte-compile-warnings - ;; Suppress all warnings, for code not used in Emacs. + `(let* ((fbound + (if (eq 'fboundp (car-safe ,condition)) + (and (eq 'quote (car-safe (nth 1 ,condition))) + ;; Ignore if the symbol is already on the + ;; unresolved list. + (not (assq (nth 1 (nth 1 ,condition)) ; the relevant symbol + byte-compile-unresolved-functions)) + (nth 1 (nth 1 ,condition))))) + (bound (if (or (eq 'boundp (car-safe ,condition)) + (eq 'default-boundp (car-safe ,condition))) + (and (eq 'quote (car-safe (nth 1 ,condition))) + (nth 1 (nth 1 ,condition))))) + ;; Maybe add to the bound list. + (byte-compile-bound-variables + (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 (member ,condition '((featurep 'xemacs) (not (featurep 'emacs)))) - nil - byte-compile-warnings)) - (byte-compile-bound-variables byte-compile-bound-variables) - binding fbound-list) - (mapc (lambda (subcondition) - (cond ((eq 'fboundp (car-safe subcondition)) - (setq binding (and (eq 'quote (car-safe (nth 1 subcondition))) - ;; Ignore if the symbol is already on the - ;; unresolved list. - (not (assq (nth 1 (nth 1 subcondition)) - byte-compile-unresolved-functions)) - (nth 1 (nth 1 subcondition)))) - (if binding (setq fbound-list (cons binding fbound-list)))) - ((or (eq 'boundp (car-safe subcondition)) - (eq 'default-boundp (car-safe subcondition))) - (setq binding (and (eq 'quote (car-safe (nth 1 subcondition))) - (nth 1 (nth 1 subcondition)))) - (if binding (setq byte-compile-bound-variables - (cons binding byte-compile-bound-variables)))))) - ;; Inspect each element in an `and' condition; otherwise, - ;; inspect the condition itself. - (if (eq 'and (car-safe ,condition)) - (cdr ,condition) - (list ,condition))) + nil byte-compile-warnings))) (unwind-protect (progn ,@body) ;; Maybe remove the function symbol from the unresolved list. - (mapc (lambda (fun) - (setq byte-compile-unresolved-functions - (delq (assq fun byte-compile-unresolved-functions) - byte-compile-unresolved-functions))) - fbound-list)))) + (if fbound + (setq byte-compile-unresolved-functions + (delq (assq fbound byte-compile-unresolved-functions) + byte-compile-unresolved-functions)))))) (defun byte-compile-if (form) (byte-compile-form (car (cdr form))) -- cgit v1.2.3 From 7fb4fa10a82d1a44f69d9027a0304c4eee89db61 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Tue, 28 Nov 2006 02:22:17 +0000 Subject: (byte-compile-get-constant): Replace incorrect use of assoc-default with a loop. --- lisp/emacs-lisp/bytecomp.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/bytecomp.el') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 02a88c13973..0fa2da23721 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2864,8 +2864,12 @@ That command is designed for interactive use only" fn)) (defmacro byte-compile-get-constant (const) `(or (if (stringp ,const) - (assoc-default ,const byte-compile-constants - 'equal-including-properties nil) + ;; In a string constant, treat properties as significant. + (let (result) + (dolist (elt byte-compile-constants) + (if (equal-including-properties (car elt) ,const) + (setq result elt))) + result) (assq ,const byte-compile-constants)) (car (setq byte-compile-constants (cons (list ,const) byte-compile-constants))))) -- cgit v1.2.3 From 9bb2e9f86baec86ae8db1fec1c68a4d744c5faa9 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Thu, 30 Nov 2006 16:26:37 +0000 Subject: (byte-optimize, byte-compile-warnings): Doc fixes. --- lisp/emacs-lisp/bytecomp.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lisp/emacs-lisp/bytecomp.el') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 0fa2da23721..6790f199206 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -264,11 +264,12 @@ facilities that have been added more recently." ;; this way can never be run in Emacs 18, and may even cause it to crash.") (defcustom byte-optimize t - "*Enables optimization in the byte compiler. -nil means don't do any optimization. -t means do all optimizations. -`source' means do source-level optimizations only. -`byte' means do code-level optimizations only." + "*Enable optimization in the byte compiler. +Possible values are: + nil - no optimization + t - all optimizations + `source' - source-level optimizations only + `byte' - code-level optimizations only" :group 'bytecomp :type '(choice (const :tag "none" nil) (const :tag "all" t) @@ -336,7 +337,7 @@ If it is 'byte, then only byte-level optimizations will be logged." (defcustom byte-compile-warnings t "*List of warnings that the byte-compiler should issue (t for all). -Elements of the list may be be: +Elements of the list may be: free-vars references to variables not in the current lexical scope. unresolved calls to unknown functions. -- cgit v1.2.3