aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2004-11-16 17:30:48 +0000
committerRichard M. Stallman2004-11-16 17:30:48 +0000
commit155cb2e57eb0ae8e874824bcaf733cfe97c4f788 (patch)
tree4256b0a4d7752336823bb5fae29ee4f8b5c99e47
parent5d645852385218a0252ec29aabf3de28364d3ec5 (diff)
downloademacs-155cb2e57eb0ae8e874824bcaf733cfe97c4f788.tar.gz
emacs-155cb2e57eb0ae8e874824bcaf733cfe97c4f788.zip
(Coding Conventions): Separate defvar and require
methods to avoid warnings. Use require only when there are many functions and variables from that package.
-rw-r--r--lispref/tips.texi35
1 files changed, 22 insertions, 13 deletions
diff --git a/lispref/tips.texi b/lispref/tips.texi
index a85147f1d8f..4182260028b 100644
--- a/lispref/tips.texi
+++ b/lispref/tips.texi
@@ -370,25 +370,34 @@ coherent if all libraries use the same conventions.
370 370
371@item 371@item
372Try to avoid compiler warnings about undefined free variables, by adding 372Try to avoid compiler warnings about undefined free variables, by adding
373@code{defvar} definitions for these variables. 373dummy @code{defvar} definitions for these variables, like this:
374 374
375Sometimes adding a @code{require} for another package is useful to avoid 375@example
376compilation warnings for variables and functions defined in that 376(defvar foo)
377package. If you do this, often it is better if the @code{require} acts 377@end example
378only at compile time. Here's how to do that: 378
379Such a definition has no effect except to tell the compiler
380not to warn about uses of the variable @code{foo} in this file.
381
382@item
383If you use many functions and variables from a certain file, you can
384add a @code{require} for that package to avoid compilation warnings
385for them. It is better if the @code{require} acts only at compile
386time. Here's how to do this:
379 387
380@example 388@example
381(eval-when-compile 389(eval-when-compile
382 (require 'foo) 390 (require 'foo))
383 (defvar bar-baz))
384@end example 391@end example
385 392
386If you bind a variable in one function, and use it or set it in another 393@item
387function, the compiler warns about the latter function unless the 394If you bind a variable in one function, and use it or set it in
388variable has a definition. But often these variables have short names, 395another function, the compiler warns about the latter function unless
389and it is not clean for Lisp packages to define such variable names. 396the variable has a definition. But adding a definition would be
390Therefore, you should rename the variable to start with the name prefix 397unclean if the variable has a short names, since Lisp packages should
391used for the other functions and variables in your package. 398not define short variable names. The right thing to do is to rename
399this variable to start with the name prefix used for the other
400functions and variables in your package.
392 401
393@item 402@item
394Indent each function with @kbd{C-M-q} (@code{indent-sexp}) using the 403Indent each function with @kbd{C-M-q} (@code{indent-sexp}) using the