all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* suppressing byte-compiler warnings about undefined functions
@ 2007-11-10  0:55 Glenn Morris
  2007-11-10  3:13 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Glenn Morris @ 2007-11-10  0:55 UTC (permalink / raw)
  To: emacs-devel


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)
+ 
+ \f
  ;; 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2007-11-24  3:12 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-10  0:55 suppressing byte-compiler warnings about undefined functions Glenn Morris
2007-11-10  3:13 ` Stefan Monnier
2007-11-10 17:54 ` Richard Stallman
2007-11-11  1:11   ` Glenn Morris
2007-11-11  4:00     ` Glenn Morris
2007-11-11 19:33     ` Richard Stallman
2007-11-13  4:20       ` Glenn Morris
2007-11-13  9:31         ` martin rudalics
2007-11-14  5:32           ` Glenn Morris
2007-11-14 14:53             ` Stefan Monnier
2007-11-15  3:07             ` Richard Stallman
2007-11-17  3:58               ` Glenn Morris
2007-11-17 23:30                 ` Richard Stallman
2007-11-13 20:02         ` Richard Stallman
2007-11-13 21:05           ` Stefan Monnier
2007-11-14  5:30             ` Glenn Morris
2007-11-15  3:06             ` Richard Stallman
     [not found]     ` <ur9oddrnmg0.fsf@mothra.ics.uci.edu>
2007-11-19  0:39       ` byte-compiler warnings about undefined functions can now be silenced Glenn Morris
2007-11-19  9:04         ` martin rudalics
2007-11-24  3:12           ` Glenn Morris
2007-11-19 19:02         ` Richard Stallman
2007-11-20  4:05           ` Glenn Morris
2007-11-19 19:33         ` Jay Belanger
2007-11-19 20:46           ` Glenn Morris
2007-11-20 12:12           ` Richard Stallman
2007-11-11  8:46 ` suppressing byte-compiler warnings about undefined functions Alan Mackenzie
2007-11-11 15:51   ` Dan Nicolaescu
2007-11-11 16:10     ` Alan Mackenzie
2007-11-11 16:18       ` Dan Nicolaescu
2007-11-11 18:32         ` Dan Nicolaescu
2007-11-11 23:54           ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.