[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
suppressing byte-compiler warnings about undefined functions
From: |
Glenn Morris |
Subject: |
suppressing byte-compiler warnings about undefined functions |
Date: |
Fri, 09 Nov 2007 19:55:08 -0500 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
Here's an attempt at a method to allow for suppressing of
byte-compiler warnings about undefined functions.
I haven't yet written the function to check that functions are
actually defined in the specified files, but I imagine it would be
straightforward.
*** byte-run.el 26 Jul 2007 05:26:44 -0000 1.22
--- byte-run.el 10 Nov 2007 00:32:42 -0000
***************
*** 103,108 ****
--- 103,118 ----
(eval-and-compile
(put ',name 'byte-optimizer 'byte-compile-inline-expand))))
+ (defun declare-function (fn file)
+ "Tell the byte-compiler that function FN is defined, in FILE.
+ The FILE argument is not used by the byte-compiler, but by the
+ function `check-declared-functions', which checks that FILE
+ contains a definition for FN. FILE should be either absolute, or
+ relative to the location of the file containing the declaration, e.g.
+
+ \(declare-function 'c-end-of-defun \"progmodes/cc-cmds.el\")"
+ nil)
+
(defun make-obsolete (obsolete-name current-name &optional when)
"Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
The warning will say that CURRENT-NAME should be used instead.
*** bytecomp.el 9 Nov 2007 15:57:46 -0000 2.216
--- bytecomp.el 10 Nov 2007 00:46:23 -0000
***************
*** 534,539 ****
--- 534,542 ----
Used for warnings when a function is not known to be defined or is later
defined with incorrect args.")
+ (defvar byte-compile-declared-functions nil
+ "List of functions constructed by `declare-function' calls when compiling.")
+
(defvar byte-compile-noruntime-functions nil
"Alist of functions called that may not be defined when the compiled code
is run.
Used for warnings about calling a function that is defined during compilation
***************
*** 1472,1479 ****
;; Separate the functions that will not be available at runtime
;; from the truly unresolved ones.
(dolist (f byte-compile-unresolved-functions)
! (setq f (car f))
! (if (fboundp f) (push f noruntime) (push f unresolved)))
;; Complain about the no-run-time functions
(byte-compile-print-syms
"the function `%s' might not be defined at runtime."
--- 1475,1482 ----
;; Separate the functions that will not be available at runtime
;; from the truly unresolved ones.
(dolist (f byte-compile-unresolved-functions)
! (unless (memq (setq f (car f)) byte-compile-declared-functions)
! (if (fboundp f) (push f noruntime) (push f unresolved))))
;; Complain about the no-run-time functions
(byte-compile-print-syms
"the function `%s' might not be defined at runtime."
***************
*** 1895,1901 ****
;; would be useful to delay this warning until all have been
;; compiled. A: Yes! b-c-u-f might contain dross from a
;; previous byte-compile.
! (setq byte-compile-unresolved-functions nil)
;; Compile the forms from the input buffer.
(while (progn
--- 1898,1905 ----
;; would be useful to delay this warning until all have been
;; compiled. A: Yes! b-c-u-f might contain dross from a
;; previous byte-compile.
! (setq byte-compile-unresolved-functions nil
! byte-compile-declared-functions nil)
;; Compile the forms from the input buffer.
(while (progn
***************
*** 2818,2823 ****
--- 2822,2834 ----
(body
(list body))))
+ ;; Add an element to byte-compile-declared-functions.
+ (put 'declare-function 'byte-hunk-handler 'byte-compile-declare-function)
+ (defun byte-compile-declare-function (form)
+ (push (eval (cadr form)) byte-compile-declared-functions)
+ nil)
+
+
;; This is the recursive entry point for compiling each subform of an
;; expression.
;; If for-effect is non-nil, byte-compile-form will output a byte-discard
- suppressing byte-compiler warnings about undefined functions,
Glenn Morris <=
- Re: suppressing byte-compiler warnings about undefined functions, Stefan Monnier, 2007/11/09
- Re: suppressing byte-compiler warnings about undefined functions, Richard Stallman, 2007/11/10
- Re: suppressing byte-compiler warnings about undefined functions, Glenn Morris, 2007/11/10
- Re: suppressing byte-compiler warnings about undefined functions, Glenn Morris, 2007/11/10
- Re: suppressing byte-compiler warnings about undefined functions, Richard Stallman, 2007/11/11
- Re: suppressing byte-compiler warnings about undefined functions, Glenn Morris, 2007/11/12
- Re: suppressing byte-compiler warnings about undefined functions, martin rudalics, 2007/11/13
- Re: suppressing byte-compiler warnings about undefined functions, Glenn Morris, 2007/11/14
- Re: suppressing byte-compiler warnings about undefined functions, Stefan Monnier, 2007/11/14
- Re: suppressing byte-compiler warnings about undefined functions, Richard Stallman, 2007/11/14