comparison lispref/tips.texi @ 70969:044c7ca7a4ff

(Coding Conventions): Advise against using eval-after-load in packages. Add an index entry.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 26 May 2006 19:32:02 +0000
parents 67a078792729
children 2a973dfbccc2
comparison
equal deleted inserted replaced
70968:a26fd6a82aff 70969:044c7ca7a4ff
33 @end menu 33 @end menu
34 34
35 @node Coding Conventions 35 @node Coding Conventions
36 @section Emacs Lisp Coding Conventions 36 @section Emacs Lisp Coding Conventions
37 37
38 @cindex coding conventions in Emacs Lisp
38 Here are conventions that you should follow when writing Emacs Lisp 39 Here are conventions that you should follow when writing Emacs Lisp
39 code intended for widespread use: 40 code intended for widespread use:
40 41
41 @itemize @bullet 42 @itemize @bullet
42 @item 43 @item
50 don't postpone it. 51 don't postpone it.
51 52
52 @item 53 @item
53 Since all global variables share the same name space, and all 54 Since all global variables share the same name space, and all
54 functions share another name space, you should choose a short word to 55 functions share another name space, you should choose a short word to
55 distinguish your program from other Lisp programs.@footnote{The 56 distinguish your program from other Lisp programs@footnote{The
56 benefits of a Common Lisp-style package system are considered not to 57 benefits of a Common Lisp-style package system are considered not to
57 outweigh the costs.} Then take care to begin the names of all global 58 outweigh the costs.}. Then take care to begin the names of all global
58 variables, constants, and functions in your program with the chosen 59 variables, constants, and functions in your program with the chosen
59 prefix. This helps avoid name conflicts. 60 prefix. This helps avoid name conflicts.
60 61
61 Occasionally, for a command name intended for users to use, it is more 62 Occasionally, for a command name intended for users to use, it is more
62 convenient if some words come before the package's name prefix. And 63 convenient if some words come before the package's name prefix. And
173 @end example 174 @end example
174 175
175 @item 176 @item
176 Redefining (or advising) an Emacs primitive is discouraged. It may do 177 Redefining (or advising) an Emacs primitive is discouraged. It may do
177 the right thing for a particular program, but there is no telling what 178 the right thing for a particular program, but there is no telling what
178 other programs might break as a result. 179 other programs might break as a result. In any case, it is a
180 maintenance burden because the two packages become highly dependent on
181 each other.
182
183 @item
184 Likewise, avoid using @code{eval-after-load} (@pxref{Hooks for
185 Loading}) in libraries and packages. This feature is meant for
186 personal customizations; using it in a Lisp package increases the
187 coupling between it and the package mentioned in
188 @code{eval-after-load}, and thus makes it harder to maintain the two
189 packages independently.
179 190
180 @item 191 @item
181 If a file does replace any of the functions or library programs of 192 If a file does replace any of the functions or library programs of
182 standard Emacs, prominent comments at the beginning of the file should 193 standard Emacs, prominent comments at the beginning of the file should
183 say which functions are replaced, and how the behavior of the 194 say which functions are replaced, and how the behavior of the