Mercurial > emacs
comparison lispref/tips.texi @ 17280:96762d1abb7c
(Coding Conventions): Node renamed from Style Tips.
Xref the Major Mode Conventions and Minor Mode Conventions nodes.
Other smaller changes in it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 01 Apr 1997 23:38:01 +0000 |
parents | 981e116b4ac6 |
children | 8546df4cb304 |
comparison
equal
deleted
inserted
replaced
17279:d2c67029b824 | 17280:96762d1abb7c |
---|---|
2 @c This is part of the GNU Emacs Lisp Reference Manual. | 2 @c This is part of the GNU Emacs Lisp Reference Manual. |
3 @c Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. | 3 @c Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. |
4 @c See the file elisp.texi for copying conditions. | 4 @c See the file elisp.texi for copying conditions. |
5 @setfilename ../info/tips | 5 @setfilename ../info/tips |
6 @node Tips, GNU Emacs Internals, Calendar, Top | 6 @node Tips, GNU Emacs Internals, Calendar, Top |
7 @appendix Tips and Standards | 7 @appendix Tips and Conventions |
8 @cindex tips | 8 @cindex tips |
9 @cindex standards of coding style | 9 @cindex standards of coding style |
10 @cindex coding standards | 10 @cindex coding standards |
11 | 11 |
12 This chapter describes no additional features of Emacs Lisp. | 12 This chapter describes no additional features of Emacs Lisp. Instead |
13 Instead it gives advice on making effective use of the features described | 13 it gives advice on making effective use of the features described in the |
14 in the previous chapters. | 14 previous chapters, and describes conventions Emacs Lisp programmers |
15 should follow. | |
15 | 16 |
16 @menu | 17 @menu |
17 * Style Tips:: Writing clean and robust programs. | 18 * Coding Conventions:: Conventions for clean and robust programs. |
18 * Compilation Tips:: Making compiled code run fast. | 19 * Compilation Tips:: Making compiled code run fast. |
19 * Documentation Tips:: Writing readable documentation strings. | 20 * Documentation Tips:: Writing readable documentation strings. |
20 * Comment Tips:: Conventions for writing comments. | 21 * Comment Tips:: Conventions for writing comments. |
21 * Library Headers:: Standard headers for library packages. | 22 * Library Headers:: Standard headers for library packages. |
22 @end menu | 23 @end menu |
23 | 24 |
24 @node Style Tips | 25 @node Coding Conventions |
25 @section Writing Clean Lisp Programs | 26 @section Emacs Lisp Coding Conventions |
26 | 27 |
27 Here are some tips for avoiding common errors in writing Lisp code | 28 Here are conventions that you should follow when writing Emacs Lisp |
28 intended for widespread use: | 29 code intended for widespread use: |
29 | 30 |
30 @itemize @bullet | 31 @itemize @bullet |
31 @item | 32 @item |
32 Since all global variables share the same name space, and all functions | 33 Since all global variables share the same name space, and all functions |
33 share another name space, you should choose a short word to distinguish | 34 share another name space, you should choose a short word to distinguish |
82 | 83 |
83 Using @code{eval-when-compile} avoids loading @var{bar} when | 84 Using @code{eval-when-compile} avoids loading @var{bar} when |
84 the compiled version of @var{foo} is @emph{used}. | 85 the compiled version of @var{foo} is @emph{used}. |
85 | 86 |
86 @item | 87 @item |
87 If you define a major mode, make sure to run a hook variable using | 88 When defining a major mode, please follow the major mode |
88 @code{run-hooks}, just as the existing major modes do. @xref{Hooks}. | 89 conventions. @xref{Major Mode Conventions}. |
90 | |
91 @item | |
92 When defining a minor mode, please follow the minor mode | |
93 conventions. @xref{Minor Mode Conventions}. | |
89 | 94 |
90 @item | 95 @item |
91 If the purpose of a function is to tell you whether a certain condition | 96 If the purpose of a function is to tell you whether a certain condition |
92 is true or false, give the function a name that ends in @samp{p}. If | 97 is true or false, give the function a name that ends in @samp{p}. If |
93 the name is one word, add just @samp{p}; if the name is multiple words, | 98 the name is one word, add just @samp{p}; if the name is multiple words, |
158 @item | 163 @item |
159 It is a bad idea to define aliases for the Emacs primitives. Use the | 164 It is a bad idea to define aliases for the Emacs primitives. Use the |
160 standard names instead. | 165 standard names instead. |
161 | 166 |
162 @item | 167 @item |
163 Redefining an Emacs primitive is an even worse idea. | 168 Redefining (or advising) an Emacs primitive is discouraged. It may do |
164 It may do the right thing for a particular program, but | 169 the right thing for a particular program, but there is no telling what |
165 there is no telling what other programs might break as a result. | 170 other programs might break as a result. |
166 | 171 |
167 @item | 172 @item |
168 If a file does replace any of the functions or library programs of | 173 If a file does replace any of the functions or library programs of |
169 standard Emacs, prominent comments at the beginning of the file should | 174 standard Emacs, prominent comments at the beginning of the file should |
170 say which functions are replaced, and how the behavior of the | 175 say which functions are replaced, and how the behavior of the |