From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.devel Subject: byte-compiler warnings about undefined functions can now be silenced Date: Sun, 18 Nov 2007 19:39:36 -0500 Message-ID: <18240.56136.448503.860758@fencepost.gnu.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1195432805 25060 80.91.229.12 (19 Nov 2007 00:40:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 Nov 2007 00:40:05 +0000 (UTC) Cc: Dan Nicolaescu To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 19 01:40:11 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1ItugL-0007AZ-TH for ged-emacs-devel@m.gmane.org; Mon, 19 Nov 2007 01:40:10 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Itug8-00065c-Ba for ged-emacs-devel@m.gmane.org; Sun, 18 Nov 2007 19:39:56 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Itufq-000637-Rl for emacs-devel@gnu.org; Sun, 18 Nov 2007 19:39:38 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Itufp-00062n-Ek for emacs-devel@gnu.org; Sun, 18 Nov 2007 19:39:38 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Itufp-00062k-A6 for emacs-devel@gnu.org; Sun, 18 Nov 2007 19:39:37 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Itufp-0004uP-1O for emacs-devel@gnu.org; Sun, 18 Nov 2007 19:39:37 -0500 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1Itufo-0001IF-Fb; Sun, 18 Nov 2007 19:39:36 -0500 In-Reply-To: X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:83596 Archived-At: Dan Nicolaescu wrote: > Could you please post a message to emacs-devel about how to use this > feature? > > An example with the warning that is currently produced by the byte > compiler and how to use this to get rid of it. As requested... When bootstrapping, there are lots of messages about functions that are "not known to be defined". The compiler is technically correct, but the code is usually such that when it actually runs, the function will be defined. For example, byte-compiling fortran.el used to warn: In end of data: fortran.el:2152:1:Warning: the function `gud-find-c-expr' is not known to be defined. But gud-find-c-expr was only used in the function that fortran mode uses for the local value of `gud-find-expr-function'. So this would only ever be called from gud, so the warning can safely be suppressed. It's nice to do this, so that real warnings are more visible. All you need to do is add a `declare-function' statement before the first use of the function in question: (declare-function gud-find-c-expr "gud.el" nil) This says that gud-find-c-expr is defined in "gud.el" (the `.el' can be omitted). The file path is either absolute, or relative to the one with the declare-function statement (e.g. "../files.el"). The 3rd argument is optional, and specifies the argument list of gud-find-c-expr. In this case, it takes no arguments (`nil' is different from not specifying a value). In other cases, this might be something like (file &optional overwrite). You don't have to specify the argument list, but if you do the byte-compiler will check that the calls match the declaration. The functions `check-declare-file' and `check-declare-directory' will check that all the declare-function statements in a file or directory are true (i.e. that the functions are defined in the specified files, and have the same argument lists, if specified). `make check-declare' will check all of leim/ and lisp/. > Also, IMO it would be good to add declare-function to the 22.2 > branch, (even as an empty stub if it's considered too risky), this > should help with compatibility between the 2 branches. I don't have much of an opinion. It could easily be added as a no-op (it's almost a no-op now...).