Mercurial > emacs
comparison lispref/tips.texi @ 62331:551071b66329
(Coding Conventions): Explain how important it is
that just loading certain files not change Emacs behavior.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 14 May 2005 14:02:39 +0000 |
parents | 0b041af08b4a |
children | 23a17af379b1 f042e7c0fe20 |
comparison
equal
deleted
inserted
replaced
62330:747b2c665140 | 62331:551071b66329 |
---|---|
35 Here are conventions that you should follow when writing Emacs Lisp | 35 Here are conventions that you should follow when writing Emacs Lisp |
36 code intended for widespread use: | 36 code intended for widespread use: |
37 | 37 |
38 @itemize @bullet | 38 @itemize @bullet |
39 @item | 39 @item |
40 Simply loading the package should not change Emacs's editing behavior. | |
41 Include a command or commands to enable and disable the feature, | |
42 or to invoke it. | |
43 | |
44 This convention is mandatory for any file that includes custom | |
45 definitions. If fixing such a file to follow this convention requires | |
46 an incompatible change, go ahead and make the incompatible change; | |
47 don't postpone it. | |
48 | |
49 @item | |
40 Since all global variables share the same name space, and all | 50 Since all global variables share the same name space, and all |
41 functions share another name space, you should choose a short word to | 51 functions share another name space, you should choose a short word to |
42 distinguish your program from other Lisp programs.@footnote{The | 52 distinguish your program from other Lisp programs.@footnote{The |
43 benefits of a Common Lisp-style package system are considered not to | 53 benefits of a Common Lisp-style package system are considered not to |
44 outweigh the costs.} Then take care to begin the names of all global | 54 outweigh the costs.} Then take care to begin the names of all global |
198 Modes such as Dired, Info, Compilation, and Occur redefine it in this | 208 Modes such as Dired, Info, Compilation, and Occur redefine it in this |
199 way. | 209 way. |
200 | 210 |
201 In addition, they should mark the text as a kind of ``link'' so that | 211 In addition, they should mark the text as a kind of ``link'' so that |
202 @kbd{mouse-1} will follow it also. @xref{Links and Mouse-1}. | 212 @kbd{mouse-1} will follow it also. @xref{Links and Mouse-1}. |
203 | |
204 @item | |
205 When a package provides a modification of ordinary Emacs behavior, it is | |
206 good to include a command to enable and disable the feature, provide a | |
207 command named @code{@var{whatever}-mode} which turns the feature on or | |
208 off, and make it autoload (@pxref{Autoload}). Design the package so | |
209 that simply loading it has no visible effect---that should not enable | |
210 the feature.@footnote{Consider that the package may be loaded | |
211 arbitrarily by Custom for instance.} Users will request the feature by | |
212 invoking the command. It is a good idea to define this command | |
213 as a minor mode. | |
214 | 213 |
215 @cindex unloading packages | 214 @cindex unloading packages |
216 If loading the file adds functions to hooks, define a function | 215 If loading the file adds functions to hooks, define a function |
217 @code{@var{feature}-unload-hook}, where @var{feature} is the name of | 216 @code{@var{feature}-unload-hook}, where @var{feature} is the name of |
218 the feature the package provides, and make it undo any such changes. | 217 the feature the package provides, and make it undo any such changes. |