From: Glenn Morris Date: Thu, 10 Sep 2009 06:22:30 +0000 (+0000) Subject: (byte-compile-function-environment): Doc fix. X-Git-Tag: emacs-pretest-23.1.90~1418 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cb4fb1d065cecb8a3bcde351c98d852c8fe618c9;p=emacs.git (byte-compile-function-environment): Doc fix. (byte-compile-file-form-autoload): Don't warn about unknown functions where the autoload statement comes after the use. (with-no-warnings): Give it a byte-hunk-handler like than of progn, so that any handlers inside the body (eg require) are in turn respected. --- diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 0e7b9781601..52994e1fbcf 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -532,7 +532,8 @@ This is so we can inline them when necessary. Each element looks like (FUNCTIONNAME . DEFINITION). It is \(FUNCTIONNAME . nil) when a function is redefined as a macro. It is \(FUNCTIONNAME . t) when all we know is that it was defined, -and we don't know the definition.") +and we don't know the definition. For an autoloaded function, DEFINITION +has the form (autoload . FILENAME).") (defvar byte-compile-unresolved-functions nil "Alist of undefined functions to which calls have been compiled. @@ -2301,13 +2302,25 @@ list that represents a doc string reference. (eval (nth 5 form)) ;Macro (eval form)) ;Define the autoload. ;; Avoid undefined function warnings for the autoload. - (if (and (consp (nth 1 form)) + (when (and (consp (nth 1 form)) (eq (car (nth 1 form)) 'quote) (consp (cdr (nth 1 form))) (symbolp (nth 1 (nth 1 form)))) - (push (cons (nth 1 (nth 1 form)) - (cons 'autoload (cdr (cdr form)))) - byte-compile-function-environment)) + (push (cons (nth 1 (nth 1 form)) + (cons 'autoload (cdr (cdr form)))) + byte-compile-function-environment) + ;; If an autoload occurs _before_ the first call to a function, + ;; byte-compile-callargs-warn does not add an entry to + ;; byte-compile-unresolved-functions. Here we mimic the logic + ;; of byte-compile-callargs-warn so as not to warn if the + ;; autoload comes _after_ the function call. + ;; Alternatively, similar logic could go in + ;; byte-compile-warn-about-unresolved-functions. + (or (memq (nth 1 (nth 1 form)) byte-compile-noruntime-functions) + (setq byte-compile-unresolved-functions + (delq (assq (nth 1 (nth 1 form)) + byte-compile-unresolved-functions) + byte-compile-unresolved-functions)))) (if (stringp (nth 3 form)) form ;; No doc string, so we can compile this as a normal form. @@ -2387,6 +2400,14 @@ list that represents a doc string reference. ;; Return nil so the forms are not output twice. nil) +(put 'with-no-warnings 'byte-hunk-handler + 'byte-compile-file-form-with-no-warnings) +(defun byte-compile-file-form-with-no-warnings (form) + ;; cf byte-compile-file-form-progn. + (let (byte-compile-warnings) + (mapc 'byte-compile-file-form (cdr form)) + nil)) + ;; This handler is not necessary, but it makes the output from dont-compile ;; and similar macros cleaner. (put 'eval 'byte-hunk-handler 'byte-compile-file-form-eval)