emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: suppressing byte-compiler warnings about undefined functions


From: Richard Stallman
Subject: Re: suppressing byte-compiler warnings about undefined functions
Date: Sun, 11 Nov 2007 14:33:51 -0500

    + (defun declare-function (fn file &optional arglist)

Why not &rest?

    + Note that for the purposes of `check-declared-functions', this
    + statement must be the first non-whitespace on a line, and
    + everything up to the end of FILE must be all on the same line.
    + For example:
    + 
    + \(declare-function 'c-end-of-defun \"progmodes/cc-cmds.el\" '(&optional 
arg))"

Breaking the line after the file name
would make the example more helpful.

    + Note that for the purposes of `check-declared-functions', this
    + statement must be the first non-whitespace on a line, and
    + everything up to the end of FILE must be all on the same line.
    + For example:
    + 
    + \(declare-function 'c-end-of-defun \"progmodes/cc-cmds.el\" '(&optional 
arg))"
    + 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     10 Nov 2007 08:05:15 -0000      2.217
    --- bytecomp.el     11 Nov 2007 00:35:23 -0000
    ***************
    *** 1258,1264 ****
                      (byte-compile-fdefinition (car form) t)))
             (sig (if (and def (not (eq def t)))
                      (byte-compile-arglist-signature
    !              (if (eq 'lambda (car-safe def))
                           (nth 1 def)
                         (if (byte-code-function-p def)
                             (aref def 0)
    --- 1258,1264 ----
                      (byte-compile-fdefinition (car form) t)))
             (sig (if (and def (not (eq def t)))
                      (byte-compile-arglist-signature
    !              (if (memq (car-safe def) '(declared lambda))
                           (nth 1 def)
                         (if (byte-code-function-p def)
                             (aref def 0)
    ***************
    *** 2818,2823 ****
    --- 2818,2831 ----
            (body
             (list body))))

    + (put 'declare-function 'byte-hunk-handler 'byte-compile-declare-function)
    + (defun byte-compile-declare-function (form)
    +   (push (cons (eval (nth 1 form))
    +               (list 'declared (eval (nth 3 form))))
    +         byte-compile-function-environment)
    +   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




    ;; Adapted from authors.el.
    (defmacro checkdec-visit (file &rest body)
      "Execute the forms in BODY while visiting FILE.
    Re-uses an existing buffer visiting FILE if there is one.  The
    value returned is the value of the last form in BODY."
      (declare (indent 1))
      `(let ((existing-buffer (find-buffer-visiting ,file))
             (enable-local-variables :safe)
             (enable-local-eval nil)
             (buffer (find-file-noselect ,file)))

This would run a lot faster if it just reads the file
into a temporary buffer and avoids visiting.


checkdoc-scan could be far far more efficient.  It should scan all
files for `declare-function' calls, sort them by the file that is
supposed to define them, then load each file just once to verify.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]